From 24e146f07d60c1a51498531ff2a846d9e97409d4 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 8 Jul 2009 23:11:20 +0000 Subject: [PATCH] added a little analyzer to inspect the traffic git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19541 71c3de6d-444a-0410-be80-ed276b4c234a --- .../remoting/RemoteInvocationHandler.java | 4 ++ remoting/src/test/java/TrafficAnalyzer.java | 11 +++++ .../java/hudson/remoting/TrafficAnalyzer.java | 43 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 remoting/src/test/java/TrafficAnalyzer.java create mode 100644 remoting/src/test/java/hudson/remoting/TrafficAnalyzer.java diff --git a/remoting/src/main/java/hudson/remoting/RemoteInvocationHandler.java b/remoting/src/main/java/hudson/remoting/RemoteInvocationHandler.java index fa8c9a456f..1b6b612a86 100644 --- a/remoting/src/main/java/hudson/remoting/RemoteInvocationHandler.java +++ b/remoting/src/main/java/hudson/remoting/RemoteInvocationHandler.java @@ -291,6 +291,10 @@ final class RemoteInvocationHandler implements InvocationHandler, Serializable { return null; } + Object[] getArguments() { // for debugging + return arguments; + } + public String toString() { return "RPCRequest("+oid+","+methodName+")"; } diff --git a/remoting/src/test/java/TrafficAnalyzer.java b/remoting/src/test/java/TrafficAnalyzer.java new file mode 100644 index 0000000000..c2f854fc14 --- /dev/null +++ b/remoting/src/test/java/TrafficAnalyzer.java @@ -0,0 +1,11 @@ +/** + * See {@link hudson.remoting.TrafficAnalyzer}. This entry point makes it easier to + * invoke the tool. + * + * @author Kohsuke Kawaguchi + */ +public class TrafficAnalyzer { + public static void main(String[] args) throws Exception { + hudson.remoting.TrafficAnalyzer.main(args); + } +} diff --git a/remoting/src/test/java/hudson/remoting/TrafficAnalyzer.java b/remoting/src/test/java/hudson/remoting/TrafficAnalyzer.java new file mode 100644 index 0000000000..56efd180fd --- /dev/null +++ b/remoting/src/test/java/hudson/remoting/TrafficAnalyzer.java @@ -0,0 +1,43 @@ +package hudson.remoting; + +import hudson.remoting.RemoteInvocationHandler.RPCRequest; + +import java.io.File; +import java.io.FileInputStream; +import java.io.DataInputStream; +import java.io.ObjectInputStream; + +/** + * A little forensic analysis tool to figure out what information master and slaves are exchanging. + * + *

+ * Use the tee command or network packet capturing tool to capture the traffic between the master and + * the slave, then run it through this tool to get the dump of what commands are sent between them. + * + * @author Kohsuke Kawaguchi + */ +public class TrafficAnalyzer { + public static void main(String[] args) throws Exception { + File f = new File("/home/kohsuke/ws/hudson/investigations/javafx-windows-hang/out.log"); + DataInputStream fin = new DataInputStream(new FileInputStream(f)); + fin.readFully(new byte[4]); // skip preamble + ObjectInputStream ois = new ObjectInputStream(fin); + for (int n=0; ; n++) { + Command o = (Command)ois.readObject(); + System.out.println("#"+n+" : "+o); + if (o instanceof RPCRequest) { + RPCRequest request = (RPCRequest) o; + System.out.print(" ("); + boolean first=true; + for (Object argument : request.getArguments()) { + if(first) first=false; + else System.out.print(","); + System.out.print(argument); + } + System.out.println(")"); + } + if (o.createdAt!=null) + o.createdAt.printStackTrace(System.out); + } + } +}