You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2021/02/24 08:46:04 UTC

[ozone] 15/27: fixing volume choosing policy initialization

This is an automated email from the ASF dual-hosted git repository.

elek pushed a commit to branch HDDS-3816-ec
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit 20c151ee97e6736094a417a3425a14198a2638b0
Author: Elek Márton <el...@apache.org>
AuthorDate: Fri Jan 29 11:15:57 2021 +0100

    fixing volume choosing policy initialization
---
 .../replication/DownloadAndImportReplicator.java   | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java
index 21fd50e..3de72d5 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java
@@ -53,8 +53,11 @@ public class DownloadAndImportReplicator implements ContainerReplicator {
   private final ContainerSet containerSet;
 
   private final ContainerDownloader downloader;
+
   private final ConfigurationSource config;
 
+  private VolumeChoosingPolicy volumeChoosingPolicy;
+
   private final Supplier<String> scmId;
 
   private VolumeSet volumeSet;
@@ -71,6 +74,24 @@ public class DownloadAndImportReplicator implements ContainerReplicator {
     this.config = config;
     this.scmId = scmId;
     this.volumeSet = volumeSet;
+    Class<? extends VolumeChoosingPolicy> volumeChoosingPolicyType = null;
+    try {
+      volumeChoosingPolicyType =
+          config.getClass(
+              HDDS_DATANODE_VOLUME_CHOOSING_POLICY,
+              RoundRobinVolumeChoosingPolicy
+                  .class, VolumeChoosingPolicy.class);
+
+      this.volumeChoosingPolicy = volumeChoosingPolicyType.newInstance();
+
+    } catch (InstantiationException ex) {
+      throw new IllegalArgumentException(
+          "Couldn't create volume choosing policy: " + volumeChoosingPolicyType,
+          ex);
+    } catch (IllegalAccessException e) {
+      e.printStackTrace();
+    }
+
   }
 
 
@@ -88,10 +109,6 @@ public class DownloadAndImportReplicator implements ContainerReplicator {
 
     try {
 
-      VolumeChoosingPolicy volumeChoosingPolicy = config.getClass(
-          HDDS_DATANODE_VOLUME_CHOOSING_POLICY, RoundRobinVolumeChoosingPolicy
-              .class, VolumeChoosingPolicy.class).newInstance();
-
       long maxContainerSize = (long) config.getStorageSize(
           ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE,
           ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org