Skip to content

Commit

Permalink
HDFS-16791 fixing pr checks/failurs/style
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McCormick committed Jan 18, 2023
1 parent 1e13b70 commit 5865dad
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<FileSystem> res;
Expand All @@ -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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,6 @@ public ListenableFuture<DatanodeInfo[]> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateEncryptionZoneFlag> provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
final EnumSet<CreateEncryptionZoneFlag> provisionTrash =
EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash);

final Path encFile = new Path(zone1, "encFile");
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<CreateEncryptionZoneFlag> provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
final EnumSet<CreateEncryptionZoneFlag> 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));
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<CreateEncryptionZoneFlag> provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
final EnumSet<CreateEncryptionZoneFlag> provisionTrash =
EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash);

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateEncryptionZoneFlag> NO_TRASH =
EnumSet.of(CreateEncryptionZoneFlag.NO_TRASH);

Expand Down

0 comments on commit 5865dad

Please sign in to comment.