mirror of https://github.com/alibaba/arthas.git
Transform commands of pkg klass100 (#1285)
parent
afc5183321
commit
4a48a7b073
@ -0,0 +1,163 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* Class detail VO
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class ClassDetailVO extends ClassVO {
|
||||
|
||||
private String classInfo;
|
||||
private String codeSource;
|
||||
private boolean isInterface;
|
||||
private boolean isAnnotation;
|
||||
private boolean isEnum;
|
||||
private boolean isAnonymousClass;
|
||||
private boolean isArray;
|
||||
private boolean isLocalClass;
|
||||
private boolean isMemberClass;
|
||||
private boolean isPrimitive;
|
||||
private boolean isSynthetic;
|
||||
private String simpleName;
|
||||
private String modifier;
|
||||
private String[] annotations;
|
||||
private String[] interfaces;
|
||||
private String[] superClass;
|
||||
private FieldVO[] fields;
|
||||
|
||||
public String getClassInfo() {
|
||||
return classInfo;
|
||||
}
|
||||
|
||||
public void setClassInfo(String classInfo) {
|
||||
this.classInfo = classInfo;
|
||||
}
|
||||
|
||||
public String getCodeSource() {
|
||||
return codeSource;
|
||||
}
|
||||
|
||||
public void setCodeSource(String codeSource) {
|
||||
this.codeSource = codeSource;
|
||||
}
|
||||
|
||||
public boolean isInterface() {
|
||||
return isInterface;
|
||||
}
|
||||
|
||||
public void setInterface(boolean anInterface) {
|
||||
isInterface = anInterface;
|
||||
}
|
||||
|
||||
public boolean isAnnotation() {
|
||||
return isAnnotation;
|
||||
}
|
||||
|
||||
public void setAnnotation(boolean annotation) {
|
||||
isAnnotation = annotation;
|
||||
}
|
||||
|
||||
public boolean isEnum() {
|
||||
return isEnum;
|
||||
}
|
||||
|
||||
public void setEnum(boolean anEnum) {
|
||||
isEnum = anEnum;
|
||||
}
|
||||
|
||||
public boolean isAnonymousClass() {
|
||||
return isAnonymousClass;
|
||||
}
|
||||
|
||||
public void setAnonymousClass(boolean anonymousClass) {
|
||||
isAnonymousClass = anonymousClass;
|
||||
}
|
||||
|
||||
public boolean isArray() {
|
||||
return isArray;
|
||||
}
|
||||
|
||||
public void setArray(boolean array) {
|
||||
isArray = array;
|
||||
}
|
||||
|
||||
public boolean isLocalClass() {
|
||||
return isLocalClass;
|
||||
}
|
||||
|
||||
public void setLocalClass(boolean localClass) {
|
||||
isLocalClass = localClass;
|
||||
}
|
||||
|
||||
public boolean isMemberClass() {
|
||||
return isMemberClass;
|
||||
}
|
||||
|
||||
public void setMemberClass(boolean memberClass) {
|
||||
isMemberClass = memberClass;
|
||||
}
|
||||
|
||||
public boolean isPrimitive() {
|
||||
return isPrimitive;
|
||||
}
|
||||
|
||||
public void setPrimitive(boolean primitive) {
|
||||
isPrimitive = primitive;
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return isSynthetic;
|
||||
}
|
||||
|
||||
public void setSynthetic(boolean synthetic) {
|
||||
isSynthetic = synthetic;
|
||||
}
|
||||
|
||||
public String getSimpleName() {
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
public void setSimpleName(String simpleName) {
|
||||
this.simpleName = simpleName;
|
||||
}
|
||||
|
||||
public String getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(String modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public String[] getAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
public void setAnnotations(String[] annotations) {
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
public String[] getInterfaces() {
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
public void setInterfaces(String[] interfaces) {
|
||||
this.interfaces = interfaces;
|
||||
}
|
||||
|
||||
public String[] getSuperClass() {
|
||||
return superClass;
|
||||
}
|
||||
|
||||
public void setSuperClass(String[] superClass) {
|
||||
this.superClass = superClass;
|
||||
}
|
||||
|
||||
public FieldVO[] getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(FieldVO[] fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import com.taobao.arthas.core.command.klass100.ClassLoaderCommand.ClassLoaderStat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class ClassLoaderModel extends ResultModel {
|
||||
|
||||
private ClassSetVO classSet;
|
||||
private List<String> resources;
|
||||
private ClassDetailVO loadClass;
|
||||
private List<String> urls;
|
||||
//classloader -l -t
|
||||
private List<ClassLoaderVO> classLoaders;
|
||||
private Boolean tree;
|
||||
|
||||
private Map<String, ClassLoaderStat> classLoaderStats;
|
||||
|
||||
public ClassLoaderModel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "classloader";
|
||||
}
|
||||
|
||||
public ClassSetVO getClassSet() {
|
||||
return classSet;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setClassSet(ClassSetVO classSet) {
|
||||
this.classSet = classSet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setResources(List<String> resources) {
|
||||
this.resources = resources;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClassDetailVO getLoadClass() {
|
||||
return loadClass;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setLoadClass(ClassDetailVO loadClass) {
|
||||
this.loadClass = loadClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setUrls(List<String> urls) {
|
||||
this.urls = urls;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ClassLoaderVO> getClassLoaders() {
|
||||
return classLoaders;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setClassLoaders(List<ClassLoaderVO> classLoaders) {
|
||||
this.classLoaders = classLoaders;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getTree() {
|
||||
return tree;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setTree(Boolean tree) {
|
||||
this.tree = tree;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, ClassLoaderStat> getClassLoaderStats() {
|
||||
return classLoaderStats;
|
||||
}
|
||||
|
||||
public ClassLoaderModel setClassLoaderStats(Map<String, ClassLoaderStat> classLoaderStats) {
|
||||
this.classLoaderStats = classLoaderStats;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class ClassLoaderVO {
|
||||
private String name;
|
||||
private String hash;
|
||||
private String parent;
|
||||
private Integer loadedCount;
|
||||
private Integer numberOfInstances;
|
||||
private List<ClassLoaderVO> children;
|
||||
|
||||
public ClassLoaderVO() {
|
||||
}
|
||||
|
||||
public void addChild(ClassLoaderVO child){
|
||||
if (this.children == null){
|
||||
this.children = new ArrayList<ClassLoaderVO>();
|
||||
}
|
||||
this.children.add(child);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(String parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Integer getLoadedCount() {
|
||||
return loadedCount;
|
||||
}
|
||||
|
||||
public void setLoadedCount(Integer loadedCount) {
|
||||
this.loadedCount = loadedCount;
|
||||
}
|
||||
|
||||
public Integer getNumberOfInstances() {
|
||||
return numberOfInstances;
|
||||
}
|
||||
|
||||
public void setNumberOfInstances(Integer numberOfInstances) {
|
||||
this.numberOfInstances = numberOfInstances;
|
||||
}
|
||||
|
||||
public List<ClassLoaderVO> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ClassLoaderVO> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class ClassSetVO implements Countable {
|
||||
private ClassLoaderVO classloader;
|
||||
private Collection<String> classes;
|
||||
private int segment;
|
||||
|
||||
public ClassSetVO(ClassLoaderVO classloader, Collection<String> classes) {
|
||||
this(classloader, classes, 0);
|
||||
}
|
||||
|
||||
public ClassSetVO(ClassLoaderVO classloader, Collection<String> classes, int segment) {
|
||||
this.classloader = classloader;
|
||||
this.classes = classes;
|
||||
this.segment = segment;
|
||||
}
|
||||
|
||||
public ClassLoaderVO getClassloader() {
|
||||
return classloader;
|
||||
}
|
||||
|
||||
public void setClassloader(ClassLoaderVO classloader) {
|
||||
this.classloader = classloader;
|
||||
}
|
||||
|
||||
public Collection<String> getClasses() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
public void setClasses(Collection<String> classes) {
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
public int getSegment() {
|
||||
return segment;
|
||||
}
|
||||
|
||||
public void setSegment(int segment) {
|
||||
this.segment = segment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return classes != null ? classes.size() : 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class ClassVO {
|
||||
|
||||
private String name;
|
||||
private String[] classloader;
|
||||
private String classLoaderHash;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String[] getClassloader() {
|
||||
return classloader;
|
||||
}
|
||||
|
||||
public void setClassloader(String[] classloader) {
|
||||
this.classloader = classloader;
|
||||
}
|
||||
|
||||
public String getClassLoaderHash() {
|
||||
return classLoaderHash;
|
||||
}
|
||||
|
||||
public void setClassLoaderHash(String classLoaderHash) {
|
||||
this.classLoaderHash = classLoaderHash;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class DumpClassModel extends ResultModel {
|
||||
|
||||
private List<DumpClassVO> dumpedClasses;
|
||||
|
||||
private Collection<ClassVO> matchedClasses;
|
||||
|
||||
public DumpClassModel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "dump";
|
||||
}
|
||||
|
||||
public List<DumpClassVO> getDumpedClasses() {
|
||||
return dumpedClasses;
|
||||
}
|
||||
|
||||
public DumpClassModel setDumpedClasses(List<DumpClassVO> dumpedClasses) {
|
||||
this.dumpedClasses = dumpedClasses;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Collection<ClassVO> getMatchedClasses() {
|
||||
return matchedClasses;
|
||||
}
|
||||
|
||||
public DumpClassModel setMatchedClasses(Collection<ClassVO> matchedClasses) {
|
||||
this.matchedClasses = matchedClasses;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* Dumped class VO
|
||||
* @author gongdewei 2020/7/9
|
||||
*/
|
||||
public class DumpClassVO extends ClassVO {
|
||||
private String location;
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class FieldVO {
|
||||
private String name;
|
||||
private String type;
|
||||
private String modifier;
|
||||
private String[] annotations;
|
||||
private Object value;
|
||||
private boolean isStatic;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(String modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String[] getAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
public void setAnnotations(String[] annotations) {
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
public void setStatic(boolean aStatic) {
|
||||
isStatic = aStatic;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/20
|
||||
*/
|
||||
public class GetStaticModel extends ResultModel {
|
||||
|
||||
private ObjectVO field;
|
||||
private Collection<ClassVO> matchedClasses;
|
||||
|
||||
//only for view
|
||||
private transient int expand;
|
||||
|
||||
public GetStaticModel() {
|
||||
}
|
||||
|
||||
public GetStaticModel(String fieldName, Object fieldValue, int expand) {
|
||||
this.field = new ObjectVO(fieldName, fieldValue);
|
||||
this.expand = expand;
|
||||
}
|
||||
|
||||
public GetStaticModel(Collection<ClassVO> matchedClasses) {
|
||||
this.matchedClasses = matchedClasses;
|
||||
}
|
||||
|
||||
public ObjectVO getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(ObjectVO field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public Collection<ClassVO> getMatchedClasses() {
|
||||
return matchedClasses;
|
||||
}
|
||||
|
||||
public void setMatchedClasses(Collection<ClassVO> matchedClasses) {
|
||||
this.matchedClasses = matchedClasses;
|
||||
}
|
||||
|
||||
public int expand() {
|
||||
return expand;
|
||||
}
|
||||
|
||||
public void setExpand(int expand) {
|
||||
this.expand = expand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "getstatic";
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/22
|
||||
*/
|
||||
public class JadModel extends ResultModel {
|
||||
private ClassVO classInfo;
|
||||
private String location;
|
||||
private String source;
|
||||
|
||||
//match multiple classes
|
||||
private Collection<ClassVO> matchedClasses;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "jad";
|
||||
}
|
||||
|
||||
public JadModel() {
|
||||
}
|
||||
|
||||
public ClassVO getClassInfo() {
|
||||
return classInfo;
|
||||
}
|
||||
|
||||
public void setClassInfo(ClassVO classInfo) {
|
||||
this.classInfo = classInfo;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Collection<ClassVO> getMatchedClasses() {
|
||||
return matchedClasses;
|
||||
}
|
||||
|
||||
public void setMatchedClasses(Collection<ClassVO> matchedClasses) {
|
||||
this.matchedClasses = matchedClasses;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/20
|
||||
*/
|
||||
public class MemoryCompilerModel extends ResultModel {
|
||||
|
||||
private List<String> files;
|
||||
|
||||
public MemoryCompilerModel() {
|
||||
}
|
||||
|
||||
public MemoryCompilerModel(List<String> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public void setFiles(List<String> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public List<String> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "mc";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* Method or Constructor VO
|
||||
* @author gongdewei 2020/4/9
|
||||
*/
|
||||
public class MethodVO {
|
||||
|
||||
private String declaringClass;
|
||||
private String methodName;
|
||||
private String modifier;
|
||||
private String[] annotations;
|
||||
private String[] parameters;
|
||||
private String returnType;
|
||||
private String[] exceptions;
|
||||
private String classLoaderHash;
|
||||
private String descriptor;
|
||||
private boolean constructor;
|
||||
|
||||
public String getDeclaringClass() {
|
||||
return declaringClass;
|
||||
}
|
||||
|
||||
public void setDeclaringClass(String declaringClass) {
|
||||
this.declaringClass = declaringClass;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public String getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(String modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public String[] getAnnotations() {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
public void setAnnotations(String[] annotations) {
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
public String[] getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(String[] parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public String getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public void setReturnType(String returnType) {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
public String[] getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
public void setExceptions(String[] exceptions) {
|
||||
this.exceptions = exceptions;
|
||||
}
|
||||
|
||||
public String getClassLoaderHash() {
|
||||
return classLoaderHash;
|
||||
}
|
||||
|
||||
public void setClassLoaderHash(String classLoaderHash) {
|
||||
this.classLoaderHash = classLoaderHash;
|
||||
}
|
||||
|
||||
public boolean isConstructor() {
|
||||
return constructor;
|
||||
}
|
||||
|
||||
public void setConstructor(boolean constructor) {
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
||||
public String getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public void setDescriptor(String descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/29
|
||||
*/
|
||||
public class ObjectVO {
|
||||
private String name;
|
||||
private Object value;
|
||||
|
||||
public ObjectVO(String name, Object value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ObjectVO(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/29
|
||||
*/
|
||||
public class OgnlModel extends ResultModel {
|
||||
private Object value;
|
||||
private int expand = 1;
|
||||
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "ognl";
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public OgnlModel setValue(Object value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getExpand() {
|
||||
return expand;
|
||||
}
|
||||
|
||||
public OgnlModel setExpand(int expand) {
|
||||
this.expand = expand;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/16
|
||||
*/
|
||||
public class RedefineModel extends ResultModel {
|
||||
|
||||
private int redefinitionCount;
|
||||
|
||||
private List<String> redefinedClasses;
|
||||
|
||||
public RedefineModel() {
|
||||
redefinedClasses = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public void addRedefineClass(String className) {
|
||||
redefinedClasses.add(className);
|
||||
redefinitionCount++;
|
||||
}
|
||||
|
||||
public int getRedefinitionCount() {
|
||||
return redefinitionCount;
|
||||
}
|
||||
|
||||
public void setRedefinitionCount(int redefinitionCount) {
|
||||
this.redefinitionCount = redefinitionCount;
|
||||
}
|
||||
|
||||
public List<String> getRedefinedClasses() {
|
||||
return redefinedClasses;
|
||||
}
|
||||
|
||||
public void setRedefinedClasses(List<String> redefinedClasses) {
|
||||
this.redefinedClasses = redefinedClasses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "redefine";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
import com.taobao.arthas.core.util.affect.RowAffect;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class RowAffectModel extends ResultModel {
|
||||
private RowAffect affect;
|
||||
|
||||
public RowAffectModel() {
|
||||
}
|
||||
|
||||
public RowAffectModel(RowAffect affect) {
|
||||
this.affect = affect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "row_affect";
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return affect.rCnt();
|
||||
}
|
||||
|
||||
public RowAffect affect() {
|
||||
return affect;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class info of SearchClassCommand
|
||||
* @author gongdewei 2020/04/08
|
||||
*/
|
||||
public class SearchClassModel extends ResultModel {
|
||||
private ClassDetailVO classInfo;
|
||||
private boolean withField;
|
||||
private boolean detailed;
|
||||
private Integer expand;
|
||||
private List<String> classNames;
|
||||
private int segment;
|
||||
|
||||
public SearchClassModel() {
|
||||
}
|
||||
|
||||
public SearchClassModel(ClassDetailVO classInfo, boolean detailed, boolean withField, Integer expand) {
|
||||
this.classInfo = classInfo;
|
||||
this.detailed = detailed;
|
||||
this.withField = withField;
|
||||
this.expand = expand;
|
||||
}
|
||||
|
||||
public SearchClassModel(List<String> classNames, int segment) {
|
||||
this.classNames = classNames;
|
||||
this.segment = segment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "sc";
|
||||
}
|
||||
|
||||
public ClassDetailVO getClassInfo() {
|
||||
return classInfo;
|
||||
}
|
||||
|
||||
public void setClassInfo(ClassDetailVO classInfo) {
|
||||
this.classInfo = classInfo;
|
||||
}
|
||||
|
||||
public List<String> getClassNames() {
|
||||
return classNames;
|
||||
}
|
||||
|
||||
public void setClassNames(List<String> classNames) {
|
||||
this.classNames = classNames;
|
||||
}
|
||||
|
||||
public int getSegment() {
|
||||
return segment;
|
||||
}
|
||||
|
||||
public void setSegment(int segment) {
|
||||
this.segment = segment;
|
||||
}
|
||||
|
||||
public boolean isDetailed() {
|
||||
return detailed;
|
||||
}
|
||||
|
||||
public boolean isWithField() {
|
||||
return withField;
|
||||
}
|
||||
|
||||
public Integer getExpand() {
|
||||
return expand;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
|
||||
/**
|
||||
* Model of SearchMethodCommand
|
||||
* @author gongdewei 2020/4/9
|
||||
*/
|
||||
public class SearchMethodModel extends ResultModel {
|
||||
private MethodVO methodInfo;
|
||||
private boolean detail;
|
||||
|
||||
public SearchMethodModel() {
|
||||
}
|
||||
|
||||
public SearchMethodModel(MethodVO methodInfo, boolean detail) {
|
||||
this.methodInfo = methodInfo;
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
public MethodVO getMethodInfo() {
|
||||
return methodInfo;
|
||||
}
|
||||
|
||||
public void setMethodInfo(MethodVO methodInfo) {
|
||||
this.methodInfo = methodInfo;
|
||||
}
|
||||
|
||||
public boolean isDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
public void setDetail(boolean detail) {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "sm";
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.klass100.ClassLoaderCommand.ClassLoaderStat;
|
||||
import com.taobao.arthas.core.command.model.ClassDetailVO;
|
||||
import com.taobao.arthas.core.command.model.ClassLoaderModel;
|
||||
import com.taobao.arthas.core.command.model.ClassLoaderVO;
|
||||
import com.taobao.arthas.core.command.model.ClassSetVO;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.text.Decoration;
|
||||
import com.taobao.text.ui.*;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class ClassLoaderView extends ResultView<ClassLoaderModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, ClassLoaderModel result) {
|
||||
if (result.getClassSet() != null) {
|
||||
drawAllClasses(process, result.getClassSet());
|
||||
}
|
||||
if (result.getResources() != null) {
|
||||
drawResources(process, result.getResources());
|
||||
}
|
||||
if (result.getLoadClass() != null) {
|
||||
drawLoadClass(process, result.getLoadClass());
|
||||
}
|
||||
if (result.getUrls() != null) {
|
||||
drawClassLoaderUrls(process, result.getUrls());
|
||||
}
|
||||
if (result.getClassLoaders() != null){
|
||||
drawClassLoaders(process, result.getClassLoaders(), result.getTree());
|
||||
}
|
||||
if (result.getClassLoaderStats() != null){
|
||||
drawClassLoaderStats(process, result.getClassLoaderStats());
|
||||
}
|
||||
}
|
||||
|
||||
private void drawClassLoaderStats(CommandProcess process, Map<String, ClassLoaderStat> classLoaderStats) {
|
||||
Element element = renderStat(classLoaderStats);
|
||||
process.write(RenderUtil.render(element, process.width()))
|
||||
.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
|
||||
}
|
||||
|
||||
private static TableElement renderStat(Map<String, ClassLoaderStat> classLoaderStats) {
|
||||
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
|
||||
table.add(new RowElement().style(Decoration.bold.bold()).add("name", "numberOfInstances", "loadedCountTotal"));
|
||||
for (Map.Entry<String, ClassLoaderStat> entry : classLoaderStats.entrySet()) {
|
||||
table.row(entry.getKey(), "" + entry.getValue().getNumberOfInstance(), "" + entry.getValue().getLoadedCount());
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
private void drawClassLoaders(CommandProcess process, List<ClassLoaderVO> classLoaders, Boolean isTree) {
|
||||
Element element = isTree ? renderTree(classLoaders) : renderTable(classLoaders);
|
||||
process.write(RenderUtil.render(element, process.width()))
|
||||
.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
}
|
||||
|
||||
private void drawClassLoaderUrls(CommandProcess process, List<String> urls) {
|
||||
process.write(RenderUtil.render(renderClassLoaderUrls(urls), process.width()));
|
||||
process.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
}
|
||||
|
||||
private void drawLoadClass(CommandProcess process, ClassDetailVO loadClass) {
|
||||
process.write(RenderUtil.render(ClassUtils.renderClassInfo(loadClass), process.width()) + "\n");
|
||||
}
|
||||
|
||||
private void drawAllClasses(CommandProcess process, ClassSetVO classSetVO) {
|
||||
process.write(RenderUtil.render(renderClasses(classSetVO), process.width()));
|
||||
process.write("\n");
|
||||
}
|
||||
|
||||
private void drawResources(CommandProcess process, List<String> resources) {
|
||||
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
|
||||
for (String resource : resources) {
|
||||
table.row(resource);
|
||||
}
|
||||
process.write(RenderUtil.render(table, process.width()) + "\n");
|
||||
process.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
}
|
||||
|
||||
private Element renderClasses(ClassSetVO classSetVO) {
|
||||
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
|
||||
if (classSetVO.getSegment() == 0) {
|
||||
table.row(new LabelElement("hash:" + classSetVO.getClassloader().getHash() + ", " + classSetVO.getClassloader().getName())
|
||||
.style(Decoration.bold.bold()));
|
||||
}
|
||||
for (String className : classSetVO.getClasses()) {
|
||||
table.row(new LabelElement(className));
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
private static Element renderClassLoaderUrls(List<String> urls) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String url : urls) {
|
||||
sb.append(url).append("\n");
|
||||
}
|
||||
return new LabelElement(sb.toString());
|
||||
}
|
||||
|
||||
// 统计所有的ClassLoader的信息
|
||||
private static TableElement renderTable(List<ClassLoaderVO> classLoaderInfos) {
|
||||
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
|
||||
table.add(new RowElement().style(Decoration.bold.bold()).add("name", "loadedCount", "hash", "parent"));
|
||||
for (ClassLoaderVO classLoaderVO : classLoaderInfos) {
|
||||
table.row(classLoaderVO.getName(), "" + classLoaderVO.getLoadedCount(), classLoaderVO.getHash(), classLoaderVO.getParent());
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
// 以树状列出ClassLoader的继承结构
|
||||
private static Element renderTree(List<ClassLoaderVO> classLoaderInfos) {
|
||||
TreeElement root = new TreeElement();
|
||||
for (ClassLoaderVO classLoader : classLoaderInfos) {
|
||||
TreeElement child = new TreeElement(classLoader.getName());
|
||||
root.addChild(child);
|
||||
renderSubtree(child, classLoader);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
private static void renderSubtree(TreeElement parent, ClassLoaderVO parentClassLoader) {
|
||||
if (parentClassLoader.getChildren() == null){
|
||||
return;
|
||||
}
|
||||
for (ClassLoaderVO childClassLoader : parentClassLoader.getChildren()) {
|
||||
TreeElement child = new TreeElement(childClassLoader.getName());
|
||||
parent.addChild(child);
|
||||
renderSubtree(child, childClassLoader);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.DumpClassModel;
|
||||
import com.taobao.arthas.core.command.model.DumpClassVO;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.arthas.core.util.TypeRenderUtils;
|
||||
import com.taobao.text.Color;
|
||||
import com.taobao.text.Decoration;
|
||||
import com.taobao.text.ui.Element;
|
||||
import com.taobao.text.ui.LabelElement;
|
||||
import com.taobao.text.ui.TableElement;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.taobao.text.ui.Element.label;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/21
|
||||
*/
|
||||
public class DumpClassView extends ResultView<DumpClassModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, DumpClassModel result) {
|
||||
if (result.getDumpedClasses() != null) {
|
||||
drawDumpedClasses(process, result.getDumpedClasses());
|
||||
|
||||
} else if (result.getMatchedClasses() != null) {
|
||||
Element table = ClassUtils.renderMatchedClasses(result.getMatchedClasses());
|
||||
process.write(RenderUtil.render(table)).write("\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void drawDumpedClasses(CommandProcess process, List<DumpClassVO> classVOs) {
|
||||
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
|
||||
table.row(new LabelElement("HASHCODE").style(Decoration.bold.bold()),
|
||||
new LabelElement("CLASSLOADER").style(Decoration.bold.bold()),
|
||||
new LabelElement("LOCATION").style(Decoration.bold.bold()));
|
||||
|
||||
for (DumpClassVO clazz : classVOs) {
|
||||
table.row(label(clazz.getClassLoaderHash()).style(Decoration.bold.fg(Color.red)),
|
||||
TypeRenderUtils.drawClassLoader(clazz),
|
||||
label(clazz.getLocation()).style(Decoration.bold.fg(Color.red)));
|
||||
}
|
||||
|
||||
process.write(RenderUtil.render(table, process.width()))
|
||||
.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.GetStaticModel;
|
||||
import com.taobao.arthas.core.command.model.ObjectVO;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.arthas.core.util.StringUtils;
|
||||
import com.taobao.arthas.core.view.ObjectView;
|
||||
import com.taobao.text.ui.Element;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/20
|
||||
*/
|
||||
public class GetStaticView extends ResultView<GetStaticModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, GetStaticModel result) {
|
||||
int expand = result.expand();
|
||||
if (result.getField() != null) {
|
||||
ObjectVO field = result.getField();
|
||||
String valueStr = StringUtils.objectToString(expand >= 0 ? new ObjectView(field.getValue(), expand).draw() : field.getValue());
|
||||
process.write("field: " + field.getName() + "\n" + valueStr + "\n");
|
||||
} else if (result.getMatchedClasses() != null) {
|
||||
Element table = ClassUtils.renderMatchedClasses(result.getMatchedClasses());
|
||||
process.write(RenderUtil.render(table)).write("\n");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.ClassVO;
|
||||
import com.taobao.arthas.core.command.model.JadModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.arthas.core.util.TypeRenderUtils;
|
||||
import com.taobao.text.Color;
|
||||
import com.taobao.text.Decoration;
|
||||
import com.taobao.text.lang.LangRenderUtil;
|
||||
import com.taobao.text.ui.Element;
|
||||
import com.taobao.text.ui.LabelElement;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/22
|
||||
*/
|
||||
public class JadView extends ResultView<JadModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, JadModel result) {
|
||||
|
||||
if (result.getMatchedClasses() != null) {
|
||||
Element table = ClassUtils.renderMatchedClasses(result.getMatchedClasses());
|
||||
process.write(RenderUtil.render(table)).write("\n");
|
||||
} else {
|
||||
ClassVO classInfo = result.getClassInfo();
|
||||
if (classInfo != null) {
|
||||
process.write("\n");
|
||||
process.write(RenderUtil.render(new LabelElement("ClassLoader: ").style(Decoration.bold.fg(Color.red)), process.width()));
|
||||
process.write(RenderUtil.render(TypeRenderUtils.drawClassLoader(classInfo), process.width()) + "\n");
|
||||
}
|
||||
if (result.getLocation() != null) {
|
||||
process.write(RenderUtil.render(new LabelElement("Location: ").style(Decoration.bold.fg(Color.red)), process.width()));
|
||||
process.write(RenderUtil.render(new LabelElement(result.getLocation()).style(Decoration.bold.fg(Color.blue)), process.width()) + "\n");
|
||||
}
|
||||
process.write(LangRenderUtil.render(result.getSource()) + "\n");
|
||||
process.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.MemoryCompilerModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/20
|
||||
*/
|
||||
public class MemoryCompilerView extends ResultView<MemoryCompilerModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, MemoryCompilerModel result) {
|
||||
process.write("Memory compiler output:\n");
|
||||
for (String file : result.getFiles()) {
|
||||
process.write(file + '\n');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.OgnlModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.StringUtils;
|
||||
import com.taobao.arthas.core.view.ObjectView;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/29
|
||||
*/
|
||||
public class OgnlView extends ResultView<OgnlModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, OgnlModel result) {
|
||||
int expand = result.getExpand();
|
||||
Object value = result.getValue();
|
||||
String resultStr = StringUtils.objectToString(expand >= 0 ? new ObjectView(value, expand).draw() : value);
|
||||
process.write(resultStr).write("\n");
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.RedefineModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/16
|
||||
*/
|
||||
public class RedefineView extends ResultView<RedefineModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, RedefineModel result) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String aClass : result.getRedefinedClasses()) {
|
||||
sb.append(aClass).append("\n");
|
||||
}
|
||||
process.write("redefine success, size: " + result.getRedefinitionCount())
|
||||
.write(", classes:\n")
|
||||
.write(sb.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.RowAffectModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class RowAffectView extends ResultView<RowAffectModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, RowAffectModel result) {
|
||||
process.write(result.affect() + "\n");
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.SearchClassModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/4/8
|
||||
*/
|
||||
public class SearchClassView extends ResultView<SearchClassModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, SearchClassModel result) {
|
||||
|
||||
if (result.isDetailed()) {
|
||||
process.write(RenderUtil.render(ClassUtils.renderClassInfo(result.getClassInfo(),
|
||||
result.isWithField(), result.getExpand()), process.width()));
|
||||
process.write("\n");
|
||||
} else if (result.getClassNames() != null) {
|
||||
for (String className : result.getClassNames()) {
|
||||
process.write(className).write("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.SearchMethodModel;
|
||||
import com.taobao.arthas.core.command.model.MethodVO;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ClassUtils;
|
||||
import com.taobao.text.util.RenderUtil;
|
||||
|
||||
|
||||
/**
|
||||
* render for SearchMethodCommand
|
||||
* @author gongdewei 2020/4/9
|
||||
*/
|
||||
public class SearchMethodView extends ResultView<SearchMethodModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, SearchMethodModel result) {
|
||||
boolean detail = result.isDetail();
|
||||
MethodVO methodInfo = result.getMethodInfo();
|
||||
|
||||
if (detail) {
|
||||
if (methodInfo.isConstructor()) {
|
||||
//render constructor
|
||||
process.write(RenderUtil.render(ClassUtils.renderConstructor(methodInfo), process.width()) + "\n");
|
||||
} else {
|
||||
//render method
|
||||
process.write(RenderUtil.render(ClassUtils.renderMethod(methodInfo), process.width()) + "\n");
|
||||
}
|
||||
} else {
|
||||
//java.util.List indexOf(Ljava/lang/Object;)I
|
||||
//className methodName+Descriptor
|
||||
process.write(methodInfo.getDeclaringClass())
|
||||
.write(" ")
|
||||
.write(methodInfo.getMethodName())
|
||||
.write(methodInfo.getDescriptor())
|
||||
.write("\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.taobao.arthas.core.shell.command;
|
||||
|
||||
/**
|
||||
* 命令执行的结束状态
|
||||
*/
|
||||
public class ExitStatus {
|
||||
|
||||
/**
|
||||
* 命令执行成功的状态
|
||||
*/
|
||||
public static final ExitStatus SUCCESS_STATUS = new ExitStatus(0);
|
||||
|
||||
/**
|
||||
* 命令执行成功的状态
|
||||
* @return
|
||||
*/
|
||||
public static ExitStatus success() {
|
||||
return SUCCESS_STATUS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令执行失败
|
||||
* @param statusCode
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static ExitStatus failure(int statusCode, String message) {
|
||||
if (statusCode == 0) {
|
||||
throw new IllegalArgumentException("failure status code cannot be 0");
|
||||
}
|
||||
return new ExitStatus(statusCode, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为失败状态
|
||||
* @param exitStatus
|
||||
* @return
|
||||
*/
|
||||
public static boolean isFailed(ExitStatus exitStatus) {
|
||||
return exitStatus != null && exitStatus.getStatusCode() != 0;
|
||||
}
|
||||
|
||||
|
||||
private int statusCode;
|
||||
private String message;
|
||||
|
||||
private ExitStatus(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
private ExitStatus(int statusCode, String message) {
|
||||
this.statusCode = statusCode;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.taobao.arthas.core.util;
|
||||
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.shell.command.ExitStatus;
|
||||
|
||||
/**
|
||||
* Command Process util
|
||||
*/
|
||||
public class CommandUtils {
|
||||
|
||||
/**
|
||||
* check exit status and end command processing
|
||||
* @param process CommandProcess instance
|
||||
* @param status ExitStatus of command
|
||||
*/
|
||||
public static void end(CommandProcess process, ExitStatus status) {
|
||||
if (status != null) {
|
||||
process.end(status.getStatusCode(), status.getMessage());
|
||||
} else {
|
||||
process.end(-1, "process error, exit status is null");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue