[jboss-cvs] JBoss Profiler SVN: r546 - in branches/JBossProfiler2: src/main/org/jboss/profiler/client and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 2 16:51:06 EDT 2009
Author: jesper.pedersen
Date: 2009-06-02 16:51:06 -0400 (Tue, 02 Jun 2009)
New Revision: 546
Modified:
branches/JBossProfiler2/doc/userguide/en/modules/client.xml
branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
Log:
[JBPROFILER-79] Add optional directory name to the load command
Modified: branches/JBossProfiler2/doc/userguide/en/modules/client.xml
===================================================================
--- branches/JBossProfiler2/doc/userguide/en/modules/client.xml 2009-06-02 20:14:40 UTC (rev 545)
+++ branches/JBossProfiler2/doc/userguide/en/modules/client.xml 2009-06-02 20:51:06 UTC (rev 546)
@@ -55,20 +55,30 @@
<section id="snapshotcmd">
<title>snapshot</title>
- <para>Take a snapshot.</para>
+ <para>Take a snapshot. An optional argument will generate the reports in the
+ specified directory.</para>
<programlisting>
java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
-jar jboss-profiler-client.jar snapshot
</programlisting>
+ <programlisting>
+java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
+ -jar jboss-profiler-client.jar snapshot reports
+ </programlisting>
</section>
<section id="getsnapshotcmd">
<title>getSnapshot</title>
- <para>Get a snapshot.</para>
+ <para>Get a snapshot. An optional second argument will generate the reports in the
+ specified directory.</para>
<programlisting>
java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
-jar jboss-profiler-client.jar getSnapshot 1
</programlisting>
+ <programlisting>
+java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
+ -jar jboss-profiler-client.jar getSnapshot 1 reports
+ </programlisting>
</section>
<section id="listsnapshotscmd">
@@ -119,7 +129,8 @@
<section id="loadcmd">
<title>load</title>
<para>Load a snapshot from either a file or a directory. This command will generate
- all the reports.</para>
+ all the reports. An optional second argument will generate the reports in the
+ specified directory.</para>
<programlisting>
java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
-jar jboss-profiler-client.jar load 20070806144635343-20070806144638444.jps
@@ -128,6 +139,10 @@
java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
-jar jboss-profiler-client.jar load 20070806144635343/
</programlisting>
+ <programlisting>
+java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties \
+ -jar jboss-profiler-client.jar load 20070806144635343-20070806144638444.jps reports
+ </programlisting>
</section>
<section id="savecmd">
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2009-06-02 20:14:40 UTC (rev 545)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2009-06-02 20:51:06 UTC (rev 546)
@@ -215,11 +215,8 @@
*/
public void dump(Snapshot snapshot, File d) throws Exception {
if (snapshot != null) {
- File dir = new File(d, SnapshotHelper.getName(snapshot));
- dir.mkdirs();
+ String directory = d.getPath() + File.separator;
- String directory = dir.getPath() + File.separator;
-
dumpThreads(snapshot.getMethodRepository(), snapshot.getThreads(), directory);
Map<String, List<CombinedFrameInfo>> info = getInformation(snapshot);
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java 2009-06-02 20:14:40 UTC (rev 545)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java 2009-06-02 20:51:06 UTC (rev 546)
@@ -136,15 +136,16 @@
port = Integer.valueOf(properties.getProperty("port", "5400"));
threshold = Double.valueOf(properties.getProperty("threshold", "1.0"));
saveLocation = properties.getProperty("savelocation", ".");
- if (!saveLocation.endsWith(File.separator)) {
- saveLocation += File.separator;
- }
List<Plugin> plugins = PluginHelper.load(properties);
if (plugins.size() > 0) {
Util.setPlugins(plugins);
}
}
+ if (!saveLocation.endsWith(File.separator)) {
+ saveLocation += File.separator;
+ }
+
int i = 0;
if ("-h".equalsIgnoreCase(args[i])) {
@@ -168,12 +169,24 @@
} else if (cmdStr.equalsIgnoreCase("stopProfiler")) {
cmd = new Command(CommandType.STOP_PROFILER);
} else if (cmdStr.equalsIgnoreCase("snapshot")) {
- cmd = new Command(CommandType.SNAPSHOT);
+ String output = null;
+ if (i < args.length) {
+ output = args[i];
+ i++;
+ }
+ cmd = new Command(CommandType.SNAPSHOT, new Object[] {output});
} else if (cmdStr.equalsIgnoreCase("getSnapshot")) {
+ Integer number = null;
+ String output = null;
if (i < args.length) {
- cmd = new Command(CommandType.GET_SNAPSHOT, new Object[] {Integer.valueOf(args[i]) });
+ number = Integer.valueOf(args[i]);
i++;
}
+ if (i < args.length) {
+ output = args[i];
+ i++;
+ }
+ cmd = new Command(CommandType.GET_SNAPSHOT, new Object[] {number, output});
} else if (cmdStr.equalsIgnoreCase("listSnapshots")) {
cmd = new Command(CommandType.LIST_SNAPSHOTS);
} else if (cmdStr.equalsIgnoreCase("clearSnapshots")) {
@@ -185,10 +198,17 @@
} else if (cmdStr.equalsIgnoreCase("disable")) {
cmd = new Command(CommandType.DISABLE);
} else if (cmdStr.equalsIgnoreCase("load")) {
+ String input = null;
+ String output = null;
if (i < args.length) {
- cmd = new Command(CommandType.LOAD, new Object[] {args[i]});
+ input = args[i];
i++;
}
+ if (i < args.length) {
+ output = args[i];
+ i++;
+ }
+ cmd = new Command(CommandType.LOAD, new Object[] {input, output});
} else if (cmdStr.equalsIgnoreCase("save")) {
Integer number = null;
String filename = null;
@@ -259,14 +279,40 @@
cmd.getCommand() == CommandType.ADD_CLASSES ||
cmd.getCommand() == CommandType.REMOVE_CLASSES) {
String response = (String)remotingClient.invoke(cmd);
- } else if (cmd.getCommand() == CommandType.SNAPSHOT ||
- cmd.getCommand() == CommandType.GET_SNAPSHOT) {
+ } else if (cmd.getCommand() == CommandType.SNAPSHOT) {
Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
if (snapshot != null) {
- File f = new File(".");
+ String dir = null;
+
+ if (cmd.getArguments()[0] == null) {
+ dir = saveLocation + SnapshotHelper.getName(snapshot);
+ } else {
+ dir = (String)cmd.getArguments()[0];
+ }
+
+ File d = new File(dir);
+ d.mkdirs();
+
SnapshotUtil su = new SnapshotUtil(threshold);
- su.dump(snapshot, f);
+ su.dump(snapshot, d);
}
+ } else if (cmd.getCommand() == CommandType.GET_SNAPSHOT) {
+ Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
+ if (snapshot != null) {
+ String dir = null;
+
+ if (cmd.getArguments()[1] == null) {
+ dir = saveLocation + SnapshotHelper.getName(snapshot);
+ } else {
+ dir = (String)cmd.getArguments()[1];
+ }
+
+ File d = new File(dir);
+ d.mkdirs();
+
+ SnapshotUtil su = new SnapshotUtil(threshold);
+ su.dump(snapshot, d);
+ }
} else if (cmd.getCommand() == CommandType.LIST_SNAPSHOTS ||
cmd.getCommand() == CommandType.LIST_CLASSES) {
String[] result = (String[])remotingClient.invoke(cmd);
@@ -287,9 +333,19 @@
}
if (snapshot != null) {
- File f = new File(".");
+ String dir = null;
+
+ if (cmd.getArguments()[1] == null) {
+ dir = saveLocation + SnapshotHelper.getName(snapshot);
+ } else {
+ dir = (String)cmd.getArguments()[1];
+ }
+
+ File d = new File(dir);
+ d.mkdirs();
+
SnapshotUtil su = new SnapshotUtil(threshold);
- su.dump(snapshot, f);
+ su.dump(snapshot, d);
}
}
} else if (cmd.getCommand() == CommandType.SAVE) {
@@ -336,7 +392,7 @@
if (os != null && ns != null) {
DifferenceUtil du = new DifferenceUtil(threshold);
- File f = new File(".");
+ File f = new File(saveLocation);
du.dump(os, ns, f);
}
}
More information about the jboss-cvs-commits
mailing list