hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject hadoop git commit: HDDS-206. Ozone shell command doesn't respect KSM port set in ozone-site.xml. Contributed by Shashikant Banerjee.
Date Mon, 02 Jul 2018 19:21:28 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 1804a3151 -> ab2f8343a


HDDS-206. Ozone shell command doesn't respect KSM port set in ozone-site.xml. Contributed
by Shashikant Banerjee.


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

Branch: refs/heads/trunk
Commit: ab2f8343a9810c9ec8b0920215a0897e7f671aba
Parents: 1804a31
Author: Nanda kumar <nanda@apache.org>
Authored: Tue Jul 3 00:51:16 2018 +0530
Committer: Nanda kumar <nanda@apache.org>
Committed: Tue Jul 3 00:51:16 2018 +0530

----------------------------------------------------------------------
 .../hadoop/ozone/client/OzoneClientFactory.java | 13 ++++++-----
 .../java/org/apache/hadoop/ozone/KsmUtils.java  | 24 +++++++++++++-------
 2 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab2f8343/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
index dae94aa..3085b0d 100644
--- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
+++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.ozone.client;
 import com.google.common.base.Preconditions;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.KsmUtils;
 import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
 import org.apache.hadoop.ozone.client.rest.RestClient;
 import org.apache.hadoop.ozone.client.rpc.RpcClient;
@@ -37,10 +38,7 @@ import static org.apache.hadoop.ozone.OzoneConfigKeys
     .OZONE_CLIENT_PROTOCOL;
 import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
     .OZONE_KSM_HTTP_ADDRESS_KEY;
-import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
-    .OZONE_KSM_HTTP_BIND_PORT_DEFAULT;
 import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_ADDRESS_KEY;
-import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_PORT_DEFAULT;
 
 /**
  * Factory class to create different types of OzoneClients.
@@ -108,8 +106,9 @@ public final class OzoneClientFactory {
    */
   public static OzoneClient getRpcClient(String ksmHost)
       throws IOException {
-    return getRpcClient(ksmHost, OZONE_KSM_PORT_DEFAULT,
-        new OzoneConfiguration());
+    Configuration config = new OzoneConfiguration();
+    int port = KsmUtils.getKsmRpcPort(config);
+    return getRpcClient(ksmHost, port, config);
   }
 
   /**
@@ -185,7 +184,9 @@ public final class OzoneClientFactory {
    */
   public static OzoneClient getRestClient(String ksmHost)
       throws IOException {
-    return getRestClient(ksmHost, OZONE_KSM_HTTP_BIND_PORT_DEFAULT);
+    Configuration config = new OzoneConfiguration();
+    int port = KsmUtils.getKsmRestPort(config);
+    return getRestClient(ksmHost, port, config);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab2f8343/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/KsmUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/KsmUtils.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/KsmUtils.java
index ebada1c..1025963 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/KsmUtils.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/KsmUtils.java
@@ -26,6 +26,8 @@ import com.google.common.base.Optional;
 import static org.apache.hadoop.hdds.HddsUtils.getHostNameFromConfigKeys;
 import static org.apache.hadoop.hdds.HddsUtils.getPortNumberFromConfigKeys;
 import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_ADDRESS_KEY;
+import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_HTTP_ADDRESS_KEY;
+import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_HTTP_BIND_PORT_DEFAULT;
 import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
     .OZONE_KSM_BIND_HOST_DEFAULT;
 import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_PORT_DEFAULT;
@@ -49,13 +51,9 @@ public final class KsmUtils {
     final Optional<String> host = getHostNameFromConfigKeys(conf,
         OZONE_KSM_ADDRESS_KEY);
 
-    // If no port number is specified then we'll just try the defaultBindPort.
-    final Optional<Integer> port = getPortNumberFromConfigKeys(conf,
-        OZONE_KSM_ADDRESS_KEY);
-
     return NetUtils.createSocketAddr(
         host.or(OZONE_KSM_BIND_HOST_DEFAULT) + ":" +
-            port.or(OZONE_KSM_PORT_DEFAULT));
+            getKsmRpcPort(conf));
   }
 
   /**
@@ -76,12 +74,22 @@ public final class KsmUtils {
               " details on configuring Ozone.");
     }
 
+    return NetUtils.createSocketAddr(
+        host.get() + ":" + getKsmRpcPort(conf));
+  }
+
+  public static int getKsmRpcPort(Configuration conf) {
     // If no port number is specified then we'll just try the defaultBindPort.
     final Optional<Integer> port = getPortNumberFromConfigKeys(conf,
         OZONE_KSM_ADDRESS_KEY);
-
-    return NetUtils.createSocketAddr(
-        host.get() + ":" + port.or(OZONE_KSM_PORT_DEFAULT));
+    return port.or(OZONE_KSM_PORT_DEFAULT);
   }
 
+  public static int getKsmRestPort(Configuration conf) {
+    // If no port number is specified then we'll just try the default
+    // HTTP BindPort.
+    final Optional<Integer> port =
+        getPortNumberFromConfigKeys(conf, OZONE_KSM_HTTP_ADDRESS_KEY);
+    return port.or(OZONE_KSM_HTTP_BIND_PORT_DEFAULT);
+  }
 }


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