Revert "HDDS-2057. Incorrect Default OM Port in Ozone FS URI Error Message."

This reverts commit 95010a41fc.
This commit is contained in:
Arpit Agarwal 2019-09-13 11:40:42 -07:00
parent e22a324f87
commit 6a9f7caef4
No known key found for this signature in database
GPG Key ID: E4B09E903FDF9E98

View File

@ -43,7 +43,6 @@
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException; import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.OmUtils; import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.om.exceptions.OMException; import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
@ -88,20 +87,11 @@ public class BasicOzoneFileSystem extends FileSystem {
private static final Pattern URL_SCHEMA_PATTERN = private static final Pattern URL_SCHEMA_PATTERN =
Pattern.compile("([^\\.]+)\\.([^\\.]+)\\.{0,1}(.*)"); Pattern.compile("([^\\.]+)\\.([^\\.]+)\\.{0,1}(.*)");
private OzoneConfiguration getOzoneConf(Configuration conf) { private static final String URI_EXCEPTION_TEXT = "Ozone file system URL " +
"should be one of the following formats: " +
return (conf instanceof OzoneConfiguration) ? "o3fs://bucket.volume/key OR " +
(OzoneConfiguration) conf : new OzoneConfiguration(conf); "o3fs://bucket.volume.om-host.example.com/key OR " +
} "o3fs://bucket.volume.om-host.example.com:5678/key";
private String getUriExceptionText(Configuration conf) {
return "Ozone file system URL should be one of the following formats: "
+ "o3fs://bucket.volume/key OR "
+ "o3fs://bucket.volume.om-host.example.com/key OR "
+ "o3fs://bucket.volume.om-host.example.com:"
+ OmUtils.getOmRpcPort(getOzoneConf(conf)) + "/key";
}
@Override @Override
public void initialize(URI name, Configuration conf) throws IOException { public void initialize(URI name, Configuration conf) throws IOException {
@ -121,7 +111,7 @@ public void initialize(URI name, Configuration conf) throws IOException {
Matcher matcher = URL_SCHEMA_PATTERN.matcher(authority); Matcher matcher = URL_SCHEMA_PATTERN.matcher(authority);
if (!matcher.matches()) { if (!matcher.matches()) {
throw new IllegalArgumentException(getUriExceptionText(conf)); throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
} }
String bucketStr = matcher.group(1); String bucketStr = matcher.group(1);
String volumeStr = matcher.group(2); String volumeStr = matcher.group(2);
@ -133,14 +123,14 @@ public void initialize(URI name, Configuration conf) throws IOException {
String[] parts = remaining.split(":"); String[] parts = remaining.split(":");
// Array length should be either 1(hostname or service id) or 2(host:port) // Array length should be either 1(hostname or service id) or 2(host:port)
if (parts.length > 2) { if (parts.length > 2) {
throw new IllegalArgumentException(getUriExceptionText(conf)); throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
} }
omHost = parts[0]; omHost = parts[0];
if (parts.length == 2) { if (parts.length == 2) {
try { try {
omPort = Integer.parseInt(parts[1]); omPort = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new IllegalArgumentException(getUriExceptionText(conf)); throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
} }
} }
} }