diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java index b8fbe19fee3c..1ed21e6217ff 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/ObjectStore.java @@ -81,7 +81,9 @@ protected ObjectStore() { proxy = null; } - @VisibleForTesting + /** + * Returns the ClientProtocol of the ObjectStore. + */ public ClientProtocol getClientProxy() { return proxy; } diff --git a/hadoop-ozone/dist/src/main/compose/ozone-csi/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-csi/docker-config index adc6646c7302..7671408d4930 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-csi/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-csi/docker-config @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +CORE-SITE.XML_fs.defaultFS=ofs://om + OZONE-SITE.XML_ozone.csi.owner=hadoop OZONE-SITE.XML_ozone.csi.socket=/tmp/csi.sock diff --git a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop27/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop27/docker-config index 8ad0d39323a0..8e06d4f8ceff 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop27/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop27/docker-config @@ -15,6 +15,7 @@ # limitations under the License. CORE-SITE.xml_fs.AbstractFileSystem.o3fs.impl=org.apache.hadoop.fs.ozone.OzFs +CORE-SITE.xml_fs.AbstractFileSystem.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzFs MAPRED-SITE.XML_mapreduce.application.classpath=/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/ozone/share/ozone/lib/hadoop-ozone-filesystem-hadoop2-@project.version@.jar no_proxy=om,scm,s3g,kdc,localhost,127.0.0.1 diff --git a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop31/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop31/docker-config index ff8f29c53799..83c25b9d403e 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop31/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop31/docker-config @@ -15,6 +15,7 @@ # limitations under the License. CORE-SITE.xml_fs.AbstractFileSystem.o3fs.impl=org.apache.hadoop.fs.ozone.OzFs +CORE-SITE.xml_fs.AbstractFileSystem.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzFs MAPRED-SITE.XML_mapreduce.application.classpath=/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/ozone/share/ozone/lib/hadoop-ozone-filesystem-hadoop3-@project.version@.jar no_proxy=om,scm,s3g,kdc,localhost,127.0.0.1 \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop32/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop32/docker-config index ff8f29c53799..83c25b9d403e 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop32/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-mr/hadoop32/docker-config @@ -15,6 +15,7 @@ # limitations under the License. CORE-SITE.xml_fs.AbstractFileSystem.o3fs.impl=org.apache.hadoop.fs.ozone.OzFs +CORE-SITE.xml_fs.AbstractFileSystem.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzFs MAPRED-SITE.XML_mapreduce.application.classpath=/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/ozone/share/ozone/lib/hadoop-ozone-filesystem-hadoop3-@project.version@.jar no_proxy=om,scm,s3g,kdc,localhost,127.0.0.1 \ No newline at end of file diff --git a/hadoop-ozone/dist/src/main/compose/ozone-om-ha-s3/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-om-ha-s3/docker-config index 69138d145deb..19c137b9f899 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-om-ha-s3/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-om-ha-s3/docker-config @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -CORE-SITE.XML_fs.o3fs.impl=org.apache.hadoop.fs.ozone.OzoneFileSystem -CORE-SITE.XML_fs.defaultFS=o3fs://bucket.volume.id1 +CORE-SITE.XML_fs.defaultFS=ofs://id1 + OZONE-SITE.XML_ozone.om.service.ids=id1 OZONE-SITE.XML_ozone.om.nodes.id1=om1,om2,om3 OZONE-SITE.XML_ozone.om.address.id1.om1=om1 diff --git a/hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config index d5892102d574..47a15df511aa 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -CORE-SITE.XML_fs.o3fs.impl=org.apache.hadoop.fs.ozone.OzoneFileSystem -CORE-SITE.XML_fs.defaultFS=o3fs://bucket1.volume1.omservice +CORE-SITE.XML_fs.defaultFS=ofs://omservice + OZONE-SITE.XML_ozone.om.service.ids=omservice OZONE-SITE.XML_ozone.om.nodes.omservice=om1,om2,om3 OZONE-SITE.XML_ozone.om.address.omservice.om1=om1 diff --git a/hadoop-ozone/dist/src/main/compose/ozone-topology/docker-config b/hadoop-ozone/dist/src/main/compose/ozone-topology/docker-config index 6080703975d6..86a633ee88c2 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-topology/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone-topology/docker-config @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +CORE-SITE.XML_fs.defaultFS=ofs://om + OZONE-SITE.XML_ozone.om.address=om OZONE-SITE.XML_ozone.om.http-address=om:9874 OZONE-SITE.XML_ozone.scm.container.size=256MB diff --git a/hadoop-ozone/dist/src/main/compose/ozone/docker-config b/hadoop-ozone/dist/src/main/compose/ozone/docker-config index ecc994b4ac26..813f2c2bcbc3 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozone/docker-config @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -CORE-SITE.XML_fs.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzoneFileSystem -CORE-SITE.XML_fs.o3fs.impl=org.apache.hadoop.fs.ozone.OzoneFileSystem +CORE-SITE.XML_fs.defaultFS=ofs://om + OZONE-SITE.XML_ozone.om.address=om OZONE-SITE.XML_ozone.om.http-address=om:9874 OZONE-SITE.XML_ozone.scm.container.size=1GB diff --git a/hadoop-ozone/dist/src/main/compose/ozoneblockade/docker-config b/hadoop-ozone/dist/src/main/compose/ozoneblockade/docker-config index 321444c952bc..205586813ff0 100644 --- a/hadoop-ozone/dist/src/main/compose/ozoneblockade/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozoneblockade/docker-config @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +CORE-SITE.XML_fs.defaultFS=ofs://om + OZONE-SITE.XML_ozone.om.address=om OZONE-SITE.XML_ozone.om.http-address=om:9874 OZONE-SITE.XML_ozone.scm.names=scm diff --git a/hadoop-ozone/dist/src/main/compose/ozones3-haproxy/docker-config b/hadoop-ozone/dist/src/main/compose/ozones3-haproxy/docker-config index f5d8e96f0102..b97abfb17d44 100644 --- a/hadoop-ozone/dist/src/main/compose/ozones3-haproxy/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozones3-haproxy/docker-config @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +CORE-SITE.XML_fs.defaultFS=ofs://om + OZONE-SITE.XML_ozone.om.address=om OZONE-SITE.XML_ozone.scm.container.size=1GB OZONE-SITE.XML_ozone.scm.pipeline.owner.container.count=1 diff --git a/hadoop-ozone/dist/src/main/compose/ozonesecure-mr/docker-config b/hadoop-ozone/dist/src/main/compose/ozonesecure-mr/docker-config index cee2a480c50b..cf25ba2a6c5c 100644 --- a/hadoop-ozone/dist/src/main/compose/ozonesecure-mr/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozonesecure-mr/docker-config @@ -67,7 +67,8 @@ HDFS-SITE.XML_rpc.metrics.quantile.enable=true HDFS-SITE.XML_rpc.metrics.percentiles.intervals=60,300 CORE-SITE.XML_fs.AbstractFileSystem.o3fs.impl=org.apache.hadoop.fs.ozone.OzFs -CORE-SITE.XML_fs.defaultFS=o3fs://bucket1.volume1/ +CORE-SITE.XML_fs.AbstractFileSystem.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzFs +CORE-SITE.XML_fs.defaultFS=ofs://om MAPRED-SITE.XML_mapreduce.framework.name=yarn MAPRED-SITE.XML_yarn.app.mapreduce.am.env=HADOOP_MAPRED_HOME=$HADOOP_HOME diff --git a/hadoop-ozone/dist/src/main/compose/ozonesecure-om-ha/docker-config b/hadoop-ozone/dist/src/main/compose/ozonesecure-om-ha/docker-config index e245b7e01998..00820d3d72cd 100644 --- a/hadoop-ozone/dist/src/main/compose/ozonesecure-om-ha/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozonesecure-om-ha/docker-config @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -CORE-SITE.XML_fs.o3fs.impl=org.apache.hadoop.fs.ozone.OzoneFileSystem -CORE-SITE.XML_fs.defaultFS=o3fs://bucket.volume.id1 +CORE-SITE.XML_fs.defaultFS=ofs://id1 + OZONE-SITE.XML_ozone.om.service.ids=id1 OZONE-SITE.XML_ozone.om.internal.service.id=id1 OZONE-SITE.XML_ozone.om.nodes.id1=om1,om2,om3 diff --git a/hadoop-ozone/dist/src/main/compose/ozonesecure/docker-config b/hadoop-ozone/dist/src/main/compose/ozonesecure/docker-config index abb30453e9c7..3ac565d276b3 100644 --- a/hadoop-ozone/dist/src/main/compose/ozonesecure/docker-config +++ b/hadoop-ozone/dist/src/main/compose/ozonesecure/docker-config @@ -14,12 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -CORE-SITE.XML_fs.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzoneFileSystem -CORE-SITE.XML_fs.o3fs.impl=org.apache.hadoop.fs.ozone.OzoneFileSystem -OZONE-SITE.XML_ozone.om.volume.listall.allowed=false +CORE-SITE.XML_fs.defaultFS=ofs://om OZONE-SITE.XML_ozone.om.address=om OZONE-SITE.XML_ozone.om.http-address=om:9874 +OZONE-SITE.XML_ozone.om.volume.listall.allowed=false OZONE-SITE.XML_ozone.scm.container.size=1GB OZONE-SITE.XML_ozone.scm.pipeline.owner.container.count=1 OZONE-SITE.XML_ozone.scm.names=scm @@ -89,7 +88,6 @@ CORE-SITE.XML_hadoop.http.authentication.type=kerberos CORE-SITE.XML_hadoop.http.authentication.kerberos.principal=HTTP/_HOST@EXAMPLE.COM CORE-SITE.XML_hadoop.http.authentication.kerberos.keytab=/etc/security/keytabs/HTTP.keytab - CORE-SITE.XML_hadoop.security.authorization=true HADOOP-POLICY.XML_ozone.om.security.client.protocol.acl=* HADOOP-POLICY.XML_hdds.security.client.datanode.container.protocol.acl=* diff --git a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java index e84a542e34fd..988df6726387 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java @@ -82,7 +82,7 @@ public class TestRootedOzoneFileSystem { private FileSystem fs; private RootedOzoneFileSystem ofs; private ObjectStore objectStore; - private static BasicRootedOzoneClientAdapterImpl adapter; + private static BasicRootedOzoneFileSystemImpl impl; private String volumeName; private String bucketName; @@ -112,12 +112,10 @@ public void init() throws Exception { // Set the fs.defaultFS and start the filesystem conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath); - // Note: FileSystem#loadFileSystems won't load OFS class due to META-INF - // hence this workaround. - conf.set("fs.ofs.impl", "org.apache.hadoop.fs.ozone.RootedOzoneFileSystem"); + // fs.ofs.impl should be loaded from META-INF, no need to explicitly set it fs = FileSystem.get(conf); ofs = (RootedOzoneFileSystem) fs; - adapter = (BasicRootedOzoneClientAdapterImpl) ofs.getAdapter(); + impl = ofs.getImpl(); } @After @@ -131,10 +129,7 @@ public void teardown() { @Test public void testOzoneFsServiceLoader() throws IOException { OzoneConfiguration confTestLoader = new OzoneConfiguration(); - // Note: FileSystem#loadFileSystems won't load OFS class due to META-INF - // hence this workaround. - confTestLoader.set("fs.ofs.impl", - "org.apache.hadoop.fs.ozone.RootedOzoneFileSystem"); + // fs.ofs.impl should be loaded from META-INF, no need to explicitly set it Assert.assertEquals(FileSystem.getFileSystemClass( OzoneConsts.OZONE_OFS_URI_SCHEME, confTestLoader), RootedOzoneFileSystem.class); @@ -586,7 +581,7 @@ private void listStatusRecursiveHelper(Path curPath, List result) */ private List callAdapterListStatus(String pathStr, boolean recursive, String startPath, long numEntries) throws IOException { - return adapter.listStatus(pathStr, recursive, startPath, numEntries, + return impl.listStatus(pathStr, recursive, startPath, numEntries, ofs.getUri(), ofs.getWorkingDirectory(), ofs.getUsername()) .stream().map(ofs::convertFileStatus).collect(Collectors.toList()); } diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/rooted/RootedOzoneContract.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/rooted/RootedOzoneContract.java index c2833f5335c0..bf6eb580a727 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/rooted/RootedOzoneContract.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/rooted/RootedOzoneContract.java @@ -104,12 +104,7 @@ public FileSystem getTestFileSystem() throws IOException { OzoneConsts.OZONE_OFS_URI_SCHEME, cluster.getOzoneManager().getRpcPort()); getConf().set("fs.defaultFS", uri); - - // Note: FileSystem#loadFileSystems doesn't load OFS class because - // META-INF points to org.apache.hadoop.fs.ozone.OzoneFileSystem - getConf().set("fs.ofs.impl", - "org.apache.hadoop.fs.ozone.RootedOzoneFileSystem"); - + // fs.ofs.impl should be loaded from META-INF, no need to explicitly set it copyClusterConfigs(OMConfigKeys.OZONE_OM_ADDRESS_KEY); copyClusterConfigs(ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY); return FileSystem.get(getConf()); diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java index e340d40b6f55..82ea2a2441e1 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java @@ -460,8 +460,7 @@ private OzoneConfiguration getClientConfForOFS( String hostPrefix, OzoneConfiguration configuration) { OzoneConfiguration clientConf = new OzoneConfiguration(configuration); - clientConf.set("fs.ofs.impl", - "org.apache.hadoop.fs.ozone.RootedOzoneFileSystem"); + // fs.ofs.impl should be loaded from META-INF, no need to explicitly set it clientConf.set(FS_DEFAULT_NAME_KEY, hostPrefix); clientConf.setInt(FS_TRASH_INTERVAL_KEY, 60); return clientConf; diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java index a2f4c174b964..d029b43bf8fb 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java @@ -228,11 +228,6 @@ public void renameKey(String key, String newKeyName) throws IOException { bucket.renameKey(key, newKeyName); } - @Override - public void rename(String pathStr, String newPath) throws IOException { - throw new IOException("Please use renameKey instead for o3fs."); - } - /** * Helper method to create an directory specified by key name in bucket. * diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java index b7a914d8b98a..a4e3ad34bdbf 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java @@ -85,8 +85,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem { private URI uri; private String userName; private Path workingDir; - private OzoneClientAdapter adapter; - private BasicRootedOzoneClientAdapterImpl adapterImpl; + // Using impl directly rather than OzoneClientAdapter in OFS. + private BasicRootedOzoneFileSystemImpl impl; private static final String URI_EXCEPTION_TEXT = "URL should be one of the following formats: " + @@ -137,8 +137,8 @@ public void initialize(URI name, Configuration conf) throws IOException { } else { source = new LegacyHadoopConfigurationSource(conf); } - this.adapter = createAdapter(source, omHostOrServiceId, omPort); - this.adapterImpl = (BasicRootedOzoneClientAdapterImpl) this.adapter; + this.impl = new BasicRootedOzoneFileSystemImpl( + omHostOrServiceId, omPort, source); try { this.userName = @@ -155,15 +155,10 @@ public void initialize(URI name, Configuration conf) throws IOException { } } - protected OzoneClientAdapter createAdapter(ConfigurationSource conf, - String omHost, int omPort) throws IOException { - return new BasicRootedOzoneClientAdapterImpl(omHost, omPort, conf); - } - @Override public void close() throws IOException { try { - adapter.close(); + impl.close(); } finally { super.close(); } @@ -186,7 +181,7 @@ public FSDataInputStream open(Path path, int bufferSize) throws IOException { LOG.trace("open() path: {}", path); final String key = pathToKey(path); return new FSDataInputStream( - new OzoneFSInputStream(adapter.readFile(key), statistics)); + new OzoneFSInputStream(impl.readFile(key), statistics)); } protected void incrementCounter(Statistic statistic) { @@ -222,7 +217,7 @@ public FSDataOutputStream createNonRecursive(Path path, private FSDataOutputStream createOutputStream(String key, short replication, boolean overwrite, boolean recursive) throws IOException { - return new FSDataOutputStream(adapter.createFile(key, + return new FSDataOutputStream(impl.createFile(key, replication, overwrite, recursive), statistics); } @@ -237,7 +232,6 @@ private class RenameIterator extends OzoneListingIterator { private final String srcPath; private final String dstPath; private final OzoneBucket bucket; - private final BasicRootedOzoneClientAdapterImpl adapterImpl; RenameIterator(Path srcPath, Path dstPath) throws IOException { @@ -247,15 +241,13 @@ private class RenameIterator extends OzoneListingIterator { LOG.trace("rename from:{} to:{}", this.srcPath, this.dstPath); // Initialize bucket here to reduce number of RPC calls OFSPath ofsPath = new OFSPath(srcPath); - // TODO: Refactor later. - adapterImpl = (BasicRootedOzoneClientAdapterImpl) adapter; - this.bucket = adapterImpl.getBucket(ofsPath, false); + this.bucket = impl.getBucket(ofsPath, false); } @Override boolean processKeyPath(String keyPath) throws IOException { String newPath = dstPath.concat(keyPath.substring(srcPath.length())); - adapterImpl.rename(this.bucket, keyPath, newPath); + impl.rename(this.bucket, keyPath, newPath); return true; } } @@ -374,7 +366,6 @@ public boolean rename(Path src, Path dst) throws IOException { private class DeleteIterator extends OzoneListingIterator { final private boolean recursive; private final OzoneBucket bucket; - private final BasicRootedOzoneClientAdapterImpl adapterImpl; DeleteIterator(Path f, boolean recursive) throws IOException { @@ -387,9 +378,7 @@ && listStatus(f).length != 0) { } // Initialize bucket here to reduce number of RPC calls OFSPath ofsPath = new OFSPath(f); - // TODO: Refactor later. - adapterImpl = (BasicRootedOzoneClientAdapterImpl) adapter; - this.bucket = adapterImpl.getBucket(ofsPath, false); + this.bucket = impl.getBucket(ofsPath, false); } @Override @@ -399,7 +388,7 @@ boolean processKeyPath(String keyPath) { return true; } else { LOG.trace("Deleting: {}", keyPath); - boolean succeed = adapterImpl.deleteObject(this.bucket, keyPath); + boolean succeed = impl.deleteObject(this.bucket, keyPath); // if recursive delete is requested ignore the return value of // deleteObject and issue deletes for other keys. return recursive || succeed; @@ -466,8 +455,7 @@ public boolean delete(Path f, boolean recursive) throws IOException { String volumeName = ofsPath.getVolumeName(); if (recursive) { // Delete all buckets first - OzoneVolume volume = - adapterImpl.getObjectStore().getVolume(volumeName); + OzoneVolume volume = impl.getVolumeDetails(volumeName); Iterator it = volume.listBuckets(""); String prefixVolumePathStr = addTrailingSlashIfNeeded(f.toString()); while (it.hasNext()) { @@ -477,7 +465,7 @@ public boolean delete(Path f, boolean recursive) throws IOException { } } try { - adapterImpl.getObjectStore().deleteVolume(volumeName); + impl.deleteVolume(volumeName); return true; } catch (OMException ex) { // volume is not empty @@ -493,8 +481,7 @@ public boolean delete(Path f, boolean recursive) throws IOException { // Handle delete bucket if (ofsPath.isBucket()) { - OzoneVolume volume = - adapterImpl.getObjectStore().getVolume(ofsPath.getVolumeName()); + OzoneVolume volume = impl.getVolumeDetails(ofsPath.getVolumeName()); try { volume.deleteBucket(ofsPath.getBucketName()); return result; @@ -510,7 +497,7 @@ public boolean delete(Path f, boolean recursive) throws IOException { } else { LOG.debug("delete: Path is a file: {}", f); - result = adapter.deleteObject(key); + result = impl.deleteObject(key); } if (result) { @@ -547,7 +534,7 @@ private void createFakeDirectoryIfNecessary(Path f) throws IOException { if (!key.isEmpty() && !o3Exists(f)) { LOG.debug("Creating new fake directory at {}", f); String dirKey = addTrailingSlashIfNeeded(key); - adapter.createDirectory(dirKey); + impl.createDirectory(dirKey); } } @@ -580,7 +567,7 @@ public FileStatus[] listStatus(Path f) throws IOException { do { tmpStatusList = - adapter.listStatus(pathToKey(f), false, startPath, + impl.listStatus(pathToKey(f), false, startPath, numEntries, uri, workingDir, getUsername()) .stream() .map(this::convertFileStatus) @@ -614,7 +601,7 @@ public Path getWorkingDirectory() { @Override public Token getDelegationToken(String renewer) throws IOException { - return adapter.getDelegationToken(renewer); + return impl.getDelegationToken(renewer); } /** @@ -625,7 +612,7 @@ public Token getDelegationToken(String renewer) throws IOException { */ @Override public String getCanonicalServiceName() { - return adapter.getCanonicalServiceName(); + return impl.getCanonicalServiceName(); } /** @@ -658,7 +645,7 @@ public Path getTrashRoot(Path path) { * @throws IOException */ private boolean mkdir(Path path) throws IOException { - return adapter.createDirectory(pathToKey(path)); + return impl.createDirectory(pathToKey(path)); } @Override @@ -685,7 +672,7 @@ public FileStatus getFileStatus(Path f) throws IOException { FileStatus fileStatus = null; try { fileStatus = convertFileStatus( - adapter.getFileStatus(key, uri, qualifiedPath, getUsername())); + impl.getFileStatus(key, uri, qualifiedPath, getUsername())); } catch (OMException ex) { if (ex.getResult().equals(OMException.ResultCodes.KEY_NOT_FOUND) || ex.getResult().equals(OMException.ResultCodes.BUCKET_NOT_FOUND) || @@ -709,7 +696,7 @@ public BlockLocation[] getFileBlockLocations(FileStatus fileStatus, @Override public short getDefaultReplication() { - return adapter.getDefaultReplication(); + return impl.getDefaultReplication(); } /** @@ -773,7 +760,7 @@ private abstract class OzoneListingIterator { if (status.isDirectory()) { this.pathKey = addTrailingSlashIfNeeded(pathKey); } - keyIterator = adapter.listKeys(pathKey); + keyIterator = impl.listKeys(pathKey); } /** @@ -833,8 +820,8 @@ FileStatus getStatus() { } } - public OzoneClientAdapter getAdapter() { - return adapter; + public BasicRootedOzoneFileSystemImpl getImpl() { + return impl; } public boolean isEmpty(CharSequence cs) { diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystemImpl.java similarity index 94% rename from hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java rename to hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystemImpl.java index b4bb16f06721..bc34678dd0d6 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystemImpl.java @@ -83,14 +83,11 @@ *

