Last active
August 29, 2015 14:02
-
-
Save winse/161f6fe9120f2ec6b024 to your computer and use it in GitHub Desktop.
查找hive-0.12.0的filesystem问题的btrace的类。[HIVE-4501](https://issues.apache.org/jira/browse/HIVE-4501)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.winse.btrace; | |
/* BTrace Script Template */ | |
import static com.sun.btrace.BTraceUtils.jstack; | |
import static com.sun.btrace.BTraceUtils.name; | |
import static com.sun.btrace.BTraceUtils.print; | |
import static com.sun.btrace.BTraceUtils.printArray; | |
import static com.sun.btrace.BTraceUtils.println; | |
import static com.sun.btrace.BTraceUtils.probeClass; | |
import static com.sun.btrace.BTraceUtils.probeMethod; | |
import static com.sun.btrace.BTraceUtils.str; | |
import static com.sun.btrace.BTraceUtils.strcat; | |
import static com.sun.btrace.BTraceUtils.timeMillis; | |
import java.net.URI; | |
import com.sun.btrace.AnyType; | |
import com.sun.btrace.annotations.BTrace; | |
import com.sun.btrace.annotations.Kind; | |
import com.sun.btrace.annotations.Location; | |
import com.sun.btrace.annotations.OnMethod; | |
import com.sun.btrace.annotations.ProbeClassName; | |
import com.sun.btrace.annotations.ProbeMethodName; | |
import com.sun.btrace.annotations.Self; | |
import com.sun.btrace.annotations.TLS; | |
@BTrace | |
public class TracingFileSystemCache { | |
// donot use $, regex | |
private final static String CLAZZ = "/org.apache.hadoop.fs.FileSystem.Cache/"; | |
private final static String METHOD = "/getInternal/"; | |
private final static int LINE = 2467; | |
// ******************************************* | |
// Exec time | |
// **************** | |
/* | |
@TLS | |
private static long startTime = 0; | |
@OnMethod(clazz = CLAZZ, method = METHOD) | |
public static void startMethod() { | |
startTime = timeMillis(); | |
} | |
@OnMethod(clazz = CLAZZ, method = METHOD, location = @Location(Kind.RETURN)) | |
public static void endMethod() { | |
println("监控指定函数耗时->"); | |
print(strcat(strcat(name(probeClass()), "."), probeMethod())); | |
print(" ["); | |
print(strcat("Time token : ", str(timeMillis() - startTime))); | |
println("]"); | |
} | |
*/ | |
// ******************************************* | |
// Line Info | |
// **************** | |
/** | |
* 行所在的方法名 | |
*/ | |
@OnMethod(clazz = CLAZZ, location = @Location(value = Kind.LINE, line = LINE)) | |
public static void online(@ProbeClassName String pcn, @ProbeMethodName String pmn, int line) { | |
println(""); | |
print("invoke at method ->"); | |
print(strcat(pcn, ".")); | |
print(strcat(pmn, ":")); | |
println(line); | |
println(""); | |
} | |
@OnMethod(clazz = CLAZZ, location = @Location(value = Kind.LINE, line = LINE)) | |
public static void printStack(@ProbeClassName String pcn, @ProbeMethodName String pmn, int line) { | |
println(""); | |
println("jstack: "); | |
jstack(); | |
println(""); | |
} | |
// ******************************************* | |
// Parameters Info | |
// **************** | |
@OnMethod(clazz = CLAZZ, method = METHOD) | |
public static void func(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType[] args) { | |
println(""); | |
print("parameters ->"); | |
print(pcn); | |
print("."); | |
print(pmn); | |
println(""); | |
// printArray(args); | |
println(str(args[0])); | |
println(str(args[1])); | |
println(str(args[2])); | |
println(""); | |
} | |
/* | |
@OnMethod(clazz = CLAZZ, method = METHOD) | |
public static void onNewFileInputStream(@Self Object self, URI uri, Configuration conf, Object key) { | |
print(key.toString()); | |
} | |
*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jps -m | |
bin/btrace 14915 TracingFileSystemCache.java > fs.log | |
grep 'org.apache.hadoop.fs.FileSystem$Cache$Key' fs.log | sort -u | wc -l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment