HDFS-14210. RBF: ACL commands should work over all the destinations. Contributed by Ayush Saxena.

This commit is contained in:
Ayush Saxena 2019-05-16 00:45:20 +05:30 committed by Brahma Reddy Battula
parent 32841178ba
commit 62fa53a01d
2 changed files with 60 additions and 5 deletions

View File

@ -1313,7 +1313,11 @@ public class RouterClientProtocol implements ClientProtocol {
RemoteMethod method = new RemoteMethod("modifyAclEntries",
new Class<?>[] {String.class, List.class},
new RemoteParam(), aclSpec);
rpcClient.invokeSequential(locations, method, null, null);
if (rpcServer.isInvokeConcurrent(src)) {
rpcClient.invokeConcurrent(locations, method);
} else {
rpcClient.invokeSequential(locations, method);
}
}
@Override
@ -1327,7 +1331,11 @@ public class RouterClientProtocol implements ClientProtocol {
RemoteMethod method = new RemoteMethod("removeAclEntries",
new Class<?>[] {String.class, List.class},
new RemoteParam(), aclSpec);
rpcClient.invokeSequential(locations, method, null, null);
if (rpcServer.isInvokeConcurrent(src)) {
rpcClient.invokeConcurrent(locations, method);
} else {
rpcClient.invokeSequential(locations, method);
}
}
@Override
@ -1339,8 +1347,12 @@ public class RouterClientProtocol implements ClientProtocol {
rpcServer.getLocationsForPath(src, true);
RemoteMethod method = new RemoteMethod("removeDefaultAcl",
new Class<?>[] {String.class}, new RemoteParam());
if (rpcServer.isInvokeConcurrent(src)) {
rpcClient.invokeConcurrent(locations, method);
} else {
rpcClient.invokeSequential(locations, method);
}
}
@Override
public void removeAcl(String src) throws IOException {
@ -1351,8 +1363,12 @@ public class RouterClientProtocol implements ClientProtocol {
rpcServer.getLocationsForPath(src, true);
RemoteMethod method = new RemoteMethod("removeAcl",
new Class<?>[] {String.class}, new RemoteParam());
if (rpcServer.isInvokeConcurrent(src)) {
rpcClient.invokeConcurrent(locations, method);
} else {
rpcClient.invokeSequential(locations, method);
}
}
@Override
public void setAcl(String src, List<AclEntry> aclSpec) throws IOException {
@ -1364,8 +1380,12 @@ public class RouterClientProtocol implements ClientProtocol {
RemoteMethod method = new RemoteMethod(
"setAcl", new Class<?>[] {String.class, List.class},
new RemoteParam(), aclSpec);
if (rpcServer.isInvokeConcurrent(src)) {
rpcClient.invokeConcurrent(locations, method);
} else {
rpcClient.invokeSequential(locations, method);
}
}
@Override
public AclStatus getAclStatus(String src) throws IOException {

View File

@ -38,7 +38,9 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Options.Rename;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
@ -84,6 +86,7 @@ public class TestRouterRPCMultipleDestinationMountTableResolver {
new RouterConfigBuilder().stateStore().admin().quota().rpc().build();
Configuration hdfsConf = new Configuration(false);
hdfsConf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, true);
cluster.addRouterOverrides(routerConf);
cluster.addNamenodeOverrides(hdfsConf);
@ -406,6 +409,38 @@ public class TestRouterRPCMultipleDestinationMountTableResolver {
return addResponse.getStatus();
}
@Test
public void testACLMultipleDestinations() throws Exception {
setupOrderMountPath(DestinationOrder.HASH_ALL);
Path mountPath = new Path("/mount/dir/dir");
Path nsPath = new Path("/tmp/dir/dir");
List<AclEntry> aclSpec = Collections.singletonList(
AclEntry.parseAclEntry("default:USER:TestUser:rwx", true));
routerFs.setAcl(mountPath, aclSpec);
assertEquals(5, nnFs0.getAclStatus(nsPath).getEntries().size());
assertEquals(5, nnFs1.getAclStatus(nsPath).getEntries().size());
aclSpec = Collections
.singletonList(AclEntry.parseAclEntry("USER:User:rwx::", true));
routerFs.modifyAclEntries(mountPath, aclSpec);
assertEquals(7, nnFs0.getAclStatus(nsPath).getEntries().size());
assertEquals(7, nnFs1.getAclStatus(nsPath).getEntries().size());
routerFs.removeAclEntries(mountPath, aclSpec);
assertEquals(6, nnFs0.getAclStatus(nsPath).getEntries().size());
assertEquals(6, nnFs1.getAclStatus(nsPath).getEntries().size());
routerFs.modifyAclEntries(mountPath, aclSpec);
routerFs.removeDefaultAcl(mountPath);
assertEquals(2, nnFs0.getAclStatus(nsPath).getEntries().size());
assertEquals(2, nnFs1.getAclStatus(nsPath).getEntries().size());
routerFs.removeAcl(mountPath);
assertEquals(0, nnFs0.getAclStatus(nsPath).getEntries().size());
assertEquals(0, nnFs1.getAclStatus(nsPath).getEntries().size());
}
@Test
public void testGetDestinationHashAll() throws Exception {
testGetDestination(DestinationOrder.HASH_ALL,