Skip to content

Commit

Permalink
Merge pull request #226 from DSL-UMD/distributed
Browse files Browse the repository at this point in the history
NN_BECHMARK route
  • Loading branch information
gangliao authored Oct 10, 2019
2 parents 0a7ca69 + a83a3ec commit bca7ed3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public String resolve(String path) {
return chosen.fsUri;
}

public String resolveForBench(String path) {
String parent = "";
if (path.charAt(49) == '/')
parent = s.substring(0, 49);
else
parent = s.substring(0, 50);
return this.lookupMap.get(parent).get(0).fsUri;
}

public String resolveOpt(String path) {
MountEntry chosen = null;
if (path == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,27 @@ ClientProtocol getUpstreamProtocol(String user, String fs) throws ExecutionExcep
}

RouteInfo route(String path) throws IOException {
String logicalPath = path;
Matcher mch = TRASH_PATTERN.matcher(path);
if (mch.find()) {
logicalPath = "/" + mch.group(1);
LOG.debug("Hit trash pattern: " + path + " -> " + logicalPath);
String nnbench = System.getenv("NN_BECHMARK");
if (nnbench != null) {
String fs = nnProxy.getMounts().resolveForBench(path);
return new RouteInfo(getProtocol(fs), path, fs);
} else {
String logicalPath = path;
Matcher mch = TRASH_PATTERN.matcher(path);
if (mch.find()) {
logicalPath = "/" + mch.group(1);
LOG.debug("Hit trash pattern: " + path + " -> " + logicalPath);
}
String fs = nnProxy.getMounts().resolveOpt(logicalPath);
if (fs == null) {
// mount to default path
fs = defaultNN;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Resolved: " + path + " -> " + fs + path);
}
return new RouteInfo(getProtocol(fs), path, fs);
}
String fs = nnProxy.getMounts().resolveOpt(logicalPath);
if (fs == null) {
// mount to default path
fs = defaultNN;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Resolved: " + path + " -> " + fs + path);
}
return new RouteInfo(getProtocol(fs), path, fs);
}

ClientProtocol getProtocol(String fs) throws IOException {
Expand Down

0 comments on commit bca7ed3

Please sign in to comment.