hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bha...@apache.org
Subject [26/37] hadoop git commit: HDDS-229:Remove singleton for Handler. Contributed by Bharat Viswanadham
Date Mon, 09 Jul 2018 20:33:35 GMT
HDDS-229:Remove singleton for Handler. Contributed by Bharat Viswanadham


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a4041649
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a4041649
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a4041649

Branch: refs/heads/trunk
Commit: a404164939c898aaf1ced90747b1011ed722e99a
Parents: e1f4b3b
Author: Bharat Viswanadham <bharat@apache.org>
Authored: Thu Jul 5 11:26:00 2018 -0700
Committer: Bharat Viswanadham <bharat@apache.org>
Committed: Thu Jul 5 11:26:00 2018 -0700

----------------------------------------------------------------------
 .../container/common/interfaces/Handler.java    |  2 +-
 .../container/keyvalue/KeyValueHandler.java     | 22 ++++----------------
 2 files changed, 5 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a4041649/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java
index 57dd224..2725f59 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java
@@ -57,7 +57,7 @@ public class Handler {
                                                    ContainerMetrics metrics) {
     switch (containerType) {
     case KeyValueContainer:
-      return KeyValueHandler.getInstance(config, contSet, volumeSet, metrics);
+      return new KeyValueHandler(config, contSet, volumeSet, metrics);
     default:
       throw new IllegalArgumentException("Handler for ContainerType: " +
         containerType + "doesn't exist.");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a4041649/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
index b615acd..8166a83 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.ozone.container.keyvalue;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.protobuf.ByteString;
-import com.sun.jersey.spi.resource.Singleton;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdds.client.BlockID;
 import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
@@ -93,33 +92,19 @@ import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
 /**
  * Handler for KeyValue Container type.
  */
-@Singleton
 public class KeyValueHandler extends Handler {
 
   private static final Logger LOG = LoggerFactory.getLogger(
       KeyValueHandler.class);
 
-  private static volatile KeyValueHandler INSTANCE = null; // Singleton class
-
   private final ContainerType containerType;
   private final KeyManager keyManager;
   private final ChunkManager chunkManager;
   private VolumeChoosingPolicy volumeChoosingPolicy;
   private final int maxContainerSizeGB;
 
-  // TODO : Add metrics and populate it.
-
-  public static KeyValueHandler getInstance(Configuration config,
-                                            ContainerSet contSet,
-                                            VolumeSet volSet,
-                                            ContainerMetrics metrics) {
-    if (INSTANCE == null) {
-      INSTANCE = new KeyValueHandler(config, contSet, volSet, metrics);
-    }
-    return INSTANCE;
-  }
 
-  private KeyValueHandler(Configuration config, ContainerSet contSet,
+  public KeyValueHandler(Configuration config, ContainerSet contSet,
       VolumeSet volSet, ContainerMetrics metrics) {
     super(config, contSet, volSet, metrics);
     containerType = ContainerType.KeyValueContainer;
@@ -127,8 +112,9 @@ public class KeyValueHandler extends Handler {
     chunkManager = new ChunkManagerImpl();
     // TODO: Add supoort for different volumeChoosingPolicies.
     volumeChoosingPolicy = new RoundRobinVolumeChoosingPolicy();
-    maxContainerSizeGB = config.getInt(ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_GB,
-        ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT);
+    maxContainerSizeGB = config.getInt(ScmConfigKeys
+            .OZONE_SCM_CONTAINER_SIZE_GB, ScmConfigKeys
+        .OZONE_SCM_CONTAINER_SIZE_DEFAULT);
   }
 
   @Override


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


Mime
View raw message