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:
parent
75aff247ae
commit
8d4f51c432
@ -2214,7 +2214,7 @@ private List<RemoteResult<RemoteLocation, DirectoryListing>> getListingInt(
|
|||||||
.invokeConcurrent(locations, method, false, -1,
|
.invokeConcurrent(locations, method, false, -1,
|
||||||
DirectoryListing.class);
|
DirectoryListing.class);
|
||||||
return listings;
|
return listings;
|
||||||
} catch (RouterResolveException e) {
|
} catch (NoLocationException | RouterResolveException e) {
|
||||||
LOG.debug("Cannot get locations for {}, {}.", src, e.getMessage());
|
LOG.debug("Cannot get locations for {}, {}.", src, e.getMessage());
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -1764,6 +1764,9 @@ protected List<RemoteLocation> getLocationsForPath(String path,
|
|||||||
locs.add(loc);
|
locs.add(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (locs.isEmpty()) {
|
||||||
|
throw new NoLocationException(path, this.subclusterResolver.getClass());
|
||||||
|
}
|
||||||
return locs;
|
return locs;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (this.rpcMonitor != null) {
|
if (this.rpcMonitor != null) {
|
||||||
|
@ -59,6 +59,7 @@ public class MockResolver
|
|||||||
private String defaultNamespace = null;
|
private String defaultNamespace = null;
|
||||||
private boolean disableDefaultNamespace = false;
|
private boolean disableDefaultNamespace = false;
|
||||||
private volatile boolean disableRegistration = false;
|
private volatile boolean disableRegistration = false;
|
||||||
|
private TreeSet<String> disableNamespaces = new TreeSet<>();
|
||||||
|
|
||||||
public MockResolver() {
|
public MockResolver() {
|
||||||
this.cleanRegistrations();
|
this.cleanRegistrations();
|
||||||
@ -300,9 +301,17 @@ public synchronized Set<FederationNamespaceInfo> getNamespaces()
|
|||||||
return Collections.unmodifiableSet(this.namespaces);
|
return Collections.unmodifiableSet(this.namespaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearDisableNamespaces() {
|
||||||
|
this.disableNamespaces.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableNamespace(String nsId) {
|
||||||
|
this.disableNamespaces.add(nsId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getDisabledNamespaces() throws IOException {
|
public Set<String> getDisabledNamespaces() throws IOException {
|
||||||
return new TreeSet<>();
|
return this.disableNamespaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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
|
@Test
|
||||||
public void testProxyExceptionMessages() throws IOException {
|
public void testProxyExceptionMessages() throws IOException {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user