* For full featured version use RootedOzoneClientAdapterImpl. */ -public class BasicRootedOzoneClientAdapterImpl - implements OzoneClientAdapter { +public class BasicRootedOzoneFileSystemImpl { static final Logger LOG = - LoggerFactory.getLogger(BasicRootedOzoneClientAdapterImpl.class); + LoggerFactory.getLogger(BasicRootedOzoneFileSystemImpl.class); - private OzoneClient ozoneClient; - private ObjectStore objectStore; private ClientProtocol proxy; private ReplicationType replicationType; private ReplicationFactor replicationFactor; @@ -102,7 +99,7 @@ public class BasicRootedOzoneClientAdapterImpl * * @throws IOException In case of a problem. */ - public BasicRootedOzoneClientAdapterImpl() throws IOException { + public BasicRootedOzoneFileSystemImpl() throws IOException { this(createConf()); } @@ -117,12 +114,12 @@ private static OzoneConfiguration createConf() { } } - public BasicRootedOzoneClientAdapterImpl(OzoneConfiguration conf) + public BasicRootedOzoneFileSystemImpl(OzoneConfiguration conf) throws IOException { this(null, -1, conf); } - public BasicRootedOzoneClientAdapterImpl(String omHost, int omPort, + public BasicRootedOzoneFileSystemImpl(String omHost, int omPort, ConfigurationSource hadoopConf) throws IOException { ClassLoader contextClassLoader = @@ -168,19 +165,17 @@ public BasicRootedOzoneClientAdapterImpl(String omHost, int omPort, int replicationCountConf = conf.getInt(OzoneConfigKeys.OZONE_REPLICATION, OzoneConfigKeys.OZONE_REPLICATION_DEFAULT); + OzoneClient ozoneClient; if (OmUtils.isOmHAServiceId(conf, omHost)) { // omHost is listed as one of the service ids in the config, // thus we should treat omHost as omServiceId - this.ozoneClient = - OzoneClientFactory.getRpcClient(omHost, conf); + ozoneClient = OzoneClientFactory.getRpcClient(omHost, conf); } else if (StringUtils.isNotEmpty(omHost) && omPort != -1) { - this.ozoneClient = - OzoneClientFactory.getRpcClient(omHost, omPort, conf); + ozoneClient = OzoneClientFactory.getRpcClient(omHost, omPort, conf); } else { - this.ozoneClient = - OzoneClientFactory.getRpcClient(conf); + ozoneClient = OzoneClientFactory.getRpcClient(conf); } - objectStore = ozoneClient.getObjectStore(); + ObjectStore objectStore = ozoneClient.getObjectStore(); proxy = objectStore.getClientProxy(); this.replicationType = ReplicationType.valueOf(replicationTypeConf); this.replicationFactor = ReplicationFactor.valueOf(replicationCountConf); @@ -235,7 +230,7 @@ private OzoneBucket getBucket(String volumeStr, String bucketStr, if (getVolEx.getResult().equals(VOLUME_NOT_FOUND)) { // Volume doesn't exist. Create it try { - objectStore.createVolume(volumeStr); + proxy.createVolume(volumeStr); } catch (OMException newVolEx) { // Ignore the case where another client created the volume if (!newVolEx.getResult().equals(VOLUME_ALREADY_EXISTS)) { @@ -268,17 +263,14 @@ private OzoneBucket getBucket(String volumeStr, String bucketStr, return bucket; } - @Override public short getDefaultReplication() { return (short) replicationFactor.getValue(); } - @Override public void close() throws IOException { - ozoneClient.close(); + proxy.close(); } - @Override public InputStream readFile(String pathStr) throws IOException { incrementCounter(Statistic.OBJECTS_READ); OFSPath ofsPath = new OFSPath(pathStr); @@ -301,7 +293,6 @@ protected void incrementCounter(Statistic objectsRead) { //noop: Use OzoneClientAdapterImpl which supports statistics. } - @Override public OzoneFSOutputStream createFile(String pathStr, short replication, boolean overWrite, boolean recursive) throws IOException { incrementCounter(Statistic.OBJECTS_CREATED); @@ -336,11 +327,6 @@ public OzoneFSOutputStream createFile(String pathStr, short replication, } } - @Override - public void renameKey(String key, String newKeyName) throws IOException { - throw new IOException("OFS doesn't support renameKey, use rename instead."); - } - /** * Rename a path into another. * @@ -352,7 +338,6 @@ public void renameKey(String key, String newKeyName) throws IOException { * @param newPath Target path * @throws IOException */ - @Override public void rename(String path, String newPath) throws IOException { incrementCounter(Statistic.OBJECTS_RENAMED); OFSPath ofsPath = new OFSPath(path); @@ -395,7 +380,6 @@ void rename(OzoneBucket bucket, String path, String newPath) * @param pathStr path to be created as directory * @return true if the key is created, false otherwise */ - @Override public boolean createDirectory(String pathStr) throws IOException { LOG.trace("creating dir for path: {}", pathStr); incrementCounter(Statistic.OBJECTS_CREATED); @@ -406,7 +390,7 @@ public boolean createDirectory(String pathStr) throws IOException { } if (ofsPath.getBucketName().isEmpty()) { // Create volume only - objectStore.createVolume(ofsPath.getVolumeName()); + proxy.createVolume(ofsPath.getVolumeName()); return true; } String keyStr = ofsPath.getKeyName(); @@ -434,7 +418,6 @@ public boolean createDirectory(String pathStr) throws IOException { * @param path path to a key to be deleted * @return true if the key is deleted, false otherwise */ - @Override public boolean deleteObject(String path) { LOG.trace("issuing delete for path to key: {}", path); incrementCounter(Statistic.OBJECTS_DELETED); @@ -459,7 +442,6 @@ public boolean deleteObject(String path) { * @param pathList key name list to be deleted * @return true if the key is deleted, false otherwise */ - @Override public boolean deleteObjects(List pathList) { // TODO: we will support deleteObjects in ofs. LOG.error("ofs currently does not support deleteObjects"); @@ -498,7 +480,7 @@ public FileStatusAdapter getFileStatus(String path, URI uri, return getFileStatusAdapterForRoot(uri); } if (ofsPath.isVolume()) { - OzoneVolume volume = objectStore.getVolume(ofsPath.getVolumeName()); + OzoneVolume volume = proxy.getVolumeDetails(ofsPath.getVolumeName()); return getFileStatusAdapterForVolume(volume, uri); } try { @@ -516,7 +498,6 @@ public FileStatusAdapter getFileStatus(String path, URI uri, } } - @Override public Iterator listKeys(String pathStr) { incrementCounter(Statistic.OBJECTS_LIST); OFSPath ofsPath = new OFSPath(pathStr); @@ -539,12 +520,11 @@ private List listStatusRoot( URI uri, Path workingDir, String username) throws IOException { OFSPath ofsStartPath = new OFSPath(startPath); - // list volumes - Iterator iter = objectStore.listVolumesByUser( - username, null, ofsStartPath.getVolumeName()); List res = new ArrayList<>(); - while (iter.hasNext() && res.size() < numEntries) { - OzoneVolume volume = iter.next(); + // list volumes + List listVolumes = proxy.listVolumes( + username, null, ofsStartPath.getVolumeName(), (int)numEntries); + for (OzoneVolume volume : listVolumes) { res.add(getFileStatusAdapterForVolume(volume, uri)); if (recursive) { String pathStrNextVolume = volume.getName(); @@ -564,7 +544,7 @@ private List listStatusVolume(String volumeStr, OFSPath ofsStartPath = new OFSPath(startPath); // list buckets in the volume - OzoneVolume volume = objectStore.getVolume(volumeStr); + OzoneVolume volume = proxy.getVolumeDetails(volumeStr); Iterator iter = volume.listBuckets(null, ofsStartPath.getBucketName()); List res = new ArrayList<>(); @@ -658,36 +638,36 @@ public List listStatus(String pathStr, boolean recursive, } } - @Override public Token getDelegationToken(String renewer) throws IOException { if (!securityEnabled) { return null; } - Token token = ozoneClient.getObjectStore() - .getDelegationToken(renewer == null ? null : new Text(renewer)); + Token token = proxy.getDelegationToken( + renewer == null ? null : new Text(renewer)); token.setKind(OzoneTokenIdentifier.KIND_NAME); return token; } - public ObjectStore getObjectStore() { - return objectStore; - } - - @Override public KeyProvider getKeyProvider() throws IOException { - return objectStore.getKeyProvider(); + return proxy.getKeyProvider(); } - @Override public URI getKeyProviderUri() throws IOException { - return objectStore.getKeyProviderUri(); + return proxy.getKeyProviderUri(); } - @Override public String getCanonicalServiceName() { - return objectStore.getCanonicalServiceName(); + return proxy.getCanonicalServiceName(); + } + + public OzoneVolume getVolumeDetails(String volumeName) throws IOException { + return proxy.getVolumeDetails(volumeName); + } + + public void deleteVolume(String volumeName) throws IOException { + proxy.deleteVolume(volumeName); } /** diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java index 2b76c22c4d56..98e128131b32 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientAdapter.java @@ -46,9 +46,6 @@ OzoneFSOutputStream createFile(String key, short replication, void renameKey(String key, String newKeyName) throws IOException; - // Users should use rename instead of renameKey in OFS. - void rename(String pathStr, String newPath) throws IOException; - boolean createDirectory(String keyName) throws IOException; boolean deleteObject(String keyName); diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java deleted file mode 100644 index e5cfb14acc0f..000000000000 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneClientAdapterImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.fs.ozone; - -import java.io.IOException; - -import org.apache.hadoop.hdds.conf.ConfigurationSource; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; - -/** - * Implementation of the RootedOzoneFileSystem calls. - */ -public class RootedOzoneClientAdapterImpl - extends BasicRootedOzoneClientAdapterImpl { - - private OzoneFSStorageStatistics storageStatistics; - - public RootedOzoneClientAdapterImpl( - OzoneFSStorageStatistics storageStatistics) - throws IOException { - super(); - this.storageStatistics = storageStatistics; - } - - public RootedOzoneClientAdapterImpl( - OzoneConfiguration conf, OzoneFSStorageStatistics storageStatistics) - throws IOException { - super(conf); - this.storageStatistics = storageStatistics; - } - - public RootedOzoneClientAdapterImpl(String omHost, int omPort, - ConfigurationSource hadoopConf, - OzoneFSStorageStatistics storageStatistics) - throws IOException { - super(omHost, omPort, hadoopConf); - this.storageStatistics = storageStatistics; - } - - @Override - protected void incrementCounter(Statistic objectsRead) { - if (storageStatistics != null) { - storageStatistics.incrementCounter(objectsRead, 1); - } - } -} diff --git a/hadoop-ozone/ozonefs-common/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/ozonefs-common/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/ozonefs-common/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/ozonefs-common/src/test/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem diff --git a/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java new file mode 100644 index 000000000000..076287eaac14 --- /dev/null +++ b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.ozone; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.DelegateToFileSystem; +import org.apache.hadoop.hdds.annotation.InterfaceAudience; +import org.apache.hadoop.hdds.annotation.InterfaceStability; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Ozone implementation of AbstractFileSystem. + * This impl delegates to the RootedOzoneFileSystem + */ +@InterfaceAudience.Public +@InterfaceStability.Evolving +public class RootedOzFs extends DelegateToFileSystem { + + public RootedOzFs(URI theUri, Configuration conf) + throws IOException, URISyntaxException { + super(theUri, new RootedOzoneFileSystem(), conf, + OzoneConsts.OZONE_OFS_URI_SCHEME, false); + } +} diff --git a/hadoop-ozone/ozonefs-hadoop2/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/ozonefs-hadoop2/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/ozonefs-hadoop2/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/ozonefs-hadoop2/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem diff --git a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java new file mode 100644 index 000000000000..076287eaac14 --- /dev/null +++ b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.ozone; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.DelegateToFileSystem; +import org.apache.hadoop.hdds.annotation.InterfaceAudience; +import org.apache.hadoop.hdds.annotation.InterfaceStability; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Ozone implementation of AbstractFileSystem. + * This impl delegates to the RootedOzoneFileSystem + */ +@InterfaceAudience.Public +@InterfaceStability.Evolving +public class RootedOzFs extends DelegateToFileSystem { + + public RootedOzFs(URI theUri, Configuration conf) + throws IOException, URISyntaxException { + super(theUri, new RootedOzoneFileSystem(), conf, + OzoneConsts.OZONE_OFS_URI_SCHEME, false); + } +} diff --git a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java index 4817f2aa2d7f..5b488b0a9760 100644 --- a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java +++ b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java @@ -20,7 +20,6 @@ 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; @@ -51,12 +50,12 @@ public RootedOzoneFileSystem() { @Override public KeyProvider getKeyProvider() throws IOException { - return getAdapter().getKeyProvider(); + return getImpl().getKeyProvider(); } @Override public URI getKeyProviderUri() throws IOException { - return getAdapter().getKeyProviderUri(); + return getImpl().getKeyProviderUri(); } @Override @@ -85,11 +84,4 @@ protected void incrementCounter(Statistic statistic) { storageStatistics.incrementCounter(statistic, 1); } } - - @Override - protected OzoneClientAdapter createAdapter(ConfigurationSource conf, - String omHost, int omPort) throws IOException { - return new RootedOzoneClientAdapterImpl(omHost, omPort, conf, - storageStatistics); - } } diff --git a/hadoop-ozone/ozonefs-hadoop3/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/ozonefs-hadoop3/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/ozonefs-hadoop3/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/ozonefs-hadoop3/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java new file mode 100644 index 000000000000..076287eaac14 --- /dev/null +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.ozone; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.DelegateToFileSystem; +import org.apache.hadoop.hdds.annotation.InterfaceAudience; +import org.apache.hadoop.hdds.annotation.InterfaceStability; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Ozone implementation of AbstractFileSystem. + * This impl delegates to the RootedOzoneFileSystem + */ +@InterfaceAudience.Public +@InterfaceStability.Evolving +public class RootedOzFs extends DelegateToFileSystem { + + public RootedOzFs(URI theUri, Configuration conf) + throws IOException, URISyntaxException { + super(theUri, new RootedOzoneFileSystem(), conf, + OzoneConsts.OZONE_OFS_URI_SCHEME, false); + } +} 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 4817f2aa2d7f..5b488b0a9760 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 @@ -20,7 +20,6 @@ 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; @@ -51,12 +50,12 @@ public RootedOzoneFileSystem() { @Override public KeyProvider getKeyProvider() throws IOException { - return getAdapter().getKeyProvider(); + return getImpl().getKeyProvider(); } @Override public URI getKeyProviderUri() throws IOException { - return getAdapter().getKeyProviderUri(); + return getImpl().getKeyProviderUri(); } @Override @@ -85,11 +84,4 @@ protected void incrementCounter(Statistic statistic) { storageStatistics.incrementCounter(statistic, 1); } } - - @Override - protected OzoneClientAdapter createAdapter(ConfigurationSource conf, - String omHost, int omPort) throws IOException { - return new RootedOzoneClientAdapterImpl(omHost, omPort, conf, - storageStatistics); - } } diff --git a/hadoop-ozone/ozonefs/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/ozonefs/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/ozonefs/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/ozonefs/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem diff --git a/hadoop-ozone/tools/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem b/hadoop-ozone/tools/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem index 03680027d539..e444f66e7ce1 100644 --- a/hadoop-ozone/tools/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem +++ b/hadoop-ozone/tools/src/main/resources/META-INF/services/org.apache.hadoop.fs.FileSystem @@ -14,3 +14,4 @@ # limitations under the License. org.apache.hadoop.fs.ozone.OzoneFileSystem +org.apache.hadoop.fs.ozone.RootedOzoneFileSystem