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 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);
}
}

View File

@ -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);
}
}