sumitagrawl commented on code in PR #8932: URL: https://github.com/apache/ozone/pull/8932#discussion_r2318958402
########## hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultVolumeChoosingPolicy.java: ########## @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.container.diskbalancer.policy; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.hadoop.hdds.fs.SpaceUsageSource; +import org.apache.hadoop.ozone.container.common.utils.StorageVolumeUtil; +import org.apache.hadoop.ozone.container.common.volume.AvailableSpaceFilter; +import org.apache.hadoop.ozone.container.common.volume.HddsVolume; +import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Choose a random volume for disk balancing. + * + * Source volumes use deltaMap to simulate space that will be freed (pre-deleted). + * Destination volumes use committedBytes to account for space already reserved. + * Both deltaMap and committedBytes are considered to calculate usage. + */ +public class DefaultVolumeChoosingPolicy implements DiskBalancerVolumeChoosingPolicy { + + public static final Logger LOG = LoggerFactory.getLogger( + DefaultVolumeChoosingPolicy.class); + private final ReentrantLock lock; + + public DefaultVolumeChoosingPolicy(ReentrantLock globalLock) { + lock = globalLock; + } + + @Override + public Pair<HddsVolume, HddsVolume> chooseVolume(MutableVolumeSet volumeSet, + double threshold, Map<HddsVolume, Long> deltaMap, long containerSize) { + lock.lock(); + try { + double idealUsage = volumeSet.getIdealUsage(); + + // Threshold is given as a percentage + double normalizedThreshold = threshold / 100; + List<HddsVolume> volumes = StorageVolumeUtil Review Comment: We need fix as above, avoid low disk space, as we are moving based on density only. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org