HADOOP-12201. Add tracing to FileSystem#createFileSystem and Globber#glob (cmccabe)

This commit is contained in:
Colin Patrick Mccabe 2015-07-08 20:07:21 -07:00
parent 2e3d83f97b
commit b8832fcf1e
3 changed files with 36 additions and 4 deletions

View File

@ -687,6 +687,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-12195. Add annotation to package-info.java file to workaround HADOOP-12195. Add annotation to package-info.java file to workaround
MCOMPILER-205. (wang) MCOMPILER-205. (wang)
HADOOP-12201. Add tracing to FileSystem#createFileSystem and Globber#glob
(cmccabe)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-11785. Reduce the number of listStatus operation in distcp HADOOP-11785. Reduce the number of listStatus operation in distcp

View File

@ -67,6 +67,9 @@
import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.ShutdownHookManager;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.htrace.Span;
import org.apache.htrace.Trace;
import org.apache.htrace.TraceScope;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -2675,10 +2678,19 @@ public static Class<? extends FileSystem> getFileSystemClass(String scheme,
private static FileSystem createFileSystem(URI uri, Configuration conf private static FileSystem createFileSystem(URI uri, Configuration conf
) throws IOException { ) throws IOException {
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf); TraceScope scope = Trace.startSpan("FileSystem#createFileSystem");
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf); Span span = scope.getSpan();
fs.initialize(uri, conf); if (span != null) {
return fs; span.addKVAnnotation("scheme", uri.getScheme());
}
try {
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf);
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
fs.initialize(uri, conf);
return fs;
} finally {
scope.close();
}
} }
/** Caching FileSystem objects */ /** Caching FileSystem objects */

View File

@ -28,6 +28,10 @@
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.htrace.Span;
import org.apache.htrace.Trace;
import org.apache.htrace.TraceScope;
@InterfaceAudience.Private @InterfaceAudience.Private
@InterfaceStability.Unstable @InterfaceStability.Unstable
class Globber { class Globber {
@ -136,6 +140,19 @@ private String authorityFromPath(Path path) throws IOException {
} }
public FileStatus[] glob() throws IOException { public FileStatus[] glob() throws IOException {
TraceScope scope = Trace.startSpan("Globber#glob");
Span span = scope.getSpan();
if (span != null) {
span.addKVAnnotation("pattern", pathPattern.toUri().getPath());
}
try {
return doGlob();
} finally {
scope.close();
}
}
private FileStatus[] doGlob() throws IOException {
// First we get the scheme and authority of the pattern that was passed // First we get the scheme and authority of the pattern that was passed
// in. // in.
String scheme = schemeFromPath(pathPattern); String scheme = schemeFromPath(pathPattern);