You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by bh...@apache.org on 2019/08/18 04:54:54 UTC

[hadoop] branch trunk updated: HDDS-1938. Change omPort parameter type from String to int in BasicOzoneFileSystem#createAdapter (#1305)

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

bharat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3bba808  HDDS-1938. Change omPort parameter type from String to int in BasicOzoneFileSystem#createAdapter (#1305)
3bba808 is described below

commit 3bba8086e0e960cb5eea230ed3f8753a86e6d4f2
Author: Siyao Meng <50...@users.noreply.github.com>
AuthorDate: Sat Aug 17 21:54:48 2019 -0700

    HDDS-1938. Change omPort parameter type from String to int in BasicOzoneFileSystem#createAdapter (#1305)
---
 .../apache/hadoop/fs/ozone/BasicOzoneFileSystem.java   | 18 +++++++++---------
 .../org/apache/hadoop/fs/ozone/OzoneFileSystem.java    |  5 ++---
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
index 27bc925..4d7bfd9 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
@@ -113,7 +113,7 @@ public class BasicOzoneFileSystem extends FileSystem {
     String remaining = matcher.groupCount() == 3 ? matcher.group(3) : null;
 
     String omHost = null;
-    String omPort = String.valueOf(-1);
+    int omPort = -1;
     if (!isEmpty(remaining)) {
       String[] parts = remaining.split(":");
       // Array length should be either 1(host) or 2(host:port)
@@ -122,13 +122,14 @@ public class BasicOzoneFileSystem extends FileSystem {
       }
       omHost = parts[0];
       if (parts.length == 2) {
-        omPort = parts[1];
+        try {
+          omPort = Integer.parseInt(parts[1]);
+        } catch (NumberFormatException e) {
+          throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
+        }
       } else {
         // If port number is not specified, read it from config
-        omPort = String.valueOf(OmUtils.getOmRpcPort(conf));
-      }
-      if (!isNumber(omPort)) {
-        throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
+        omPort = OmUtils.getOmRpcPort(conf);
       }
     }
 
@@ -170,7 +171,7 @@ public class BasicOzoneFileSystem extends FileSystem {
 
   protected OzoneClientAdapter createAdapter(Configuration conf,
       String bucketStr,
-      String volumeStr, String omHost, String omPort,
+      String volumeStr, String omHost, int omPort,
       boolean isolatedClassloader) throws IOException {
 
     if (isolatedClassloader) {
@@ -180,8 +181,7 @@ public class BasicOzoneFileSystem extends FileSystem {
 
     } else {
 
-      return new BasicOzoneClientAdapterImpl(omHost,
-          Integer.parseInt(omPort), conf,
+      return new BasicOzoneClientAdapterImpl(omHost, omPort, conf,
           volumeStr, bucketStr);
     }
   }
diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
index 983c5a9..33dee87 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
@@ -86,7 +86,7 @@ public class OzoneFileSystem extends BasicOzoneFileSystem
   @Override
   protected OzoneClientAdapter createAdapter(Configuration conf,
       String bucketStr,
-      String volumeStr, String omHost, String omPort,
+      String volumeStr, String omHost, int omPort,
       boolean isolatedClassloader) throws IOException {
 
     this.storageStatistics =
@@ -99,8 +99,7 @@ public class OzoneFileSystem extends BasicOzoneFileSystem
           storageStatistics);
 
     } else {
-      return new OzoneClientAdapterImpl(omHost,
-          Integer.parseInt(omPort), conf,
+      return new OzoneClientAdapterImpl(omHost, omPort, conf,
           volumeStr, bucketStr, storageStatistics);
     }
   }


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