maobaolong commented on a change in pull request #1096:
URL: https://github.com/apache/hadoop-ozone/pull/1096#discussion_r460067221



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/choose/algorithms/PipelineChoosePolicyFactory.java
##########
@@ -0,0 +1,71 @@
+/**
+ * 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.hdds.scm.pipeline.choose.algorithms;
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.scm.PipelineChoosePolicy;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * A factory to create pipeline choose policy instance based on configuration
+ * property {@link ScmConfigKeys#OZONE_SCM_PIPELINE_CHOOSE_IMPL_KEY}.
+ */
+public final class PipelineChoosePolicyFactory {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(PipelineChoosePolicyFactory.class);
+
+  private static final Class<? extends PipelineChoosePolicy>
+      OZONE_SCM_PIPELINE_CHOOSE_IMPL_DEFAULT =
+      RandomPipelineChoosePolicy.class;
+
+  private PipelineChoosePolicyFactory() {
+  }
+
+  public static PipelineChoosePolicy getPolicy(
+      ConfigurationSource conf) throws SCMException {
+    final Class<? extends PipelineChoosePolicy> policyClass = conf
+        .getClass(ScmConfigKeys.OZONE_SCM_PIPELINE_CHOOSE_IMPL_KEY,
+            OZONE_SCM_PIPELINE_CHOOSE_IMPL_DEFAULT,
+            PipelineChoosePolicy.class);
+    Constructor<? extends PipelineChoosePolicy> constructor;
+    try {
+      constructor = policyClass.getDeclaredConstructor();

Review comment:
       Now it cannot get the client address while allocate block. After this 
PR, we can create a new ticket to add client parameter to the allocateblock 
method, then, I can write a localFirstPolicy. Also, I plan to let datanode 
report its utilized to scm, so i can implement a LowLoadFirstPolicy, we can 
also collect the pipeline vote count, batch size, use these information, we can 
get write many kind of choose pipeline policy.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to