HDDS-1938. Change omPort parameter type from String to int in BasicOzoneFileSystem#createAdapter (#1305)

This commit is contained in:
Siyao Meng 2019-08-17 21:54:48 -07:00 committed by Bharat Viswanadham
parent e61825682a
commit 3bba8086e0
2 changed files with 11 additions and 12 deletions

View File

@ -113,7 +113,7 @@ public class BasicOzoneFileSystem extends FileSystem {
String remaining = matcher.groupCount() == 3 ? matcher.group(3) : null; String remaining = matcher.groupCount() == 3 ? matcher.group(3) : null;
String omHost = null; String omHost = null;
String omPort = String.valueOf(-1); int omPort = -1;
if (!isEmpty(remaining)) { if (!isEmpty(remaining)) {
String[] parts = remaining.split(":"); String[] parts = remaining.split(":");
// Array length should be either 1(host) or 2(host:port) // Array length should be either 1(host) or 2(host:port)
@ -122,13 +122,14 @@ public class BasicOzoneFileSystem extends FileSystem {
} }
omHost = parts[0]; omHost = parts[0];
if (parts.length == 2) { if (parts.length == 2) {
omPort = parts[1]; try {
omPort = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
}
} else { } else {
// If port number is not specified, read it from config // If port number is not specified, read it from config
omPort = String.valueOf(OmUtils.getOmRpcPort(conf)); omPort = OmUtils.getOmRpcPort(conf);
}
if (!isNumber(omPort)) {
throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
} }
} }
@ -170,7 +171,7 @@ public class BasicOzoneFileSystem extends FileSystem {
protected OzoneClientAdapter createAdapter(Configuration conf, protected OzoneClientAdapter createAdapter(Configuration conf,
String bucketStr, String bucketStr,
String volumeStr, String omHost, String omPort, String volumeStr, String omHost, int omPort,
boolean isolatedClassloader) throws IOException { boolean isolatedClassloader) throws IOException {
if (isolatedClassloader) { if (isolatedClassloader) {
@ -180,8 +181,7 @@ public class BasicOzoneFileSystem extends FileSystem {
} else { } else {
return new BasicOzoneClientAdapterImpl(omHost, return new BasicOzoneClientAdapterImpl(omHost, omPort, conf,
Integer.parseInt(omPort), conf,
volumeStr, bucketStr); volumeStr, bucketStr);
} }
} }

View File

@ -86,7 +86,7 @@ public class OzoneFileSystem extends BasicOzoneFileSystem
@Override @Override
protected OzoneClientAdapter createAdapter(Configuration conf, protected OzoneClientAdapter createAdapter(Configuration conf,
String bucketStr, String bucketStr,
String volumeStr, String omHost, String omPort, String volumeStr, String omHost, int omPort,
boolean isolatedClassloader) throws IOException { boolean isolatedClassloader) throws IOException {
this.storageStatistics = this.storageStatistics =
@ -99,8 +99,7 @@ public class OzoneFileSystem extends BasicOzoneFileSystem
storageStatistics); storageStatistics);
} else { } else {
return new OzoneClientAdapterImpl(omHost, return new OzoneClientAdapterImpl(omHost, omPort, conf,
Integer.parseInt(omPort), conf,
volumeStr, bucketStr, storageStatistics); volumeStr, bucketStr, storageStatistics);
} }
} }