You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by si...@apache.org on 2020/04/23 18:00:33 UTC

[hadoop-ozone] 02/02: HDDS-3390. Rebase OFS branch - 2. Adapt OFS classes to HDDS-3101 (#822)

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

siyao pushed a commit to branch HDDS-2665-ofs
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git

commit 9ed2e15834c8d19c2dac30c2d06788006e31ec82
Author: Siyao Meng <sm...@cloudera.com>
AuthorDate: Wed Apr 22 23:19:53 2020 -0700

    HDDS-3390. Rebase OFS branch - 2. Adapt OFS classes to HDDS-3101 (#822)
---
 .../fs/ozone/BasicRootedOzoneClientAdapterImpl.java    |  9 ++++++---
 .../hadoop/fs/ozone/BasicRootedOzoneFileSystem.java    | 18 ++++++++++++++----
 .../hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java  |  6 ++++--
 .../apache/hadoop/fs/ozone/RootedOzoneFileSystem.java  | 16 ++++++++--------
 .../fs/ozone/TestRootedOzoneFileSystemWithMocks.java   |  5 ++---
 5 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
index 4409891..bf7b124 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdds.client.ReplicationFactor;
 import org.apache.hadoop.hdds.client.ReplicationType;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.security.x509.SecurityConfig;
@@ -123,7 +124,7 @@ public class BasicRootedOzoneClientAdapterImpl
   }
 
   public BasicRootedOzoneClientAdapterImpl(String omHost, int omPort,
-      Configuration hadoopConf) throws IOException {
+      ConfigurationSource hadoopConf) throws IOException {
 
     ClassLoader contextClassLoader =
         Thread.currentThread().getContextClassLoader();
@@ -706,7 +707,8 @@ public class BasicRootedOzoneClientAdapterImpl
       Token<OzoneTokenIdentifier> ozoneDt =
           (Token<OzoneTokenIdentifier>) token;
       OzoneClient ozoneClient =
-          OzoneClientFactory.getRpcClient(conf);
+          OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
+              ozoneDt);
       return ozoneClient.getObjectStore().renewDelegationToken(ozoneDt);
     }
 
@@ -716,7 +718,8 @@ public class BasicRootedOzoneClientAdapterImpl
       Token<OzoneTokenIdentifier> ozoneDt =
           (Token<OzoneTokenIdentifier>) token;
       OzoneClient ozoneClient =
-          OzoneClientFactory.getRpcClient(conf);
+          OzoneClientFactory.getOzoneClient(OzoneConfiguration.of(conf),
+              ozoneDt);
       ozoneClient.getObjectStore().cancelDelegationToken(ozoneDt);
     }
   }
diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
index ff84175..39aeef1 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
@@ -33,6 +33,9 @@ import org.apache.hadoop.fs.LocatedFileStatus;
 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.ConfigurationSource;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
 import org.apache.hadoop.ozone.client.OzoneBucket;
 import org.apache.hadoop.ozone.om.exceptions.OMException;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -136,9 +139,16 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
       boolean isolatedClassloader =
           conf.getBoolean("ozone.fs.isolated-classloader", defaultValue);
 
-      // adapter should be initialized in operations.
-      this.adapter = createAdapter(
-          conf, omHostOrServiceId, omPort, isolatedClassloader);
+      ConfigurationSource source;
+      if (conf instanceof OzoneConfiguration) {
+        source = (ConfigurationSource) conf;
+      } else {
+        source = new LegacyHadoopConfigurationSource(conf);
+      }
+      this.adapter =
+          createAdapter(source,
+              omHostOrServiceId, omPort,
+              isolatedClassloader);
 
       try {
         this.userName =
@@ -155,7 +165,7 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
     }
   }
 
-  protected OzoneClientAdapter createAdapter(Configuration conf,
+  protected OzoneClientAdapter createAdapter(ConfigurationSource conf,
       String omHost, int omPort, boolean isolatedClassloader)
       throws IOException {
 
diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java
index e8ac316..e5cfb14 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java
@@ -18,7 +18,8 @@
 package org.apache.hadoop.fs.ozone;
 
 import java.io.IOException;
-import org.apache.hadoop.conf.Configuration;
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 
 /**
@@ -44,7 +45,8 @@ public class RootedOzoneClientAdapterImpl
   }
 
   public RootedOzoneClientAdapterImpl(String omHost, int omPort,
-      Configuration hadoopConf, OzoneFSStorageStatistics storageStatistics)
+      ConfigurationSource hadoopConf,
+      OzoneFSStorageStatistics storageStatistics)
       throws IOException {
     super(omHost, omPort, hadoopConf);
     this.storageStatistics = storageStatistics;
diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java
index a8bd099..474e6b5 100644
--- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java
@@ -18,9 +18,9 @@
 
 package org.apache.hadoop.fs.ozone;
 
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience;
+import org.apache.hadoop.hdds.annotation.InterfaceStability;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.crypto.key.KeyProvider;
 import org.apache.hadoop.crypto.key.KeyProviderTokenIssuer;
 import org.apache.hadoop.fs.FileSystem;
@@ -32,12 +32,12 @@ import java.io.IOException;
 import java.net.URI;
 
 /**
- * The Ozone Filesystem implementation.
+ * The Rooted Ozone Filesystem implementation.
  * <p>
  * This subclass is marked as private as code should not be creating it
- * directly; use {@link FileSystem#get(Configuration)} and variants to create
- * one. If cast to {@link RootedOzoneFileSystem}, extra methods and features
- * may be accessed. Consider those private and unstable.
+ * directly; use {@link FileSystem#get(org.apache.hadoop.conf.Configuration)}
+ * and variants to create one. If cast to {@link OzoneFileSystem}, extra
+ * methods and features may be accessed. Consider those private and unstable.
  */
 @InterfaceAudience.Private
 @InterfaceStability.Evolving
@@ -84,7 +84,7 @@ public class RootedOzoneFileSystem extends BasicRootedOzoneFileSystem
   }
 
   @Override
-  protected OzoneClientAdapter createAdapter(Configuration conf,
+  protected OzoneClientAdapter createAdapter(ConfigurationSource conf,
       String omHost, int omPort, boolean isolatedClassloader)
       throws IOException {
 
diff --git a/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithMocks.java b/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithMocks.java
index e278d0c..5ea20a3 100644
--- a/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithMocks.java
+++ b/hadoop-ozone/ozonefs/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystemWithMocks.java
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.fs.ozone;
 
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.ozone.OmUtils;
@@ -49,7 +48,7 @@ public class TestRootedOzoneFileSystemWithMocks {
 
   @Test
   public void testFSUriWithHostPortOverrides() throws Exception {
-    Configuration conf = new OzoneConfiguration();
+    OzoneConfiguration conf = new OzoneConfiguration();
     OzoneClient ozoneClient = mock(OzoneClient.class);
     ObjectStore objectStore = mock(ObjectStore.class);
 
@@ -80,7 +79,7 @@ public class TestRootedOzoneFileSystemWithMocks {
 
   @Test
   public void testFSUriWithHostPortUnspecified() throws Exception {
-    Configuration conf = new OzoneConfiguration();
+    OzoneConfiguration conf = new OzoneConfiguration();
     final int omPort = OmUtils.getOmRpcPort(conf);
 
     OzoneClient ozoneClient = mock(OzoneClient.class);


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