HDFS-13253. RBF: Quota management incorrect parent-child relationship judgement. Contributed by Yiqun Lin.
This commit is contained in:
parent
89105a623b
commit
430cdfefc0
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.federation.resolver;
|
|||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ROUTER_DEFAULT_NAMESERVICE;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.FEDERATION_MOUNT_TABLE_MAX_CACHE_SIZE;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.FEDERATION_MOUNT_TABLE_MAX_CACHE_SIZE_DEFAULT;
|
||||
import static org.apache.hadoop.hdfs.server.federation.router.FederationUtil.isParentEntry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
@ -239,7 +240,7 @@ public class MountTableResolver
|
|||
PathLocation loc = entry.getValue();
|
||||
String src = loc.getSourcePath();
|
||||
if (src != null) {
|
||||
if (src.startsWith(path)) {
|
||||
if(isParentEntry(src, path)) {
|
||||
LOG.debug("Removing {}", src);
|
||||
it.remove();
|
||||
}
|
||||
|
@ -530,17 +531,6 @@ public class MountTableResolver
|
|||
return this.defaultNameService;
|
||||
}
|
||||
|
||||
private boolean isParentEntry(final String path, final String parent) {
|
||||
if (!path.startsWith(parent)) {
|
||||
return false;
|
||||
}
|
||||
if (path.equals(parent)) {
|
||||
return true;
|
||||
}
|
||||
return path.charAt(parent.length()) == Path.SEPARATOR_CHAR
|
||||
|| parent.equals(Path.SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the deepest mount point for a path.
|
||||
* @param path Path to look for.
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.net.URL;
|
|||
import java.net.URLConnection;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.FileSubclusterResolver;
|
||||
|
@ -186,4 +187,23 @@ public final class FederationUtil {
|
|||
ActiveNamenodeResolver.class);
|
||||
return newInstance(conf, stateStore, StateStoreService.class, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given path is the child of parent path.
|
||||
* @param path Path to be check.
|
||||
* @param parent Parent path.
|
||||
* @return True if parent path is parent entry for given path.
|
||||
*/
|
||||
public static boolean isParentEntry(final String path, final String parent) {
|
||||
if (!path.startsWith(parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path.equals(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return path.charAt(parent.length()) == Path.SEPARATOR_CHAR
|
||||
|| parent.equals(Path.SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue