Skip to content

Commit

Permalink
HDFS-16728. RBF throw IndexOutOfBoundsException with disableNameServi…
Browse files Browse the repository at this point in the history
…ces (#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>
  • Loading branch information
ZanderXu committed Aug 24, 2022
1 parent 75aff24 commit 8d4f51c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down

0 comments on commit 8d4f51c

Please sign in to comment.