ChenSammi commented on code in PR #9858: URL: https://github.com/apache/ozone/pull/9858#discussion_r2910439419
########## hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/ContainerChoosingPolicyFactory.java: ########## @@ -0,0 +1,56 @@ +/* + * 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; + +import static org.apache.hadoop.ozone.container.diskbalancer.DiskBalancerConfiguration.HDDS_DATANODE_DISKBALANCER_CONTAINER_CHOOSING_POLICY; + +import java.util.concurrent.locks.ReentrantLock; +import org.apache.hadoop.hdds.conf.ConfigurationSource; +import org.apache.hadoop.ozone.container.diskbalancer.policy.ContainerChoosingPolicy; +import org.apache.hadoop.ozone.container.diskbalancer.policy.DefaultContainerChoosingPolicy; +import org.apache.ratis.util.ReflectionUtils; + +/** + * A factory to create {@link ContainerChoosingPolicy} instances for the DiskBalancer. + * The policy class is configured via + * {@link DiskBalancerConfiguration#getContainerChoosingPolicyClass()}. + */ +public final class ContainerChoosingPolicyFactory { + + private static final Class<? extends ContainerChoosingPolicy> + DEFAULT_CONTAINER_CHOOSING_POLICY = DefaultContainerChoosingPolicy.class; + + // A lock to coordinate space reservation between multiple policy instances and threads + private static final ReentrantLock LOCK = new ReentrantLock(); Review Comment: We have to share the LOCK with VolumeChoosingPolicyFactory. Otherwise, ContainerChoosePolicy reserve committed space is not synced with volume choosing policy created by VolumeChoosingPolicyFactory. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
