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 ae...@apache.org on 2019/09/13 14:13:18 UTC
[hadoop] branch trunk updated: HDDS-2057. Incorrect Default OM Port
in Ozone FS URI Error Message.
This is an automated email from the ASF dual-hosted git repository.
aengineer 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 95010a4 HDDS-2057. Incorrect Default OM Port in Ozone FS URI Error Message.
95010a4 is described below
commit 95010a41fcea6ecf5dfd46d6e6f6f38c8b3e2a66
Author: sdeka <sd...@hortonworks.com>
AuthorDate: Thu Aug 29 21:23:50 2019 +0530
HDDS-2057. Incorrect Default OM Port in Ozone FS URI Error Message.
Signed-off-by: Anu Engineer <ae...@apache.org>
---
.../hadoop/fs/ozone/BasicOzoneFileSystem.java | 26 +++++++++++++++-------
1 file changed, 18 insertions(+), 8 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 4d7bfd9..06eedba 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
@@ -43,6 +43,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
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.om.exceptions.OMException;
import org.apache.hadoop.security.UserGroupInformation;
@@ -87,11 +88,20 @@ public class BasicOzoneFileSystem extends FileSystem {
private static final Pattern URL_SCHEMA_PATTERN =
Pattern.compile("([^\\.]+)\\.([^\\.]+)\\.{0,1}(.*)");
- private static final String URI_EXCEPTION_TEXT = "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:5678/key";
+ private OzoneConfiguration getOzoneConf(Configuration conf) {
+
+ return (conf instanceof OzoneConfiguration) ?
+ (OzoneConfiguration) conf : new OzoneConfiguration(conf);
+ }
+
+ 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
public void initialize(URI name, Configuration conf) throws IOException {
@@ -106,7 +116,7 @@ public class BasicOzoneFileSystem extends FileSystem {
Matcher matcher = URL_SCHEMA_PATTERN.matcher(authority);
if (!matcher.matches()) {
- throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
+ throw new IllegalArgumentException(getUriExceptionText(conf));
}
String bucketStr = matcher.group(1);
String volumeStr = matcher.group(2);
@@ -118,14 +128,14 @@ public class BasicOzoneFileSystem extends FileSystem {
String[] parts = remaining.split(":");
// Array length should be either 1(host) or 2(host:port)
if (parts.length > 2) {
- throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
+ throw new IllegalArgumentException(getUriExceptionText(conf));
}
omHost = parts[0];
if (parts.length == 2) {
try {
omPort = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
- throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
+ throw new IllegalArgumentException(getUriExceptionText(conf));
}
} else {
// If port number is not specified, read it from config
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org