diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index e5cbf49e84e97a..663bb72f4a11e7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -1369,7 +1369,7 @@ public boolean hasPathCapability(Path path, String capability) throw new NotInMountpointException(p, "hasPathCapability"); } } - + @Override public Path getEnclosingRoot(Path path) throws IOException { InodeTree.ResolveResult res; @@ -1380,7 +1380,8 @@ public Path getEnclosingRoot(Path path) throws IOException { } Path mountPath = new Path(res.resolvedPath); Path enclosingPath = res.targetFileSystem.getEnclosingRoot(new Path(getUriPath(path))); - return fixRelativePart(this.makeQualified(enclosingPath.depth() > mountPath.depth() ? enclosingPath : mountPath)); + return fixRelativePart(this.makeQualified(enclosingPath.depth() > mountPath.depth() + ? enclosingPath : mountPath)); } /** diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java index 0107431fb0739a..de8f309abdcec2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java @@ -36,7 +36,6 @@ import java.util.Set; -import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.util.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java index 24ffa553e15093..6b04169bfc7d50 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java @@ -144,9 +144,9 @@ public class RouterClientProtocol implements ClientProtocol { private final boolean allowPartialList; /** Time out when getting the mount statistics. */ private long mountStatusTimeOut; - - /** Default nameservice enabled */ - private final boolean defaultNameserviceEnabled; + + /** Default nameservice enabled. */ + private final boolean defaultNameServiceEnabled; /** Identifier for the super user. */ private String superUser; @@ -197,7 +197,8 @@ public class RouterClientProtocol implements ClientProtocol { this.routerCacheAdmin = new RouterCacheAdmin(rpcServer); this.securityManager = rpcServer.getRouterSecurityManager(); this.rbfRename = new RouterFederationRename(rpcServer, conf); - this.defaultNameserviceEnabled = conf.getBoolean(RBFConfigKeys.DFS_ROUTER_DEFAULT_NAMESERVICE_ENABLE, + this.defaultNameServiceEnabled = conf.getBoolean( + RBFConfigKeys.DFS_ROUTER_DEFAULT_NAMESERVICE_ENABLE, RBFConfigKeys.DFS_ROUTER_DEFAULT_NAMESERVICE_ENABLE_DEFAULT); } @@ -1944,22 +1945,21 @@ public DatanodeInfo[] getSlowDatanodeReport() throws IOException { @Override public Path getEnclosingRoot(String src) throws IOException { Path mountPath = null; - if (defaultNameserviceEnabled) { + if (defaultNameServiceEnabled) { mountPath = new Path("/"); } - + if (subclusterResolver instanceof MountTableResolver) { MountTableResolver mountTable = (MountTableResolver) subclusterResolver; if (mountTable.getMountPoint(src) != null) { - // unclear if this is the correct thing to do, probably depends on default mount point / link fallback mountPath = new Path(mountTable.getMountPoint(src).getSourcePath()); } } - + if (mountPath == null) { throw new IOException(String.format("No mount point for %s", src)); } - + EncryptionZone zone = getEZForPath(src); if (zone == null) { return mountPath; diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java index 5c91f39acc25a6..ea5ea2ccbcb4fe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java @@ -2113,7 +2113,6 @@ public ListenableFuture reload( @Override // ClientProtocol public Path getEnclosingRoot(String src) throws IOException { - // need to resolve this src to a mount point in RBF and return the max this and the enclosing root from nn return clientProto.getEnclosingRoot(src); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterMountTable.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterMountTable.java index 745e99ecb976a9..8812f83febb803 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterMountTable.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterMountTable.java @@ -53,7 +53,6 @@ import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesRequest; import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse; import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryResponse; import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryRequest; import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryResponse; import org.apache.hadoop.hdfs.server.federation.store.records.MountTable; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java index 2ac4414d6058b8..c75908a73644ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java @@ -2083,7 +2083,8 @@ public GetEnclosingRootResponseProto getEnclosingRoot( throws ServiceException { try { Path enclosingRootPath = server.getEnclosingRoot(req.getFilename()); - return GetEnclosingRootResponseProto.newBuilder().setEnclosingRootPath(enclosingRootPath.toUri().toString()) + return GetEnclosingRootResponseProto.newBuilder() + .setEnclosingRootPath(enclosingRootPath.toUri().toString()) .build(); } catch (IOException e) { throw new ServiceException(e); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java index a4de359b51761e..39d027aec2340a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java @@ -200,7 +200,8 @@ public void testTrashRootsAfterEncryptionZoneDeletion() throws Exception { DFSTestUtil.createKey("test_key", cluster, CONF); HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF); - final EnumSet provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); + final EnumSet provisionTrash = + EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash); final Path encFile = new Path(zone1, "encFile"); @@ -213,11 +214,13 @@ public void testTrashRootsAfterEncryptionZoneDeletion() throws Exception { //Verify file deletion within EZ DFSTestUtil.verifyDelete(shell, fsTarget, encFile, true); - assertTrue("ViewFileSystem trash roots should include EZ file trash", (fsView.getTrashRoots(true).size() == 1)); + assertTrue("ViewFileSystem trash roots should include EZ file trash", + (fsView.getTrashRoots(true).size() == 1)); //Verify deletion of EZ DFSTestUtil.verifyDelete(shell, fsTarget, zone, true); - assertTrue("ViewFileSystem trash roots should include EZ zone trash", (fsView.getTrashRoots(true).size() == 2)); + assertTrue("ViewFileSystem trash roots should include EZ zone trash", + (fsView.getTrashRoots(true).size() == 2)); } finally { DFSTestUtil.deleteKey("test_key", cluster); } @@ -527,7 +530,8 @@ public void testEnclosingRootsBase() throws Exception { DFSTestUtil.createKey("test_key", cluster, 0, CONF); HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF); - final EnumSet provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); + final EnumSet provisionTrash = + EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash); assertEquals(fsView.getEnclosingRoot(zone), getViewFsPath("/data", fsView)); assertEquals(fsView.getEnclosingRoot(zone1), getViewFsPath(zone1, fsView)); @@ -539,10 +543,12 @@ public void testEnclosingRootsBase() throws Exception { DFSTestUtil.createKey("test_key", cluster, 1, CONF); hdfsAdmin2.createEncryptionZone(nn02Ez, "test_key", provisionTrash); assertEquals(fsView.getEnclosingRoot((nn02Ez)), getViewFsPath(nn02Ez, fsView)); - assertEquals(fsView.getEnclosingRoot(new Path(nn02Ez, "dir/dir2/file")), getViewFsPath(nn02Ez, fsView)); + assertEquals(fsView.getEnclosingRoot(new Path(nn02Ez, "dir/dir2/file")), + getViewFsPath(nn02Ez, fsView)); // With viewfs:// scheme - assertEquals(fsView.getEnclosingRoot(fsView.getWorkingDirectory()), getViewFsPath("/user", fsView)); + assertEquals(fsView.getEnclosingRoot(fsView.getWorkingDirectory()), + getViewFsPath("/user", fsView)); } finally { DFSTestUtil.deleteKey("test_key", cluster, 0); } @@ -572,7 +578,8 @@ public void testEnclosingRootWrapped() throws Exception { DFSTestUtil.createKey("test_key", cluster, 0, CONF); HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF); - final EnumSet provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); + final EnumSet provisionTrash = + EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash); UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEnclosingRoot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEnclosingRoot.java index 06e3218ec9733c..3c40782ef22a8a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEnclosingRoot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEnclosingRoot.java @@ -42,7 +42,7 @@ public class TestEnclosingRoot extends AbstractHadoopTestBase { private static final Logger LOG = LoggerFactory.getLogger(TestEnclosingRoot.class); - private final String TEST_KEY = "test_key"; + private static final String TEST_KEY = "test_key"; private static final EnumSet NO_TRASH = EnumSet.of(CreateEncryptionZoneFlag.NO_TRASH);