HDFS-16728. RBF throw IndexOutOfBoundsException with disableNameServices (#4734). Contributed by ZanderXu.

Reviewed-by: He Xiaoqiao <hexiaoqiao@apache.org>
Reviewed-by: Inigo Goiri <inigoiri@apache.org>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
ZanderXu 2022-08-24 22:57:15 +08:00 committed by GitHub
parent 75aff247ae
commit 8d4f51c432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View File

@ -2214,7 +2214,7 @@ private List<RemoteResult<RemoteLocation, DirectoryListing>> getListingInt(
.invokeConcurrent(locations, method, false, -1,
DirectoryListing.class);
return listings;
} catch (RouterResolveException e) {
} catch (NoLocationException | RouterResolveException e) {
LOG.debug("Cannot get locations for {}, {}.", src, e.getMessage());
return new ArrayList<>();
}

View File

@ -1764,6 +1764,9 @@ protected List<RemoteLocation> getLocationsForPath(String path,
locs.add(loc);
}
}
if (locs.isEmpty()) {
throw new NoLocationException(path, this.subclusterResolver.getClass());
}
return locs;
} catch (IOException ioe) {
if (this.rpcMonitor != null) {

View File

@ -59,6 +59,7 @@ public class MockResolver
private String defaultNamespace = null;
private boolean disableDefaultNamespace = false;
private volatile boolean disableRegistration = false;
private TreeSet<String> disableNamespaces = new TreeSet<>();
public MockResolver() {
this.cleanRegistrations();
@ -300,9 +301,17 @@ public synchronized Set<FederationNamespaceInfo> getNamespaces()
return Collections.unmodifiableSet(this.namespaces);
}
public void clearDisableNamespaces() {
this.disableNamespaces.clear();
}
public void disableNamespace(String nsId) {
this.disableNamespaces.add(nsId);
}
@Override
public Set<String> getDisabledNamespaces() throws IOException {
return new TreeSet<>();
return this.disableNamespaces;
}
@Override

View File

@ -1548,6 +1548,24 @@ public void testRenewLeaseWithMultiStream() throws Exception {
}
}
@Test
public void testMkdirWithDisableNameService() throws Exception {
MockResolver resolver = (MockResolver)router.getRouter().getSubclusterResolver();
String ns0 = cluster.getNameservices().get(0);
resolver.addLocation("/mnt", ns0, "/");
MockResolver activeNamenodeResolver = (MockResolver)router.getRouter().getNamenodeResolver();
activeNamenodeResolver.disableNamespace(ns0);
try {
FsPermission permission = new FsPermission("777");
RouterRpcServer rpcServer = router.getRouter().getRpcServer();
LambdaTestUtils.intercept(NoLocationException.class,
() -> rpcServer.mkdirs("/mnt/folder0/folder1", permission, true));
} finally {
activeNamenodeResolver.clearDisableNamespaces();
}
}
@Test
public void testProxyExceptionMessages() throws IOException {