HDFS-13253. RBF: Quota management incorrect parent-child relationship judgement. Contributed by Yiqun Lin.
(cherry picked from commit 430cdfefc01686fc4b88e46060da5b19dced5def)
This commit is contained in:
parent
f4bbd6c893
commit
da270052a2
@ -20,6 +20,7 @@
|
|||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ROUTER_DEFAULT_NAMESERVICE;
|
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;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.FEDERATION_MOUNT_TABLE_MAX_CACHE_SIZE_DEFAULT;
|
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.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -239,7 +240,7 @@ private void invalidateLocationCache(final String path) {
|
|||||||
PathLocation loc = entry.getValue();
|
PathLocation loc = entry.getValue();
|
||||||
String src = loc.getSourcePath();
|
String src = loc.getSourcePath();
|
||||||
if (src != null) {
|
if (src != null) {
|
||||||
if (src.startsWith(path)) {
|
if(isParentEntry(src, path)) {
|
||||||
LOG.debug("Removing {}", src);
|
LOG.debug("Removing {}", src);
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
@ -530,17 +531,6 @@ public String getDefaultNamespace() {
|
|||||||
return this.defaultNameService;
|
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.
|
* Find the deepest mount point for a path.
|
||||||
* @param path Path to look for.
|
* @param path Path to look for.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver;
|
import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver;
|
||||||
import org.apache.hadoop.hdfs.server.federation.resolver.FileSubclusterResolver;
|
import org.apache.hadoop.hdfs.server.federation.resolver.FileSubclusterResolver;
|
||||||
@ -186,4 +187,23 @@ public static ActiveNamenodeResolver newActiveNamenodeResolver(
|
|||||||
ActiveNamenodeResolver.class);
|
ActiveNamenodeResolver.class);
|
||||||
return newInstance(conf, stateStore, StateStoreService.class, clazz);
|
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…
x
Reference in New Issue
Block a user