mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
vmtool support limit option. #1781
This commit is contained in:
@@ -47,6 +47,8 @@ import arthas.VmTool;
|
||||
@Description(Constants.EXAMPLE
|
||||
+ " vmtool --action getInstances --className demo.MathGame\n"
|
||||
+ " vmtool --action getInstances --className demo.MathGame --express 'instances.length'\n"
|
||||
+ " vmtool --action getInstances --className demo.MathGame --express 'instances[0]'\n"
|
||||
+ " vmtool --action getInstances --className java.lang.String --limit 10\n"
|
||||
+ " vmtool --action forceGc\n"
|
||||
+ Constants.WIKI + Constants.WIKI_HOME + "vmtool")
|
||||
//@formatter:on
|
||||
@@ -64,6 +66,11 @@ public class VmToolCommand extends AnnotatedCommand {
|
||||
*/
|
||||
private int expand;
|
||||
|
||||
/**
|
||||
* default value 10
|
||||
*/
|
||||
private int limit;
|
||||
|
||||
private static String libPath;
|
||||
private static VmTool vmTool = null;
|
||||
|
||||
@@ -117,6 +124,13 @@ public class VmToolCommand extends AnnotatedCommand {
|
||||
this.classLoaderClass = classLoaderClass;
|
||||
}
|
||||
|
||||
@Option(shortName = "l", longName = "limit")
|
||||
@Description("Set the limit value of the getInstances action, default value is 10, set to -1 is unlimited")
|
||||
@DefaultValue("10")
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
@Option(longName = "express", required = false)
|
||||
@Description("The ognl expression, default valueis `instances`.")
|
||||
public void setExpress(String express) {
|
||||
@@ -165,7 +179,7 @@ public class VmToolCommand extends AnnotatedCommand {
|
||||
process.end(-1, "Found more than one class: " + matchedClasses + ".");
|
||||
return;
|
||||
} else {
|
||||
Object[] instances = vmToolInstance().getInstances(matchedClasses.get(0));
|
||||
Object[] instances = vmToolInstance().getInstances(matchedClasses.get(0), limit);
|
||||
Object value = instances;
|
||||
if (express != null) {
|
||||
Express unpooledExpress = ExpressFactory.unpooledExpress(classLoader);
|
||||
|
||||
Reference in New Issue
Block a user