ChenSammi commented on code in PR #4408:
URL: https://github.com/apache/ozone/pull/4408#discussion_r1141621022


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultContainerChoosingPolicy.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.hadoop.ozone.container.common.impl.ContainerData;
+import org.apache.hadoop.ozone.container.common.interfaces.Container;
+import org.apache.hadoop.ozone.container.common.volume.HddsVolume;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Choose a container from specified volume, make sure it's not being 
balancing.
+ */
+public class DefaultContainerChoosingPolicy implements ContainerChoosingPolicy 
{
+  public static final Logger LOG = LoggerFactory.getLogger(
+      DefaultContainerChoosingPolicy.class);
+
+  @Override
+  public ContainerData chooseContainer(OzoneContainer ozoneContainer,
+      HddsVolume hddsVolume, Set<Long> inProgressContainerIDs) {

Review Comment:
   I think we should turn this API into a batch API. 
   ozoneContainer.getController().getContainers(hddsVolume) will be a quite 
expensive operation once the container per volume reach a high number. Try to 
mostly leverage the result in one chooseContainer call, batch allocation or 
cache the container list of this volume for a while.
   



-- 
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]

Reply via email to