repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/DumpClassVO.java | core/src/main/java/com/taobao/arthas/core/command/model/DumpClassVO.java | 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/JvmItemVO.java | core/src/main/java/com/taobao/arthas/core/command/model/JvmItemVO.java | package com.taobao.arthas.core.command.model;
/**
* Key/value/desc
* @author gongdewei 2020/4/24
*/
public class JvmItemVO {
private String name;
private Object value;
private String desc;
public JvmItemVO(String name, Object value, String desc) {
this.name = name;
this.value = value;
this.desc = desc;
}
public JvmItemVO(String name, Object value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/OptionsModel.java | core/src/main/java/com/taobao/arthas/core/command/model/OptionsModel.java | package com.taobao.arthas.core.command.model;
import java.util.List;
/**
* @author gongdewei 2020/4/15
*/
public class OptionsModel extends ResultModel{
private List<OptionVO> options;
private ChangeResultVO changeResult;
public OptionsModel() {
}
public OptionsModel(List<OptionVO> options) {
this.options = options;
}
public OptionsModel(ChangeResultVO changeResult) {
this.changeResult = changeResult;
}
@Override
public String getType() {
return "options";
}
public List<OptionVO> getOptions() {
return options;
}
public void setOptions(List<OptionVO> options) {
this.options = options;
}
public ChangeResultVO getChangeResult() {
return changeResult;
}
public void setChangeResult(ChangeResultVO changeResult) {
this.changeResult = changeResult;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/TraceTree.java | core/src/main/java/com/taobao/arthas/core/command/model/TraceTree.java | package com.taobao.arthas.core.command.model;
import com.taobao.arthas.core.util.StringUtils;
import java.util.List;
/**
* Tree model of TraceCommand
* @author gongdewei 2020/4/28
*/
public class TraceTree {
private TraceNode root;
private TraceNode current;
private int nodeCount = 0;
public TraceTree(ThreadNode root) {
this.root = root;
this.current = root;
}
/**
* Begin a new method call
* @param className className of method
* @param methodName method name of the call
* @param lineNumber line number of invoke point
* @param isInvoking Whether to invoke this method in other classes
*/
public void begin(String className, String methodName, int lineNumber, boolean isInvoking) {
TraceNode child = findChild(current, className, methodName, lineNumber);
if (child == null) {
child = new MethodNode(className, methodName, lineNumber, isInvoking);
current.addChild(child);
}
child.begin();
current = child;
nodeCount += 1;
}
private TraceNode findChild(TraceNode node, String className, String methodName, int lineNumber) {
List<TraceNode> childList = node.getChildren();
if (childList != null) {
//less memory than foreach/iterator
for (int i = 0; i < childList.size(); i++) {
TraceNode child = childList.get(i);
if (matchNode(child, className, methodName, lineNumber)) {
return child;
}
}
}
return null;
}
private boolean matchNode(TraceNode node, String className, String methodName, int lineNumber) {
if (node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
if (lineNumber != methodNode.getLineNumber()) return false;
if (className != null ? !className.equals(methodNode.getClassName()) : methodNode.getClassName() != null) return false;
return methodName != null ? methodName.equals(methodNode.getMethodName()) : methodNode.getMethodName() == null;
}
return false;
}
public void end() {
current.end();
if (current.parent() != null) {
//TODO 为什么会到达这里? 调用end次数比begin多?
current = current.parent();
}
}
public void end(Throwable throwable, int lineNumber) {
ThrowNode throwNode = new ThrowNode();
throwNode.setException(throwable.getClass().getName());
throwNode.setMessage(throwable.getMessage());
throwNode.setLineNumber(lineNumber);
current.addChild(throwNode);
this.end(true);
}
public void end(boolean isThrow) {
if (isThrow) {
current.setMark("throws Exception");
if (current instanceof MethodNode) {
MethodNode methodNode = (MethodNode) current;
methodNode.setThrow(true);
}
}
this.end();
}
/**
* 修整树结点
*/
public void trim() {
this.normalizeClassName(root);
}
/**
* 转换标准类名,放在trace结束后统一转换,减少重复操作
* @param node
*/
private void normalizeClassName(TraceNode node) {
if (node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
String nodeClassName = methodNode.getClassName();
String normalizeClassName = StringUtils.normalizeClassName(nodeClassName);
methodNode.setClassName(normalizeClassName);
}
List<TraceNode> children = node.getChildren();
if (children != null) {
//less memory fragment than foreach
for (int i = 0; i < children.size(); i++) {
TraceNode child = children.get(i);
normalizeClassName(child);
}
}
}
public TraceNode getRoot() {
return root;
}
public TraceNode current() {
return current;
}
public int getNodeCount() {
return nodeCount;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/SystemEnvModel.java | core/src/main/java/com/taobao/arthas/core/command/model/SystemEnvModel.java | package com.taobao.arthas.core.command.model;
import java.util.Map;
import java.util.TreeMap;
/**
* sysenv KV Result
* @author gongdewei 2020/4/2
*/
public class SystemEnvModel extends ResultModel {
private Map<String, String> env = new TreeMap<String, String>();
public SystemEnvModel() {
}
public SystemEnvModel(Map env) {
this.putAll(env);
}
public SystemEnvModel(String name, String value) {
this.put(name, value);
}
public Map<String, String> getEnv() {
return env;
}
public String put(String key, String value) {
return env.put(key, value);
}
public void putAll(Map m) {
env.putAll(m);
}
@Override
public String getType() {
return "sysenv";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/HeapDumpModel.java | core/src/main/java/com/taobao/arthas/core/command/model/HeapDumpModel.java | package com.taobao.arthas.core.command.model;
/**
* Model of `heapdump` command
* @author gongdewei 2020/4/24
*/
public class HeapDumpModel extends ResultModel {
private String dumpFile;
private boolean live;
public HeapDumpModel() {
}
public HeapDumpModel(String dumpFile, boolean live) {
this.dumpFile = dumpFile;
this.live = live;
}
public String getDumpFile() {
return dumpFile;
}
public void setDumpFile(String dumpFile) {
this.dumpFile = dumpFile;
}
public boolean isLive() {
return live;
}
public void setLive(boolean live) {
this.live = live;
}
@Override
public String getType() {
return "heapdump";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/GetStaticModel.java | core/src/main/java/com/taobao/arthas/core/command/model/GetStaticModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
/**
* Data model of GetStaticCommand
* @author gongdewei 2020/4/20
*/
public class GetStaticModel extends ResultModel {
private Collection<ClassVO> matchedClasses;
private String fieldName;
private ObjectVO field;
private Collection<ClassLoaderVO> matchedClassLoaders;
private String classLoaderClass;
public GetStaticModel() {
}
public GetStaticModel(String fieldName, Object fieldValue, int expand) {
this.fieldName = fieldName;
this.field = new ObjectVO(fieldValue, expand);
}
public GetStaticModel(Collection<ClassVO> matchedClasses) {
this.matchedClasses = matchedClasses;
}
public ObjectVO getField() {
return field;
}
public void setField(ObjectVO field) {
this.field = field;
}
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public Collection<ClassVO> getMatchedClasses() {
return matchedClasses;
}
public void setMatchedClasses(Collection<ClassVO> matchedClasses) {
this.matchedClasses = matchedClasses;
}
public String getClassLoaderClass() {
return classLoaderClass;
}
public GetStaticModel setClassLoaderClass(String classLoaderClass) {
this.classLoaderClass = classLoaderClass;
return this;
}
public Collection<ClassLoaderVO> getMatchedClassLoaders() {
return matchedClassLoaders;
}
public GetStaticModel setMatchedClassLoaders(Collection<ClassLoaderVO> matchedClassLoaders) {
this.matchedClassLoaders = matchedClassLoaders;
return this;
}
@Override
public String getType() {
return "getstatic";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ThrowNode.java | core/src/main/java/com/taobao/arthas/core/command/model/ThrowNode.java | package com.taobao.arthas.core.command.model;
/**
* Throw exception info node of TraceCommand
* @author gongdewei 2020/7/21
*/
public class ThrowNode extends TraceNode {
private String exception;
private String message;
private int lineNumber;
public ThrowNode() {
super("throw");
}
public String getException() {
return exception;
}
public void setException(String exception) {
this.exception = exception;
}
public int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/HelpModel.java | core/src/main/java/com/taobao/arthas/core/command/model/HelpModel.java | package com.taobao.arthas.core.command.model;
import java.util.ArrayList;
import java.util.List;
/**
* @author gongdewei 2020/4/3
*/
public class HelpModel extends ResultModel {
//list
private List<CommandVO> commands;
//details
private CommandVO detailCommand;
public HelpModel() {
}
public HelpModel(List<CommandVO> commands) {
this.commands = commands;
}
public HelpModel(CommandVO command) {
this.detailCommand = command;
}
public void addCommandVO(CommandVO commandVO){
if (commands == null) {
commands = new ArrayList<CommandVO>();
}
this.commands.add(commandVO);
}
public List<CommandVO> getCommands() {
return commands;
}
public void setCommands(List<CommandVO> commands) {
this.commands = commands;
}
public CommandVO getDetailCommand() {
return detailCommand;
}
@Override
public String getType() {
return "help";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/MonitorModel.java | core/src/main/java/com/taobao/arthas/core/command/model/MonitorModel.java | package com.taobao.arthas.core.command.model;
import com.taobao.arthas.core.command.monitor200.MonitorData;
import java.util.List;
/**
* Data model of MonitorCommand
* @author gongdewei 2020/4/28
*/
public class MonitorModel extends ResultModel {
private List<MonitorData> monitorDataList;
public MonitorModel() {
}
public MonitorModel(List<MonitorData> monitorDataList) {
this.monitorDataList = monitorDataList;
}
@Override
public String getType() {
return "monitor";
}
public List<MonitorData> getMonitorDataList() {
return monitorDataList;
}
public void setMonitorDataList(List<MonitorData> monitorDataList) {
this.monitorDataList = monitorDataList;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/MethodVO.java | core/src/main/java/com/taobao/arthas/core/command/model/MethodVO.java | 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/TimeTunnelModel.java | core/src/main/java/com/taobao/arthas/core/command/model/TimeTunnelModel.java | package com.taobao.arthas.core.command.model;
import java.util.List;
import java.util.Map;
/**
* Data model of TimeTunnelCommand
* @author gongdewei 2020/4/27
*/
public class TimeTunnelModel extends ResultModel {
//查看列表
private List<TimeFragmentVO> timeFragmentList;
//是否为第一次输出(需要加表头)
private Boolean isFirst;
//查看单条记录
private TimeFragmentVO timeFragment;
//重放执行的结果
private TimeFragmentVO replayResult;
//重放执行的次数
private Integer replayNo;
private ObjectVO watchValue;
//search: tt -s {} -w {}
private Map<Integer, ObjectVO> watchResults;
private Integer expand;
private Integer sizeLimit;
@Override
public String getType() {
return "tt";
}
public List<TimeFragmentVO> getTimeFragmentList() {
return timeFragmentList;
}
public TimeTunnelModel setTimeFragmentList(List<TimeFragmentVO> timeFragmentList) {
this.timeFragmentList = timeFragmentList;
return this;
}
public TimeFragmentVO getTimeFragment() {
return timeFragment;
}
public TimeTunnelModel setTimeFragment(TimeFragmentVO timeFragment) {
this.timeFragment = timeFragment;
return this;
}
public Integer getExpand() {
return expand;
}
public TimeTunnelModel setExpand(Integer expand) {
this.expand = expand;
return this;
}
public Integer getSizeLimit() {
return sizeLimit;
}
public TimeTunnelModel setSizeLimit(Integer sizeLimit) {
this.sizeLimit = sizeLimit;
return this;
}
public ObjectVO getWatchValue() {
return watchValue;
}
public TimeTunnelModel setWatchValue(ObjectVO watchValue) {
this.watchValue = watchValue;
return this;
}
public Map<Integer, ObjectVO> getWatchResults() {
return watchResults;
}
public TimeTunnelModel setWatchResults(Map<Integer, ObjectVO> watchResults) {
this.watchResults = watchResults;
return this;
}
public TimeFragmentVO getReplayResult() {
return replayResult;
}
public TimeTunnelModel setReplayResult(TimeFragmentVO replayResult) {
this.replayResult = replayResult;
return this;
}
public Integer getReplayNo() {
return replayNo;
}
public TimeTunnelModel setReplayNo(Integer replayNo) {
this.replayNo = replayNo;
return this;
}
public Boolean getFirst() {
return isFirst;
}
public TimeTunnelModel setFirst(Boolean first) {
isFirst = first;
return this;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/HistoryModel.java | core/src/main/java/com/taobao/arthas/core/command/model/HistoryModel.java | package com.taobao.arthas.core.command.model;
import java.util.List;
/**
* @author gongdewei 2020/4/8
*/
public class HistoryModel extends ResultModel {
private List<String> history;
public HistoryModel() {
}
public HistoryModel(List<String> history) {
this.history = history;
}
public List<String> getHistory() {
return history;
}
@Override
public String getType() {
return "history";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/TraceModel.java | core/src/main/java/com/taobao/arthas/core/command/model/TraceModel.java | package com.taobao.arthas.core.command.model;
/**
* Data model of TraceCommand
* @author gongdewei 2020/4/29
*/
public class TraceModel extends ResultModel {
private TraceNode root;
private int nodeCount;
public TraceModel() {
}
public TraceModel(TraceNode root, int nodeCount) {
this.root = root;
this.nodeCount = nodeCount;
}
@Override
public String getType() {
return "trace";
}
public TraceNode getRoot() {
return root;
}
public void setRoot(TraceNode root) {
this.root = root;
}
public int getNodeCount() {
return nodeCount;
}
public void setNodeCount(int nodeCount) {
this.nodeCount = nodeCount;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/SystemPropertyModel.java | core/src/main/java/com/taobao/arthas/core/command/model/SystemPropertyModel.java | package com.taobao.arthas.core.command.model;
import java.util.HashMap;
import java.util.Map;
/**
* Property KV Result
* @author gongdewei 2020/4/2
*/
public class SystemPropertyModel extends ResultModel {
private Map<String, String> props = new HashMap<String, String>();
public SystemPropertyModel() {
}
public SystemPropertyModel(Map props) {
this.putAll(props);
}
public SystemPropertyModel(String name, String value) {
this.put(name, value);
}
public Map<String, String> getProps() {
return props;
}
public String put(String key, String value) {
return props.put(key, value);
}
public void putAll(Map m) {
props.putAll(m);
}
@Override
public String getType() {
return "sysprop";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/SearchMethodModel.java | core/src/main/java/com/taobao/arthas/core/command/model/SearchMethodModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
/**
* Model of SearchMethodCommand
* @author gongdewei 2020/4/9
*/
public class SearchMethodModel extends ResultModel {
private MethodVO methodInfo;
private boolean detail;
private Collection<ClassLoaderVO> matchedClassLoaders;
private String classLoaderClass;
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;
}
public String getClassLoaderClass() {
return classLoaderClass;
}
public SearchMethodModel setClassLoaderClass(String classLoaderClass) {
this.classLoaderClass = classLoaderClass;
return this;
}
public Collection<ClassLoaderVO> getMatchedClassLoaders() {
return matchedClassLoaders;
}
public SearchMethodModel setMatchedClassLoaders(Collection<ClassLoaderVO> matchedClassLoaders) {
this.matchedClassLoaders = matchedClassLoaders;
return this;
}
@Override
public String getType() {
return "sm";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ClassLoaderVO.java | core/src/main/java/com/taobao/arthas/core/command/model/ClassLoaderVO.java | 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ThreadModel.java | core/src/main/java/com/taobao/arthas/core/command/model/ThreadModel.java | package com.taobao.arthas.core.command.model;
import java.lang.management.ThreadInfo;
import java.util.List;
import java.util.Map;
/**
* Model of 'thread' command
*
* @author gongdewei 2020/4/26
*/
public class ThreadModel extends ResultModel {
//single thread: thread 12
private ThreadInfo threadInfo;
//thread -b
private BlockingLockInfo blockingLockInfo;
//thread -n 5
private List<BusyThreadInfo> busyThreads;
//thread stats
private List<ThreadVO> threadStats;
private Map<Thread.State, Integer> threadStateCount;
private boolean all;
public ThreadModel() {
}
public ThreadModel(ThreadInfo threadInfo) {
this.threadInfo = threadInfo;
}
public ThreadModel(BlockingLockInfo blockingLockInfo) {
this.blockingLockInfo = blockingLockInfo;
}
public ThreadModel(List<BusyThreadInfo> busyThreads) {
this.busyThreads = busyThreads;
}
public ThreadModel(List<ThreadVO> threadStats, Map<Thread.State, Integer> threadStateCount, boolean all) {
this.threadStats = threadStats;
this.threadStateCount = threadStateCount;
this.all = all;
}
@Override
public String getType() {
return "thread";
}
public ThreadInfo getThreadInfo() {
return threadInfo;
}
public void setThreadInfo(ThreadInfo threadInfo) {
this.threadInfo = threadInfo;
}
public BlockingLockInfo getBlockingLockInfo() {
return blockingLockInfo;
}
public void setBlockingLockInfo(BlockingLockInfo blockingLockInfo) {
this.blockingLockInfo = blockingLockInfo;
}
public List<BusyThreadInfo> getBusyThreads() {
return busyThreads;
}
public void setBusyThreads(List<BusyThreadInfo> busyThreads) {
this.busyThreads = busyThreads;
}
public List<ThreadVO> getThreadStats() {
return threadStats;
}
public void setThreadStats(List<ThreadVO> threadStats) {
this.threadStats = threadStats;
}
public Map<Thread.State, Integer> getThreadStateCount() {
return threadStateCount;
}
public void setThreadStateCount(Map<Thread.State, Integer> threadStateCount) {
this.threadStateCount = threadStateCount;
}
public boolean isAll() {
return all;
}
public void setAll(boolean all) {
this.all = all;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/MethodNode.java | core/src/main/java/com/taobao/arthas/core/command/model/MethodNode.java | package com.taobao.arthas.core.command.model;
/**
* Method call node of TraceCommand
* @author gongdewei 2020/4/29
*/
public class MethodNode extends TraceNode {
private String className;
private String methodName;
private int lineNumber;
private Boolean isThrow;
private String throwExp;
/**
* 是否为invoke方法,true为beforeInvoke,false为方法体入口的onBefore
*/
private boolean isInvoking;
/**
* 开始时间戳
*/
private long beginTimestamp;
/**
* 结束时间戳
*/
private long endTimestamp;
/**
* 合并统计相同调用,并计算最小\最大\总耗时
*/
private long minCost = Long.MAX_VALUE;
private long maxCost = Long.MIN_VALUE;
private long totalCost = 0;
private long times = 0;
public MethodNode(String className, String methodName, int lineNumber, boolean isInvoking) {
super("method");
this.className = className;
this.methodName = methodName;
this.lineNumber = lineNumber;
this.isInvoking = isInvoking;
}
public void begin() {
beginTimestamp = System.nanoTime();
}
public void end() {
endTimestamp = System.nanoTime();
long cost = getCost();
if (cost < minCost) {
minCost = cost;
}
if (cost > maxCost) {
maxCost = cost;
}
times++;
totalCost += cost;
}
public long getCost() {
return endTimestamp - beginTimestamp;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public Boolean getThrow() {
return isThrow;
}
public void setThrow(Boolean aThrow) {
isThrow = aThrow;
}
public String getThrowExp() {
return throwExp;
}
public void setThrowExp(String throwExp) {
this.throwExp = throwExp;
}
public long getMinCost() {
return minCost;
}
public void setMinCost(long minCost) {
this.minCost = minCost;
}
public long getMaxCost() {
return maxCost;
}
public void setMaxCost(long maxCost) {
this.maxCost = maxCost;
}
public long getTotalCost() {
return totalCost;
}
public void setTotalCost(long totalCost) {
this.totalCost = totalCost;
}
public long getTimes() {
return times;
}
public void setTimes(long times) {
this.times = times;
}
public boolean isInvoking() {
return isInvoking;
}
public void setInvoking(boolean invoking) {
isInvoking = invoking;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/VmToolModel.java | core/src/main/java/com/taobao/arthas/core/command/model/VmToolModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
/**
*
* @author hengyunabc 2022-04-24
*
*/
public class VmToolModel extends ResultModel {
private ObjectVO value;
private Collection<ClassLoaderVO> matchedClassLoaders;
private String classLoaderClass;
@Override
public String getType() {
return "vmtool";
}
public ObjectVO getValue() {
return value;
}
public VmToolModel setValue(ObjectVO value) {
this.value = value;
return this;
}
public String getClassLoaderClass() {
return classLoaderClass;
}
public VmToolModel setClassLoaderClass(String classLoaderClass) {
this.classLoaderClass = classLoaderClass;
return this;
}
public Collection<ClassLoaderVO> getMatchedClassLoaders() {
return matchedClassLoaders;
}
public VmToolModel setMatchedClassLoaders(Collection<ClassLoaderVO> matchedClassLoaders) {
this.matchedClassLoaders = matchedClassLoaders;
return this;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/FieldVO.java | core/src/main/java/com/taobao/arthas/core/command/model/FieldVO.java | 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 ObjectVO 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 ObjectVO getValue() {
return value;
}
public void setValue(ObjectVO 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/CatModel.java | core/src/main/java/com/taobao/arthas/core/command/model/CatModel.java | package com.taobao.arthas.core.command.model;
/**
* Result model for CatCommand
* @author gongdewei 2020/5/11
*/
public class CatModel extends ResultModel implements Countable {
private String file;
private String content;
public CatModel() {
}
public CatModel(String file, String content) {
this.file = file;
this.content = content;
}
@Override
public String getType() {
return "cat";
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public int size() {
if (content != null) {
//粗略计算行数作为item size
return content.length()/100 + 1;
}
return 0;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/WatchModel.java | core/src/main/java/com/taobao/arthas/core/command/model/WatchModel.java | package com.taobao.arthas.core.command.model;
import java.time.LocalDateTime;
/**
* Watch command result model
*
* @author gongdewei 2020/03/26
*/
public class WatchModel extends ResultModel {
private LocalDateTime ts;
private double cost;
private ObjectVO value;
private Integer sizeLimit;
private String className;
private String methodName;
private String accessPoint;
public WatchModel() {
}
@Override
public String getType() {
return "watch";
}
public LocalDateTime getTs() {
return ts;
}
public void setTs(LocalDateTime ts) {
this.ts = ts;
}
public double getCost() {
return cost;
}
public ObjectVO getValue() {
return value;
}
public void setCost(double cost) {
this.cost = cost;
}
public void setValue(ObjectVO value) {
this.value = value;
}
public void setSizeLimit(Integer sizeLimit) {
this.sizeLimit = sizeLimit;
}
public Integer getSizeLimit() {
return sizeLimit;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getAccessPoint() {
return accessPoint;
}
public void setAccessPoint(String accessPoint) {
this.accessPoint = accessPoint;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/LoggerModel.java | core/src/main/java/com/taobao/arthas/core/command/model/LoggerModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
import java.util.Map;
/**
* Model of logger command
*
* @author gongdewei 2020/4/22
*/
public class LoggerModel extends ResultModel {
private Map<String, Map<String, Object>> loggerInfoMap;
private Collection<ClassLoaderVO> matchedClassLoaders;
private String classLoaderClass;
public LoggerModel() {
}
public LoggerModel(Map<String, Map<String, Object>> loggerInfoMap) {
this.loggerInfoMap = loggerInfoMap;
}
public Map<String, Map<String, Object>> getLoggerInfoMap() {
return loggerInfoMap;
}
public void setLoggerInfoMap(Map<String, Map<String, Object>> loggerInfoMap) {
this.loggerInfoMap = loggerInfoMap;
}
public String getClassLoaderClass() {
return classLoaderClass;
}
public LoggerModel setClassLoaderClass(String classLoaderClass) {
this.classLoaderClass = classLoaderClass;
return this;
}
public Collection<ClassLoaderVO> getMatchedClassLoaders() {
return matchedClassLoaders;
}
public LoggerModel setMatchedClassLoaders(Collection<ClassLoaderVO> matchedClassLoaders) {
this.matchedClassLoaders = matchedClassLoaders;
return this;
}
@Override
public String getType() {
return "logger";
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ProfilerModel.java | core/src/main/java/com/taobao/arthas/core/command/model/ProfilerModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
/**
* Data model of ProfilerCommand
* @author gongdewei 2020/4/27
*/
public class ProfilerModel extends ResultModel {
private String action;
private String actionArg;
private String executeResult;
private Collection<String> supportedActions;
private String outputFile;
private Long duration;
public ProfilerModel() {
}
public ProfilerModel(Collection<String> supportedActions) {
this.supportedActions = supportedActions;
}
@Override
public String getType() {
return "profiler";
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getActionArg() {
return actionArg;
}
public void setActionArg(String actionArg) {
this.actionArg = actionArg;
}
public Collection<String> getSupportedActions() {
return supportedActions;
}
public void setSupportedActions(Collection<String> supportedActions) {
this.supportedActions = supportedActions;
}
public String getExecuteResult() {
return executeResult;
}
public void setExecuteResult(String executeResult) {
this.executeResult = executeResult;
}
public String getOutputFile() {
return outputFile;
}
public void setOutputFile(String outputFile) {
this.outputFile = outputFile;
}
public Long getDuration() {
return duration;
}
public void setDuration(Long duration) {
this.duration = duration;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/BlockingLockInfo.java | core/src/main/java/com/taobao/arthas/core/command/model/BlockingLockInfo.java | package com.taobao.arthas.core.command.model;
import java.lang.management.ThreadInfo;
/**
* Thread blocking lock info, extract from ThreadUtil.
*
* @author gongdewei 2020/7/14
*/
public class BlockingLockInfo {
// the thread info that is holing this lock.
private ThreadInfo threadInfo = null;
// the associated LockInfo object
private int lockIdentityHashCode = 0;
// the number of thread that is blocked on this lock
private int blockingThreadCount = 0;
public BlockingLockInfo() {
}
public ThreadInfo getThreadInfo() {
return threadInfo;
}
public void setThreadInfo(ThreadInfo threadInfo) {
this.threadInfo = threadInfo;
}
public int getLockIdentityHashCode() {
return lockIdentityHashCode;
}
public void setLockIdentityHashCode(int lockIdentityHashCode) {
this.lockIdentityHashCode = lockIdentityHashCode;
}
public int getBlockingThreadCount() {
return blockingThreadCount;
}
public void setBlockingThreadCount(int blockingThreadCount) {
this.blockingThreadCount = blockingThreadCount;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/OptionVO.java | core/src/main/java/com/taobao/arthas/core/command/model/OptionVO.java | package com.taobao.arthas.core.command.model;
/**
* @author gongdewei 2020/4/15
*/
public class OptionVO {
private int level;
private String type;
private String name;
private String value;
private String summary;
private String description;
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ClassDetailVO.java | core/src/main/java/com/taobao/arthas/core/command/model/ClassDetailVO.java | 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/GcInfoVO.java | core/src/main/java/com/taobao/arthas/core/command/model/GcInfoVO.java | package com.taobao.arthas.core.command.model;
/**
* GC info of dashboard
* @author gongdewei 2020/4/23
*/
public class GcInfoVO {
private String name;
private long collectionCount;
private long collectionTime;
public GcInfoVO(String name, long collectionCount, long collectionTime) {
this.name = name;
this.collectionCount = collectionCount;
this.collectionTime = collectionTime;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getCollectionCount() {
return collectionCount;
}
public void setCollectionCount(long collectionCount) {
this.collectionCount = collectionCount;
}
public long getCollectionTime() {
return collectionTime;
}
public void setCollectionTime(long collectionTime) {
this.collectionTime = collectionTime;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/PerfCounterModel.java | core/src/main/java/com/taobao/arthas/core/command/model/PerfCounterModel.java | package com.taobao.arthas.core.command.model;
import java.util.List;
/**
* Model of 'perfcounter'
*
* @author gongdewei 2020/4/27
*/
public class PerfCounterModel extends ResultModel {
private List<PerfCounterVO> perfCounters;
private boolean details;
public PerfCounterModel() {
}
public PerfCounterModel(List<PerfCounterVO> perfCounters, boolean details) {
this.perfCounters = perfCounters;
this.details = details;
}
@Override
public String getType() {
return "perfcounter";
}
public List<PerfCounterVO> getPerfCounters() {
return perfCounters;
}
public void setPerfCounters(List<PerfCounterVO> perfCounters) {
this.perfCounters = perfCounters;
}
public boolean isDetails() {
return details;
}
public void setDetails(boolean details) {
this.details = details;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/MBeanAttributeVO.java | core/src/main/java/com/taobao/arthas/core/command/model/MBeanAttributeVO.java | package com.taobao.arthas.core.command.model;
/**
* MBean attribute
*
* @author gongdewei 2020/4/26
*/
public class MBeanAttributeVO {
private String name;
private Object value;
private String error;
public MBeanAttributeVO(String name, Object value) {
this.name = name;
this.value = value;
}
public MBeanAttributeVO(String name, Object value, String error) {
this.name = name;
this.value = value;
this.error = error;
}
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;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/CommandVO.java | core/src/main/java/com/taobao/arthas/core/command/model/CommandVO.java | package com.taobao.arthas.core.command.model;
import com.taobao.middleware.cli.CLI;
import java.util.ArrayList;
import java.util.List;
/**
* @author gongdewei 2020/4/3
*/
public class CommandVO {
//TODO remove cli
private transient CLI cli;
private String name;
private String description;
private String usage;
private String summary;
private List<CommandOptionVO> options = new ArrayList<CommandOptionVO>();
private List<ArgumentVO> arguments = new ArrayList<ArgumentVO>();
public CommandVO() {
}
public CommandVO(String name, String description) {
this.name = name;
this.description = description;
}
public CommandVO addOption(CommandOptionVO optionVO){
this.options.add(optionVO);
return this;
}
public CommandVO addArgument(ArgumentVO argumentVO){
this.arguments.add(argumentVO);
return this;
}
public CLI cli() {
return cli;
}
public void setCli(CLI cli) {
this.cli = cli;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public List<CommandOptionVO> getOptions() {
return options;
}
public void setOptions(List<CommandOptionVO> options) {
this.options = options;
}
public List<ArgumentVO> getArguments() {
return arguments;
}
public void setArguments(List<ArgumentVO> arguments) {
this.arguments = arguments;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/StackModel.java | core/src/main/java/com/taobao/arthas/core/command/model/StackModel.java | package com.taobao.arthas.core.command.model;
import java.time.LocalDateTime;
/**
* StackCommand result model
* @author gongdewei 2020/4/13
*/
public class StackModel extends ResultModel {
private LocalDateTime ts;
private double cost;
private String traceId;
private String rpcId;
private String threadName;
private String threadId;
private boolean daemon;
private int priority;
/* Thread Current ClassLoader */
private String classloader;
private StackTraceElement[] stackTrace;
@Override
public String getType() {
return "stack";
}
public LocalDateTime getTs() {
return ts;
}
public void setTs(LocalDateTime ts) {
this.ts = ts;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public String getThreadName() {
return threadName;
}
public void setThreadName(String threadName) {
this.threadName = threadName;
}
public String getThreadId() {
return threadId;
}
public void setThreadId(String threadId) {
this.threadId = threadId;
}
public boolean isDaemon() {
return daemon;
}
public void setDaemon(boolean daemon) {
this.daemon = daemon;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public String getClassloader() {
return classloader;
}
public void setClassloader(String classloader) {
this.classloader = classloader;
}
public String getTraceId() {
return traceId;
}
public void setTraceId(String traceId) {
this.traceId = traceId;
}
public String getRpcId() {
return rpcId;
}
public void setRpcId(String rpcId) {
this.rpcId = rpcId;
}
public StackTraceElement[] getStackTrace() {
return stackTrace;
}
public void setStackTrace(StackTraceElement[] stackTrace) {
this.stackTrace = stackTrace;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/MBeanModel.java | core/src/main/java/com/taobao/arthas/core/command/model/MBeanModel.java | package com.taobao.arthas.core.command.model;
import javax.management.MBeanInfo;
import java.util.List;
import java.util.Map;
/**
* Model of 'mbean'
*
* @author gongdewei 2020/4/26
*/
public class MBeanModel extends ResultModel {
private List<String> mbeanNames;
private Map<String, MBeanInfo> mbeanMetadata;
private Map<String, List<MBeanAttributeVO>> mbeanAttribute;
public MBeanModel() {
}
public MBeanModel(List<String> mbeanNames) {
this.mbeanNames = mbeanNames;
}
@Override
public String getType() {
return "mbean";
}
public List<String> getMbeanNames() {
return mbeanNames;
}
public void setMbeanNames(List<String> mbeanNames) {
this.mbeanNames = mbeanNames;
}
public Map<String, MBeanInfo> getMbeanMetadata() {
return mbeanMetadata;
}
public void setMbeanMetadata(Map<String, MBeanInfo> mbeanMetadata) {
this.mbeanMetadata = mbeanMetadata;
}
public Map<String, List<MBeanAttributeVO>> getMbeanAttribute() {
return mbeanAttribute;
}
public void setMbeanAttribute(Map<String, List<MBeanAttributeVO>> mbeanAttribute) {
this.mbeanAttribute = mbeanAttribute;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ClassVO.java | core/src/main/java/com/taobao/arthas/core/command/model/ClassVO.java | 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;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/ShutdownModel.java | core/src/main/java/com/taobao/arthas/core/command/model/ShutdownModel.java | package com.taobao.arthas.core.command.model;
/**
* @author gongdewei 2020/6/22
*/
public class ShutdownModel extends ResultModel {
private boolean graceful;
private String message;
public ShutdownModel(boolean graceful, String message) {
this.graceful = graceful;
this.message = message;
}
@Override
public String getType() {
return "shutdown";
}
public boolean isGraceful() {
return graceful;
}
public String getMessage() {
return message;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/SearchClassModel.java | core/src/main/java/com/taobao/arthas/core/command/model/SearchClassModel.java | package com.taobao.arthas.core.command.model;
import java.util.Collection;
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 List<String> classNames;
private int segment;
private Collection<ClassLoaderVO> matchedClassLoaders;
private String classLoaderClass;
public SearchClassModel() {
}
public SearchClassModel(ClassDetailVO classInfo, boolean detailed, boolean withField) {
this.classInfo = classInfo;
this.detailed = detailed;
this.withField = withField;
}
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 String getClassLoaderClass() {
return classLoaderClass;
}
public SearchClassModel setClassLoaderClass(String classLoaderClass) {
this.classLoaderClass = classLoaderClass;
return this;
}
public Collection<ClassLoaderVO> getMatchedClassLoaders() {
return matchedClassLoaders;
}
public SearchClassModel setMatchedClassLoaders(Collection<ClassLoaderVO> matchedClassLoaders) {
this.matchedClassLoaders = matchedClassLoaders;
return this;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/Base64Model.java | core/src/main/java/com/taobao/arthas/core/command/model/Base64Model.java | package com.taobao.arthas.core.command.model;
/**
*
* @author hengyunabc 2021-01-05
*
*/
public class Base64Model extends ResultModel {
private String content;
public Base64Model() {
}
public Base64Model(String content) {
this.content = content;
}
@Override
public String getType() {
return "base64";
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/EchoModel.java | core/src/main/java/com/taobao/arthas/core/command/model/EchoModel.java | package com.taobao.arthas.core.command.model;
/**
* @author gongdewei 2020/5/11
*/
public class EchoModel extends ResultModel {
private String content;
public EchoModel() {
}
public EchoModel(String content) {
this.content = content;
}
@Override
public String getType() {
return "echo";
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/model/JvmModel.java | core/src/main/java/com/taobao/arthas/core/command/model/JvmModel.java | package com.taobao.arthas.core.command.model;
import java.util.*;
/**
* Model of 'jvm' command
*
* @author gongdewei 2020/4/24
*/
public class JvmModel extends ResultModel {
private Map<String, List<JvmItemVO>> jvmInfo;
public JvmModel() {
jvmInfo = Collections.synchronizedMap(new LinkedHashMap<String, List<JvmItemVO>>());
}
@Override
public String getType() {
return "jvm";
}
public JvmModel addItem(String group, String name, Object value) {
this.addItem(group, name, value, null);
return this;
}
public JvmModel addItem(String group, String name, Object value, String desc) {
this.group(group).add(new JvmItemVO(name, value, desc));
return this;
}
public List<JvmItemVO> group(String group) {
synchronized (this) {
List<JvmItemVO> list = jvmInfo.get(group);
if (list == null) {
list = new ArrayList<JvmItemVO>();
jvmInfo.put(group, list);
}
return list;
}
}
public Map<String, List<JvmItemVO>> getJvmInfo() {
return jvmInfo;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/GrepCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/GrepCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.DefaultValue;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
/**
* @see com.taobao.arthas.core.shell.command.internal.GrepHandler
*/
@Name("grep")
@Summary("grep command for pipes." )
@Description(Constants.EXAMPLE +
" sysprop | grep java \n" +
" sysprop | grep java -n\n" +
" sysenv | grep -v JAVA\n" +
" sysenv | grep -e \"(?i)(JAVA|sun)\" -m 3 -C 2\n" +
" sysenv | grep JAVA -A2 -B3\n" +
" thread | grep -m 10 -e \"TIMED_WAITING|WAITING\"\n"
+ Constants.WIKI + Constants.WIKI_HOME + "grep")
public class GrepCommand extends AnnotatedCommand {
private String pattern;
private boolean ignoreCase;
/**
* select non-matching lines
*/
private boolean invertMatch;
private boolean isRegEx = false;
/**
* print line number with output lines
*/
private boolean showLineNumber = false;
private boolean trimEnd;
/**
* print NUM lines of leading context
*/
private int beforeLines;
/**
* print NUM lines of trailing context
*/
private int afterLines;
/**
* print NUM lines of output context
*/
private int context;
/**
* stop after NUM selected lines
*/
private int maxCount;
@Argument(index = 0, argName = "pattern", required = true)
@Description("Pattern")
public void setOptionName(String pattern) {
this.pattern = pattern;
}
@Option(shortName = "e", longName = "regex", flag = true)
@Description("Enable regular expression to match")
public void setRegEx(boolean regEx) {
isRegEx = regEx;
}
@Option(shortName = "i", longName = "ignore-case", flag = true)
@Description("Perform case insensitive matching. By default, grep is case sensitive.")
public void setIgnoreCase(boolean ignoreCase) {
this.ignoreCase = ignoreCase;
}
@Option(shortName = "v", longName = "invert-match", flag = true)
@Description("Select non-matching lines")
public void setInvertMatch(boolean invertMatch) {
this.invertMatch = invertMatch;
}
@Option(shortName = "n", longName = "line-number", flag = true)
@Description("Print line number with output lines")
public void setShowLineNumber(boolean showLineNumber) {
this.showLineNumber = showLineNumber;
}
@Option(longName = "trim-end", flag = false)
@DefaultValue("true")
@Description("Remove whitespaces at the end of the line, default value true")
public void setTrimEnd(boolean trimEnd) {
this.trimEnd = trimEnd;
}
@Option(shortName = "B", longName = "before-context")
@Description("Print NUM lines of leading context)")
public void setBeforeLines(int beforeLines) {
this.beforeLines = beforeLines;
}
@Option(shortName = "A", longName = "after-context")
@Description("Print NUM lines of trailing context)")
public void setAfterLines(int afterLines) {
this.afterLines = afterLines;
}
@Option(shortName = "C", longName = "context")
@Description("Print NUM lines of output context)")
public void setContext(int context) {
this.context = context;
}
@Option(shortName = "m", longName = "max-count")
@Description("stop after NUM selected lines)")
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public boolean isIgnoreCase() {
return ignoreCase;
}
public boolean isInvertMatch() {
return invertMatch;
}
public boolean isRegEx() {
return isRegEx;
}
public boolean isShowLineNumber() {
return showLineNumber;
}
public boolean isTrimEnd() {
return trimEnd;
}
public int getBeforeLines() {
return beforeLines;
}
public int getAfterLines() {
return afterLines;
}
public int getContext() {
return context;
}
public int getMaxCount() {
return maxCount;
}
@Override
public void process(CommandProcess process) {
process.end(-1, "The grep command only for pipes. See 'grep --help'\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/HistoryCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/HistoryCommand.java | package com.taobao.arthas.core.command.basic1000;
import java.util.ArrayList;
import java.util.List;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.HistoryModel;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.history.HistoryManager;
import com.taobao.arthas.core.shell.session.Session;
import com.taobao.arthas.core.shell.term.impl.TermImpl;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
import io.termd.core.readline.Readline;
import io.termd.core.util.Helper;
/**
*
* @author hengyunabc 2018-11-18
*
*/
@Name("history")
@Summary("Display command history")
@Description(Constants.EXAMPLE + " history\n" + " history -c\n" + " history 5\n")
public class HistoryCommand extends AnnotatedCommand {
boolean clear = false;
int n = -1;
@Option(shortName = "c", longName = "clear", flag = true , acceptValue = false)
@Description("clear history")
public void setClear(boolean clear) {
this.clear = clear;
}
@Argument(index = 0, argName = "n", required = false)
@Description("how many history commands to display")
public void setNumber(int n) {
this.n = n;
}
@Override
public void process(CommandProcess process) {
Session session = process.session();
//TODO 修改term history实现方式,统一使用HistoryManager
Object termObject = session.get(Session.TTY);
if (termObject instanceof TermImpl) {
TermImpl term = (TermImpl) termObject;
Readline readline = term.getReadline();
List<int[]> history = readline.getHistory();
if (clear) {
readline.setHistory(new ArrayList<int[]>());
} else {
StringBuilder sb = new StringBuilder();
int size = history.size();
if (n < 0 || n > size) {
n = size;
}
for (int i = 0; i < n; ++i) {
int[] line = history.get(n - i - 1);
sb.append(String.format("%5s ", size - (n - i - 1)));
Helper.appendCodePoints(line, sb);
sb.append('\n');
}
process.write(sb.toString());
}
} else {
//http api
HistoryManager historyManager = ArthasBootstrap.getInstance().getHistoryManager();
if (clear) {
historyManager.clearHistory();
} else {
List<String> history = historyManager.getHistory();
process.appendResult(new HistoryModel(new ArrayList<String>(history)));
}
}
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/SessionCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/SessionCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.model.SessionModel;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.session.Session;
import com.taobao.arthas.core.util.UserStatUtil;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
import com.alibaba.arthas.tunnel.client.TunnelClient;
/**
* 查看会话状态命令
*
* @author vlinux on 15/5/3.
*/
@Name("session")
@Summary("Display current session information")
public class SessionCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
SessionModel result = new SessionModel();
Session session = process.session();
result.setJavaPid(session.getPid());
result.setSessionId(session.getSessionId());
//tunnel
TunnelClient tunnelClient = ArthasBootstrap.getInstance().getTunnelClient();
if (tunnelClient != null) {
String id = tunnelClient.getId();
if (id != null) {
result.setAgentId(id);
}
result.setTunnelServer(tunnelClient.getTunnelServerUrl());
result.setTunnelConnected(tunnelClient.isConnected());
}
//statUrl
String statUrl = UserStatUtil.getStatUrl();
result.setStatUrl(statUrl);
//userId
String userId = session.getUserId();
result.setUserId(userId);
process.appendResult(result);
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/OptionsCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/OptionsCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.GlobalOptions;
import com.taobao.arthas.core.Option;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.ChangeResultVO;
import com.taobao.arthas.core.command.model.OptionVO;
import com.taobao.arthas.core.command.model.OptionsModel;
import com.taobao.arthas.core.shell.cli.CliToken;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.command.ExitStatus;
import com.taobao.arthas.core.util.CommandUtils;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.arthas.core.util.TokenUtils;
import com.taobao.arthas.core.util.matcher.EqualsMatcher;
import com.taobao.arthas.core.util.matcher.Matcher;
import com.taobao.arthas.core.util.matcher.RegexMatcher;
import com.taobao.arthas.core.util.reflect.FieldUtils;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static com.taobao.arthas.core.util.ArthasCheckUtils.isIn;
import static java.lang.String.format;
/**
* 选项开关命令
*
* @author vlinux on 15/6/6.
*/
// @formatter:off
@Name("options")
@Summary("View and change various Arthas options")
@Description(Constants.EXAMPLE +
"options # list all options\n" +
"options json-format true\n" +
"options dump true\n" +
"options unsafe true\n" +
Constants.WIKI + Constants.WIKI_HOME + "options")
//@formatter:on
public class OptionsCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(OptionsCommand.class);
private String optionName;
private String optionValue;
@Argument(index = 0, argName = "options-name", required = false)
@Description("Option name")
public void setOptionName(String optionName) {
this.optionName = optionName;
}
@Argument(index = 1, argName = "options-value", required = false)
@Description("Option value")
public void setOptionValue(String optionValue) {
this.optionValue = optionValue;
}
@Override
public void process(CommandProcess process) {
try {
ExitStatus status = null;
if (isShow()) {
status = processShow(process);
} else if (isShowName()) {
status = processShowName(process);
} else {
status = processChangeNameValue(process);
}
CommandUtils.end(process, status);
} catch (Throwable t) {
logger.error("processing error", t);
process.end(-1, "processing error");
}
}
/**
* complete first argument(options-name), other case use default complete
*
* @param completion the completion object
*/
@Override
public void complete(Completion completion) {
int argumentIndex = CompletionUtils.detectArgumentIndex(completion);
List<CliToken> lineTokens = completion.lineTokens();
if (argumentIndex == 1) {
String laseToken = TokenUtils.getLast(lineTokens).value().trim();
//prefix match options-name
String pattern = "^" + laseToken + ".*";
Collection<String> optionNames = findOptionNames(new RegexMatcher(pattern));
CompletionUtils.complete(completion, optionNames);
} else {
super.complete(completion);
}
}
private ExitStatus processShow(CommandProcess process) throws IllegalAccessException {
Collection<Field> fields = findOptionFields(new RegexMatcher(".*"));
process.appendResult(new OptionsModel(convertToOptionVOs(fields)));
return ExitStatus.success();
}
private ExitStatus processShowName(CommandProcess process) throws IllegalAccessException {
Collection<Field> fields = findOptionFields(new EqualsMatcher<String>(optionName));
process.appendResult(new OptionsModel(convertToOptionVOs(fields)));
return ExitStatus.success();
}
private ExitStatus processChangeNameValue(CommandProcess process) throws IllegalAccessException {
Collection<Field> fields = findOptionFields(new EqualsMatcher<String>(optionName));
// name not exists
if (fields.isEmpty()) {
return ExitStatus.failure(-1, format("options[%s] not found.", optionName));
}
Field field = fields.iterator().next();
Option optionAnnotation = field.getAnnotation(Option.class);
Class<?> type = field.getType();
Object beforeValue = FieldUtils.readStaticField(field);
Object afterValue;
try {
// try to case string to type
if (isIn(type, int.class, Integer.class)) {
FieldUtils.writeStaticField(field, afterValue = Integer.valueOf(optionValue));
} else if (isIn(type, long.class, Long.class)) {
FieldUtils.writeStaticField(field, afterValue = Long.valueOf(optionValue));
} else if (isIn(type, boolean.class, Boolean.class)) {
FieldUtils.writeStaticField(field, afterValue = Boolean.valueOf(optionValue));
} else if (isIn(type, double.class, Double.class)) {
FieldUtils.writeStaticField(field, afterValue = Double.valueOf(optionValue));
} else if (isIn(type, float.class, Float.class)) {
FieldUtils.writeStaticField(field, afterValue = Float.valueOf(optionValue));
} else if (isIn(type, byte.class, Byte.class)) {
FieldUtils.writeStaticField(field, afterValue = Byte.valueOf(optionValue));
} else if (isIn(type, short.class, Short.class)) {
FieldUtils.writeStaticField(field, afterValue = Short.valueOf(optionValue));
} else if (isIn(type, short.class, String.class)) {
FieldUtils.writeStaticField(field, afterValue = optionValue);
} else {
return ExitStatus.failure(-1, format("Options[%s] type[%s] was unsupported.", optionName, type.getSimpleName()));
}
// FIXME hack for ongl strict
if (field.getName().equals("strict")) {
GlobalOptions.updateOnglStrict(Boolean.valueOf(optionValue));
logger.info("update ongl strict to: {}", optionValue);
}
} catch (Throwable t) {
return ExitStatus.failure(-1, format("Cannot cast option value[%s] to type[%s].", optionValue, type.getSimpleName()));
}
ChangeResultVO changeResultVO = new ChangeResultVO(optionAnnotation.name(), beforeValue, afterValue);
process.appendResult(new OptionsModel(changeResultVO));
return ExitStatus.success();
}
/**
* 判断当前动作是否需要展示整个options
*/
private boolean isShow() {
return StringUtils.isBlank(optionName) && StringUtils.isBlank(optionValue);
}
/**
* 判断当前动作是否需要展示某个Name的值
*/
private boolean isShowName() {
return !StringUtils.isBlank(optionName) && StringUtils.isBlank(optionValue);
}
private Collection<Field> findOptionFields(Matcher<String> optionNameMatcher) {
final Collection<Field> matchFields = new ArrayList<Field>();
for (final Field optionField : FieldUtils.getAllFields(GlobalOptions.class)) {
if (isMatchOptionAnnotation(optionField, optionNameMatcher)) {
matchFields.add(optionField);
}
}
return matchFields;
}
private Collection<String> findOptionNames(Matcher<String> optionNameMatcher) {
final Collection<String> matchOptionNames = new ArrayList<String>();
for (final Field optionField : FieldUtils.getAllFields(GlobalOptions.class)) {
if (isMatchOptionAnnotation(optionField, optionNameMatcher)) {
final Option optionAnnotation = optionField.getAnnotation(Option.class);
matchOptionNames.add(optionAnnotation.name());
}
}
return matchOptionNames;
}
private boolean isMatchOptionAnnotation(Field optionField, Matcher<String> optionNameMatcher) {
if (!optionField.isAnnotationPresent(Option.class)) {
return false;
}
final Option optionAnnotation = optionField.getAnnotation(Option.class);
return optionAnnotation != null && optionNameMatcher.matching(optionAnnotation.name());
}
private List<OptionVO> convertToOptionVOs(Collection<Field> fields) throws IllegalAccessException {
List<OptionVO> list = new ArrayList<OptionVO>();
for (Field field : fields) {
list.add(convertToOptionVO(field));
}
return list;
}
private OptionVO convertToOptionVO(Field optionField) throws IllegalAccessException {
Option optionAnnotation = optionField.getAnnotation(Option.class);
OptionVO optionVO = new OptionVO();
optionVO.setLevel(optionAnnotation.level());
optionVO.setName(optionAnnotation.name());
optionVO.setSummary(optionAnnotation.summary());
optionVO.setDescription(optionAnnotation.description());
optionVO.setType(optionField.getType().getSimpleName());
optionVO.setValue(""+optionField.get(null));
return optionVO;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/SystemPropertyCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/SystemPropertyCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.MessageModel;
import com.taobao.arthas.core.command.model.SystemPropertyModel;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* @author ralf0131 2017-01-09 14:03.
*/
@Name("sysprop")
@Summary("Display and change the system properties.")
@Description(Constants.EXAMPLE + " sysprop\n"+ " sysprop file.encoding\n" + " sysprop production.mode true\n" +
Constants.WIKI + Constants.WIKI_HOME + "sysprop")
public class SystemPropertyCommand extends AnnotatedCommand {
private String propertyName;
private String propertyValue;
@Argument(index = 0, argName = "property-name", required = false)
@Description("property name")
public void setOptionName(String propertyName) {
this.propertyName = propertyName;
}
@Argument(index = 1, argName = "property-value", required = false)
@Description("property value")
public void setOptionValue(String propertyValue) {
this.propertyValue = propertyValue;
}
@Override
public void process(CommandProcess process) {
try {
if (StringUtils.isBlank(propertyName) && StringUtils.isBlank(propertyValue)) {
// show all system properties
process.appendResult(new SystemPropertyModel(System.getProperties()));
} else if (StringUtils.isBlank(propertyValue)) {
// view the specified system property
String value = System.getProperty(propertyName);
if (value == null) {
process.end(1, "There is no property with the key " + propertyName);
return;
} else {
process.appendResult(new SystemPropertyModel(propertyName, value));
}
} else {
// change system property
System.setProperty(propertyName, propertyValue);
process.appendResult(new MessageModel("Successfully changed the system property."));
process.appendResult(new SystemPropertyModel(propertyName, System.getProperty(propertyName)));
}
process.end();
} catch (Throwable t) {
process.end(-1, "Error during setting system property: " + t.getMessage());
}
}
/**
* First, try to complete with the sysprop command scope.
* If completion is failed, delegates to super class.
* @param completion the completion object
*/
@Override
public void complete(Completion completion) {
CompletionUtils.complete(completion, System.getProperties().stringPropertyNames());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/Base64Command.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/Base64Command.java | package com.taobao.arthas.core.command.basic1000;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.common.IOUtils;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.Base64Model;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.base64.Base64;
import io.netty.util.CharsetUtil;
/**
*
* @author hengyunabc 2021-01-05
*
*/
@Name("base64")
@Summary("Encode and decode using Base64 representation")
@Description(Constants.EXAMPLE +
" base64 /tmp/test.txt\n" +
" base64 --input /tmp/test.txt --output /tmp/result.txt\n" +
" base64 -d /tmp/result.txt\n"
+ Constants.WIKI + Constants.WIKI_HOME + "base64")
public class Base64Command extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(Base64Command.class);
private String file;
private int sizeLimit = 128 * 1024;
private static final int MAX_SIZE_LIMIT = 8 * 1024 * 1024;
private boolean decode;
private String input;
private String output;
@Argument(argName = "file", index = 0, required = false)
@Description("file")
public void setFiles(String file) {
this.file = file;
}
@Option(shortName = "d", longName = "decode", flag = true)
@Description("decodes input")
public void setDecode(boolean decode) {
this.decode = decode;
}
@Option(shortName = "i", longName = "input")
@Description("input file")
public void setInput(String input) {
this.input = input;
}
@Option(shortName = "o", longName = "output")
@Description("output file")
public void setOutput(String output) {
this.output = output;
}
@Option(shortName = "M", longName = "sizeLimit")
@Description("Upper size limit in bytes for the result (128 * 1024 by default, the maximum value is 8 * 1024 * 1024)")
public void setSizeLimit(Integer sizeLimit) {
this.sizeLimit = sizeLimit;
}
@Override
public void process(CommandProcess process) {
if (!verifyOptions(process)) {
return;
}
// 确认输入
if (file == null) {
if (this.input != null) {
file = input;
} else {
process.end(-1, ": No file, nor input");
return;
}
}
File f = new File(file);
if (!f.exists()) {
process.end(-1, file + ": No such file or directory");
return;
}
if (f.isDirectory()) {
process.end(-1, file + ": Is a directory");
return;
}
if (f.length() > sizeLimit) {
process.end(-1, file + ": Is too large, size: " + f.length());
return;
}
InputStream input = null;
ByteBuf convertResult = null;
try {
input = new FileInputStream(f);
byte[] bytes = IOUtils.getBytes(input);
if (this.decode) {
convertResult = Base64.decode(Unpooled.wrappedBuffer(bytes));
} else {
convertResult = Base64.encode(Unpooled.wrappedBuffer(bytes));
}
if (this.output != null) {
int readableBytes = convertResult.readableBytes();
OutputStream out = new FileOutputStream(this.output);
convertResult.readBytes(out, readableBytes);
process.appendResult(new Base64Model(null));
} else {
String base64Str = convertResult.toString(CharsetUtil.UTF_8);
process.appendResult(new Base64Model(base64Str));
}
} catch (IOException e) {
logger.error("read file error. name: " + file, e);
process.end(1, "read file error: " + e.getMessage());
return;
} finally {
if (convertResult != null) {
convertResult.release();
}
IOUtils.close(input);
}
process.end();
}
private boolean verifyOptions(CommandProcess process) {
if(this.file == null && this.input == null) {
process.end(-1);
return false;
}
if (sizeLimit > MAX_SIZE_LIMIT) {
process.end(-1, "sizeLimit cannot be large than: " + MAX_SIZE_LIMIT);
return false;
}
// 目前不支持过滤,限制http请求执行的文件大小
int maxSizeLimitOfNonTty = 128 * 1024;
if (!process.session().isTty() && sizeLimit > maxSizeLimitOfNonTty) {
process.end(-1,
"When executing in non-tty session, sizeLimit cannot be large than: " + maxSizeLimitOfNonTty);
return false;
}
return true;
}
@Override
public void complete(Completion completion) {
if (!CompletionUtils.completeFilePath(completion)) {
super.complete(completion);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/TeeCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/TeeCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.*;
/**
* @author min.yang
*/
@Name("tee")
@Summary("tee command for pipes." )
@Description(Constants.EXAMPLE +
" sysprop | tee /path/to/logfile | grep java \n" +
" sysprop | tee -a /path/to/logfile | grep java \n"
+ Constants.WIKI + Constants.WIKI_HOME + "tee")
public class TeeCommand extends AnnotatedCommand {
private String filePath;
private boolean append;
@Argument(index = 0, argName = "file", required = false)
@Description("File path")
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@Option(shortName = "a", longName = "append", flag = true)
@Description("Append to file")
public void setRegEx(boolean append) {
this.append = append;
}
@Override
public void process(CommandProcess process) {
process.end(-1, "The tee command only for pipes. See 'tee --help'");
}
public String getFilePath() {
return filePath;
}
public boolean isAppend() {
return append;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/SystemEnvCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/SystemEnvCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.SystemEnvModel;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* @author hengyunabc 2018-11-09
*
*/
@Name("sysenv")
@Summary("Display the system env.")
@Description(Constants.EXAMPLE + " sysenv\n" + " sysenv USER\n" + Constants.WIKI + Constants.WIKI_HOME + "sysenv")
public class SystemEnvCommand extends AnnotatedCommand {
private String envName;
@Argument(index = 0, argName = "env-name", required = false)
@Description("env name")
public void setOptionName(String envName) {
this.envName = envName;
}
@Override
public void process(CommandProcess process) {
try {
SystemEnvModel result = new SystemEnvModel();
if (StringUtils.isBlank(envName)) {
// show all system env
result.putAll(System.getenv());
} else {
// view the specified system env
String value = System.getenv(envName);
result.put(envName, value);
}
process.appendResult(result);
process.end();
} catch (Throwable t) {
process.end(-1, "Error during setting system env: " + t.getMessage());
}
}
/**
* First, try to complete with the sysenv command scope. If completion is
* failed, delegates to super class.
*
* @param completion
* the completion object
*/
@Override
public void complete(Completion completion) {
CompletionUtils.complete(completion, System.getenv().keySet());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/ResetCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/ResetCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.advisor.Enhancer;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.ResetModel;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.matcher.Matcher;
import com.taobao.arthas.core.util.SearchUtils;
import com.taobao.arthas.core.util.affect.EnhancerAffect;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
/**
* 恢复所有增强类<br/>
*
* @author vlinux on 15/5/29.
*/
@Name("reset")
@Summary("Reset all the enhanced classes")
@Description(Constants.EXAMPLE +
" reset\n" +
" reset *List\n" +
" reset -E .*List\n")
public class ResetCommand extends AnnotatedCommand {
private String classPattern;
private boolean isRegEx = false;
@Argument(index = 0, argName = "class-pattern", required = false)
@Description("Path and classname of Pattern Matching")
public void setClassPattern(String classPattern) {
this.classPattern = classPattern;
}
@Option(shortName = "E", longName = "regex", flag = true)
@Description("Enable regular expression to match (wildcard matching by default)")
public void setRegEx(boolean regEx) {
isRegEx = regEx;
}
@Override
public void process(CommandProcess process) {
Instrumentation inst = process.session().getInstrumentation();
Matcher matcher = SearchUtils.classNameMatcher(classPattern, isRegEx);
try {
EnhancerAffect enhancerAffect = Enhancer.reset(inst, matcher);
process.appendResult(new ResetModel(enhancerAffect));
process.end();
} catch (UnmodifiableClassException e) {
// ignore
process.end();
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java | package com.taobao.arthas.core.command.basic1000;
import java.io.File;
import com.taobao.arthas.core.command.model.PwdModel;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
@Name("pwd")
@Summary("Return working directory name")
public class PwdCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
String path = new File("").getAbsolutePath();
process.appendResult(new PwdModel(path));
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/AuthCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/AuthCommand.java | package com.taobao.arthas.core.command.basic1000;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.common.ArthasConstants;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.security.BasicPrincipal;
import com.taobao.arthas.core.security.SecurityAuthenticator;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.session.Session;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.DefaultValue;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
/**
* TODO 支持更多的鉴权方式。目前只支持 username/password的方式
*
* @author hengyunabc 2021-03-03
*
*/
// @formatter:off
@Name(ArthasConstants.AUTH)
@Summary("Authenticates the current session")
@Description(Constants.EXAMPLE +
" auth\n" +
" auth <password>\n" +
" auth --username <username> <password>\n"
+ Constants.WIKI + Constants.WIKI_HOME + ArthasConstants.AUTH)
//@formatter:on
public class AuthCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(AuthCommand.class);
private String username;
private String password;
private SecurityAuthenticator authenticator = ArthasBootstrap.getInstance().getSecurityAuthenticator();
@Argument(argName = "password", index = 0, required = false)
@Description("password")
public void setPassword(String password) {
this.password = password;
}
@Option(shortName = "n", longName = "username")
@Description("username, default value 'arthas'")
@DefaultValue(ArthasConstants.DEFAULT_USERNAME)
public void setUsername(String username) {
this.username = username;
}
@Override
public void process(CommandProcess process) {
int status = 0;
String message = "";
try {
Session session = process.session();
if (username == null) {
status = 1;
message = "username can not be empty!";
return;
}
if (password == null) { // 没有传入password参数时,打印当前结果
boolean authenticated = session.get(ArthasConstants.SUBJECT_KEY) != null;
boolean needLogin = this.authenticator.needLogin();
message = "Authentication result: " + authenticated + ", Need authentication: " + needLogin;
if (needLogin && !authenticated) {
status = 1;
}
return;
} else {
// 尝试进行鉴权
BasicPrincipal principal = new BasicPrincipal(username, password);
try {
Subject subject = authenticator.login(principal);
if (subject != null) {
// 把subject 保存到 session里,后续其它命令则可以正常执行
session.put(ArthasConstants.SUBJECT_KEY, subject);
message = "Authentication result: " + true + ", username: " + username;
} else {
status = 1;
message = "Authentication result: " + false + ", username: " + username;
}
} catch (LoginException e) {
logger.error("Authentication error, username: {}", username, e);
}
}
} finally {
process.end(status, message);
}
}
@Override
public void complete(Completion completion) {
if (!CompletionUtils.completeFilePath(completion)) {
super.complete(completion);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java | package com.taobao.arthas.core.command.basic1000;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.ChangeResultVO;
import com.taobao.arthas.core.command.model.MessageModel;
import com.taobao.arthas.core.command.model.VMOptionModel;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* vmoption command
*
* @author hengyunabc 2019-09-02
*
*/
// @formatter:off
@Name("vmoption")
@Summary("Display, and update the vm diagnostic options.")
@Description("\nExamples:\n" +
" vmoption\n" +
" vmoption PrintGC\n" +
" vmoption PrintGC true\n" +
" vmoption PrintGCDetails true\n" +
Constants.WIKI + Constants.WIKI_HOME + "vmoption")
//@formatter:on
public class VMOptionCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(VMOptionCommand.class);
private String name;
private String value;
@Argument(index = 0, argName = "name", required = false)
@Description("VMOption name")
public void setOptionName(String name) {
this.name = name;
}
@Argument(index = 1, argName = "value", required = false)
@Description("VMOption value")
public void setOptionValue(String value) {
this.value = value;
}
@Override
public void process(CommandProcess process) {
run(process, name, value);
}
private static void run(CommandProcess process, String name, String value) {
try {
HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory
.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
if (StringUtils.isBlank(name) && StringUtils.isBlank(value)) {
// show all options
process.appendResult(new VMOptionModel(hotSpotDiagnosticMXBean.getDiagnosticOptions()));
} else if (StringUtils.isBlank(value)) {
// view the specified option
VMOption option = hotSpotDiagnosticMXBean.getVMOption(name);
if (option == null) {
process.end(-1, "In order to change the system properties, you must specify the property value.");
return;
} else {
process.appendResult(new VMOptionModel(Collections.singletonList(option)));
}
} else {
VMOption vmOption = hotSpotDiagnosticMXBean.getVMOption(name);
String originValue = vmOption.getValue();
// change vm option
hotSpotDiagnosticMXBean.setVMOption(name, value);
process.appendResult(new MessageModel("Successfully updated the vm option."));
process.appendResult(new VMOptionModel(new ChangeResultVO(name, originValue,
hotSpotDiagnosticMXBean.getVMOption(name).getValue())));
}
process.end();
} catch (Throwable t) {
logger.error("Error during setting vm option", t);
process.end(-1, "Error during setting vm option: " + t.getMessage());
}
}
@Override
public void complete(Completion completion) {
HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory
.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
List<VMOption> diagnosticOptions = hotSpotDiagnosticMXBean.getDiagnosticOptions();
List<String> names = new ArrayList<String>(diagnosticOptions.size());
for (VMOption option : diagnosticOptions) {
names.add(option.getName());
}
CompletionUtils.complete(completion, names);
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/CatCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/CatCommand.java | package com.taobao.arthas.core.command.basic1000;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import com.taobao.arthas.core.command.model.CatModel;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.FileUtils;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
@Name("cat")
@Summary("Concatenate and print files")
public class CatCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(CatCommand.class);
private List<String> files;
private String encoding;
private Integer sizeLimit = 128 * 1024;
private int maxSizeLimit = 8 * 1024 * 1024;
@Argument(argName = "files", index = 0)
@Description("files")
public void setFiles(List<String> files) {
this.files = files;
}
@Option(longName = "encoding")
@Description("File encoding")
public void setEncoding(String encoding) {
this.encoding = encoding;
}
@Option(shortName = "M", longName = "sizeLimit")
@Description("Upper size limit in bytes for the result (128 * 1024 by default, the maximum value is 8 * 1024 * 1024)")
public void setSizeLimit(Integer sizeLimit) {
this.sizeLimit = sizeLimit;
}
@Override
public void process(CommandProcess process) {
if (!verifyOptions(process)) {
return;
}
for (String file : files) {
File f = new File(file);
if (!f.exists()) {
process.end(-1, "cat " + file + ": No such file or directory");
return;
}
if (f.isDirectory()) {
process.end(-1, "cat " + file + ": Is a directory");
return;
}
}
for (String file : files) {
File f = new File(file);
if (f.length() > sizeLimit) {
process.end(-1, "cat " + file + ": Is too large, size: " + f.length());
return;
}
try {
String fileToString = FileUtils.readFileToString(f,
encoding == null ? Charset.defaultCharset() : Charset.forName(encoding));
process.appendResult(new CatModel(file, fileToString));
} catch (IOException e) {
logger.error("cat read file error. name: " + file, e);
process.end(1, "cat read file error: " + e.getMessage());
return;
}
}
process.end();
}
private boolean verifyOptions(CommandProcess process) {
if (sizeLimit > maxSizeLimit) {
process.end(-1, "sizeLimit cannot be large than: " + maxSizeLimit);
return false;
}
//目前不支持过滤,限制http请求执行的文件大小
int maxSizeLimitOfNonTty = 128 * 1024;
if (!process.session().isTty() && sizeLimit > maxSizeLimitOfNonTty) {
process.end(-1, "When executing in non-tty session, sizeLimit cannot be large than: " + maxSizeLimitOfNonTty);
return false;
}
return true;
}
@Override
public void complete(Completion completion) {
if (!CompletionUtils.completeFilePath(completion)) {
super.complete(completion);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/KeymapCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/KeymapCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.common.IOUtils;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.term.impl.Helper;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
import com.taobao.text.Decoration;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import static com.taobao.text.ui.Element.label;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* A command to display all the keymap for the specified connection.
*
* @author ralf0131 2016-12-15 17:27.
* @author hengyunabc 2019-01-18
*/
@Name("keymap")
@Summary("Display all the available keymap for the specified connection.")
@Description(Constants.WIKI + Constants.WIKI_HOME + "keymap")
public class KeymapCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(KeymapCommand.class);
@Override
public void process(CommandProcess process) {
if (!process.session().isTty()) {
process.end(-1, "Command 'keymap' is only support tty session.");
return;
}
InputStream inputrc = Helper.loadInputRcFile();
try {
TableElement table = new TableElement(1, 1, 2).leftCellPadding(1).rightCellPadding(1);
table.row(true, label("Shortcut").style(Decoration.bold.bold()),
label("Description").style(Decoration.bold.bold()),
label("Name").style(Decoration.bold.bold()));
BufferedReader br = new BufferedReader(new InputStreamReader(inputrc));
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || "".equals(line)) {
continue;
}
String[] strings = line.split(":");
if (strings.length == 2) {
table.row(strings[0], translate(strings[0]), strings[1]);
} else {
table.row(line);
}
}
process.write(RenderUtil.render(table, process.width()));
} catch (IOException e) {
logger.error("read inputrc file error.", e);
} finally {
IOUtils.close(inputrc);
process.end();
}
}
private String translate(String key) {
if (key.length() == 6 && key.startsWith("\"\\C-") && key.endsWith("\"")) {
char ch = key.charAt(4);
if ((ch >= 'a' && ch <= 'z') || ch == '?') {
return "Ctrl + " + ch;
}
}
if (key.equals("\"\\e[D\"")) {
return "Left arrow";
} else if (key.equals("\"\\e[C\"")) {
return "Right arrow";
} else if (key.equals("\"\\e[B\"")) {
return "Down arrow";
} else if (key.equals("\"\\e[A\"")) {
return "Up arrow";
}
return key;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/JFRCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/JFRCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.JFRModel;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.cli.CliToken;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Option;
import com.taobao.middleware.cli.annotations.Summary;
import jdk.jfr.Configuration;
import jdk.jfr.Recording;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@Name("jfr")
@Summary("Java Flight Recorder Command")
@Description(Constants.EXAMPLE +
" jfr start # start a new JFR recording\n" +
" jfr start -n myRecording --duration 60s -f /tmp/myRecording.jfr \n" +
" jfr status # list all recordings\n" +
" jfr status -r 1 # list recording id = 1 \n" +
" jfr status --state running # list recordings state = running\n" +
" jfr stop -r 1 # stop a JFR recording to default file\n" +
" jfr stop -r 1 -f /tmp/myRecording.jfr\n" +
" jfr dump -r 1 # copy contents of a JFR recording to default file\n" +
" jfr dump -r 1 -f /tmp/myRecording.jfr\n" +
Constants.WIKI + Constants.WIKI_HOME + "jfr")
public class JFRCommand extends AnnotatedCommand {
private String cmd;
private String name;
private String settings;
private Boolean dumpOnExit;
private String delay;
private String duration;
private String filename;
private String maxAge;
private String maxSize;
private Long recording;
private String state;
private JFRModel result = new JFRModel();
private static Map<Long, Recording> recordings = new ConcurrentHashMap<Long, Recording>();
@Argument(index = 0, argName = "cmd", required = true)
@Description("command name (start status stop dump)")
public void setCmd(String cmd) {
this.cmd = cmd;
}
@Option(shortName = "n", longName = "name")
@Description("Name that can be used to identify recording, e.g. \"My Recording\"")
public void setName(String name) {
this.name = name;
}
@Option(shortName = "s", longName = "settings")
@Description("Settings file(s), e.g. profile or default. See JRE_HOME/lib/jfr (STRING , default)")
public void setSettings(String settings) {
this.settings = settings;
}
@Option(longName = "dumponexit")
@Description("Dump running recording when JVM shuts down (BOOLEAN, false)")
public void setDumpOnExit(Boolean dumpOnExit) {
this.dumpOnExit = dumpOnExit;
}
@Option(shortName = "d", longName = "delay")
@Description("Delay recording start with (s)econds, (m)inutes), (h)ours), or (d)ays, e.g. 5h. (NANOTIME, 0)")
public void setDelay(String delay) {
this.delay = delay;
}
@Option(longName = "duration")
@Description("Duration of recording in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 300s. (NANOTIME, 0)")
public void setDuration(String duration) {
this.duration = duration;
}
@Option(shortName = "f", longName = "filename")
@Description("Resulting recording filename, e.g. /tmp/MyRecording.jfr.")
public void setFilename(String filename) {
this.filename = filename;
}
@Option(longName = "maxage")
@Description("Maximum time to keep recorded data (on disk) in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or default for no limit (NANOTIME, 0)")
public void setMaxAge(String maxAge) {
this.maxAge = maxAge;
}
@Option(longName = "maxsize")
@Description("Maximum amount of bytes to keep (on disk) in (k)B, (M)B or (G)B, e.g. 500M, 0 for no limit (MEMORY SIZE, 250MB)")
public void setMaxSize(String maxSize) {
this.maxSize = maxSize;
}
@Option(shortName = "r", longName = "recording")
@Description("Recording number, or omit to see all recordings (LONG, -1)")
public void setRecording(Long recording) {
this.recording = recording;
}
@Option(longName = "state")
@Description("Query recordings by sate (new, delay, running, stopped, closed)")
public void setState(String state) {
this.state = state;
}
public String getCmd() {
return cmd;
}
public String getName() {
return name;
}
public String getSettings() {
return settings;
}
public Boolean isDumpOnExit() {
return dumpOnExit;
}
public String getDelay() {
return delay;
}
public String getDuration() {
return duration;
}
public String getFilename() {
return filename;
}
public String getMaxAge() {
return maxAge;
}
public String getMaxSize() {
return maxSize;
}
public Long getRecording() {
return recording;
}
public String getState() {
return state;
}
@Override
public void process(CommandProcess process) {
if ("start".equals(cmd)) {
Configuration c = null;
try {
if (getSettings() == null) {
setSettings("default");
}
c = Configuration.getConfiguration(settings);
} catch (Throwable e) {
process.end(-1, "Could not start recording, not able to read settings");
}
Recording r = new Recording(c);
if (getFilename() != null) {
try {
r.setDestination(Paths.get(getFilename()));
} catch (IOException e) {
r.close();
process.end(-1, "Could not start recording, not able to write to file " + getFilename() + e.getMessage());
}
}
if (getMaxSize() != null) {
try {
r.setMaxSize(parseSize(getMaxSize()));
} catch (Exception e) {
process.end(-1, e.getMessage());
}
}
if (getMaxAge() != null) {
try {
r.setMaxAge(Duration.ofNanos(parseTimespan(getMaxAge())));
} catch (Exception e) {
process.end(-1, e.getMessage());
}
}
if (isDumpOnExit() != false) {
r.setDumpOnExit(isDumpOnExit().booleanValue());
}
if (getDuration() != null) {
try {
r.setDuration(Duration.ofNanos(parseTimespan(getDuration())));
} catch (Exception e) {
process.end(-1, e.getMessage());
}
}
if (getName() == null) {
r.setName("Recording-" + r.getId());
} else {
r.setName(getName());
}
long id = r.getId();
recordings.put(id, r);
if (getDelay() != null) {
try {
r.scheduleStart(Duration.ofNanos(parseTimespan(getDelay())));
} catch (Exception e) {
process.end(-1, e.getMessage());
}
result.setJfrOutput("Recording " + r.getId() + " scheduled to start in " + getDelay());
} else {
r.start();
result.setJfrOutput("Started recording " + r.getId() + ".");
}
if (duration == null && maxAge == null && maxSize == null) {
result.setJfrOutput(" No limit specified, using maxsize=250MB as default.");
r.setMaxSize(250 * 1024L * 1024L);
}
if (filename != null && duration != null) {
result.setJfrOutput(" The result will be written to:\n" + filename);
}
} else if ("status".equals(cmd)) {
// list recording id = recording
if (getRecording() != null) {
Recording r = recordings.get(getRecording());
if (r == null) {
process.end(-1, "recording not exit");
}
printRecording(r);
} else {// list all recordings
List<Recording> recordingList;
if (state != null) {
recordingList = findRecordingByState(state);
} else {
recordingList = new ArrayList<Recording>(recordings.values());
}
if (recordingList.isEmpty()) {
process.end(-1, "No available recordings.\n Use jfr start to start a recording.\n");
} else {
for (Recording recording : recordingList) {
printRecording(recording);
}
}
}
} else if ("dump".equals(cmd)) {
if (recordings.isEmpty()) {
process.end(-1, "No recordings to dump. Use jfr start to start a recording.");
}
if (getRecording() != null) {
Recording r = recordings.get(getRecording());
if (r == null) {
process.end(-1, "recording not exit");
}
if (getFilename() == null) {
try {
setFilename(outputFile());
} catch (IOException e) {
process.end(-1, e.getMessage());
}
}
try {
r.dump(Paths.get(getFilename()));
} catch (IOException e) {
process.end(-1, "Could not to dump. " + e.getMessage());
}
result.setJfrOutput("Dump recording " + r.getId() + ", The result will be written to:\n" + getFilename());
} else {
process.end(-1, "Failed to dump. Please input recording id");
}
} else if ("stop".equals(cmd)) {
if (recordings.isEmpty()) {
process.end(-1, "No recordings to stop. Use jfr start to start a recording.");
}
if (getRecording() != null) {
Recording r = recordings.remove(getRecording());
if (r == null) {
process.end(-1, "recording not exit");
}
if ("CLOSED".equals(r.getState().toString()) || "STOPPED".equals(r.getState().toString())) {
process.end(-1, "Failed to stop recording, state can not be closed/stopped");
}
if (getFilename() == null) {
try {
setFilename(outputFile());
} catch (IOException e) {
process.end(-1, e.getMessage());
}
}
try {
r.setDestination(Paths.get(getFilename()));
} catch (IOException e) {
process.end(-1, "Failed to stop " + r.getName() + ". Could not set destination for " + filename + "to file" + e.getMessage());
}
r.stop();
result.setJfrOutput("Stop recording " + r.getId() + ", The result will be written to:\n" + getFilename());
r.close();
} else {
process.end(-1, "Failed to stop. please input recording id");
}
} else {
process.end(-1, "Please input correct jfr command (start status stop dump)");
}
process.appendResult(result);
process.end();
}
public long parseSize(String s) throws Exception {
s = s.toLowerCase();
if (s.endsWith("b")) {
return Long.parseLong(s.substring(0, s.length() - 1).trim());
} else if (s.endsWith("k")) {
return 1024 * Long.parseLong(s.substring(0, s.length() - 1).trim());
} else if (s.endsWith("m")) {
return 1024 * 1024 * Long.parseLong(s.substring(0, s.length() - 1).trim());
} else if (s.endsWith("g")) {
return 1024 * 1024 * 1024 * Long.parseLong(s.substring(0, s.length() - 1).trim());
} else {
try {
return Long.parseLong(s);
} catch (Exception e) {
throw new NumberFormatException("'" + s + "' is not a valid size. Should be numeric value followed by a unit, i.e. 20M. Valid units k, M, G");
}
}
}
public long parseTimespan(String s) throws Exception {
s = s.toLowerCase();
if (s.endsWith("s")) {
return TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);
} else if (s.endsWith("m")) {
return 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);
} else if (s.endsWith("h")) {
return 60 * 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);
} else if (s.endsWith("d")) {
return 24 * 60 * 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);
} else {
try {
return Long.parseLong(s);
} catch (NumberFormatException var2) {
throw new NumberFormatException("'" + s + "' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20s. Valid units s, m, h and d.");
}
}
}
private List<Recording> findRecordingByState(String state) {
List<Recording> resultRecordingList = new ArrayList<Recording>();
Collection<Recording> recordingList = recordings.values();
for (Recording recording : recordingList) {
if (recording.getState().toString().toLowerCase().equals(state)) {
resultRecordingList.add(recording);
}
}
return resultRecordingList;
}
private void printRecording(Recording recording) {
String format = "Recording: recording=" + recording.getId() + " name=" + recording.getName() + "";
result.setJfrOutput(format);
Duration duration = recording.getDuration();
if (duration != null) {
result.setJfrOutput(" duration=" + duration.toString());
}
result.setJfrOutput(" (" + recording.getState().toString().toLowerCase() + ")\n");
}
private String outputFile() throws IOException {
if (this.filename == null) {
File outputPath = ArthasBootstrap.getInstance().getOutputPath();
if (outputPath != null) {
this.filename = new File(outputPath,
new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()) + ".jfr")
.getAbsolutePath();
} else {
this.filename = File.createTempFile("arthas-output", ".jfr").getAbsolutePath();
}
}
return filename;
}
@Override
public void complete(Completion completion) {
List<CliToken> tokens = completion.lineTokens();
String token = tokens.get(tokens.size() - 1).value();
if (token.startsWith("-")) {
super.complete(completion);
return;
}
List<String> cmd = Arrays.asList("start", "status", "dump", "stop");
CompletionUtils.complete(completion, cmd);
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/EchoCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/EchoCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.Constants;
import com.taobao.arthas.core.command.model.EchoModel;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
*
* @author hengyunabc
*
*/
@Name("echo")
@Summary("write arguments to the standard output")
@Description("\nExamples:\n" +
" echo 'abc'\n" +
Constants.WIKI + Constants.WIKI_HOME + "echo")
public class EchoCommand extends AnnotatedCommand {
private String message;
@Argument(argName = "message", index = 0, required = false)
@Description("message")
public void setMessage(String message) {
this.message = message;
}
@Override
public void process(CommandProcess process) {
if (message != null) {
process.appendResult(new EchoModel(message));
}
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/VersionCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/VersionCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.model.VersionModel;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.ArthasBanner;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* 输出版本
*
* @author vlinux
*/
@Name("version")
@Summary("Display Arthas version")
public class VersionCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
VersionModel result = new VersionModel();
result.setVersion(ArthasBanner.version());
process.appendResult(result);
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/ClsCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/ClsCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
import com.taobao.text.util.RenderUtil;
@Name("cls")
@Summary("Clear the screen")
public class ClsCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
if (!process.session().isTty()) {
process.end(-1, "Command 'cls' is only support tty session.");
return;
}
process.write(RenderUtil.cls()).write("\n");
process.end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/HelpCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/HelpCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.command.model.ArgumentVO;
import com.taobao.arthas.core.command.model.CommandOptionVO;
import com.taobao.arthas.core.command.model.CommandVO;
import com.taobao.arthas.core.command.model.HelpModel;
import com.taobao.arthas.core.shell.cli.Completion;
import com.taobao.arthas.core.shell.cli.CompletionUtils;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.Command;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.command.CommandResolver;
import com.taobao.arthas.core.shell.session.Session;
import com.taobao.arthas.core.util.usage.StyledUsageFormatter;
import com.taobao.middleware.cli.CLI;
import com.taobao.middleware.cli.Option;
import com.taobao.middleware.cli.annotations.Argument;
import com.taobao.middleware.cli.annotations.Description;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
import java.util.ArrayList;
import java.util.List;
/**
* @author vlinux on 14/10/26.
*/
@Name("help")
@Summary("Display Arthas Help")
@Description("Examples:\n" + " help\n" + " help sc\n" + " help sm\n" + " help watch")
public class HelpCommand extends AnnotatedCommand {
private String cmd;
@Argument(index = 0, argName = "cmd", required = false)
@Description("command name")
public void setCmd(String cmd) {
this.cmd = cmd;
}
@Override
public void process(CommandProcess process) {
List<Command> commands = allCommands(process.session());
Command targetCmd = findCommand(commands);
if (targetCmd == null) {
process.appendResult(createHelpModel(commands));
} else {
process.appendResult(createHelpDetailModel(targetCmd));
}
process.end();
}
public HelpModel createHelpDetailModel(Command targetCmd) {
return new HelpModel(createCommandVO(targetCmd, true));
}
private HelpModel createHelpModel(List<Command> commands) {
HelpModel helpModel = new HelpModel();
for (Command command : commands) {
if(command.cli() == null || command.cli().isHidden()){
continue;
}
helpModel.addCommandVO(createCommandVO(command, false));
}
return helpModel;
}
private CommandVO createCommandVO(Command command, boolean withDetail) {
CLI cli = command.cli();
CommandVO commandVO = new CommandVO();
commandVO.setName(command.name());
if (cli!=null){
commandVO.setSummary(cli.getSummary());
if (withDetail){
commandVO.setCli(cli);
StyledUsageFormatter usageFormatter = new StyledUsageFormatter(null);
String usageLine = usageFormatter.computeUsageLine(null, cli);
commandVO.setUsage(usageLine);
commandVO.setDescription(cli.getDescription());
//以线程安全的方式遍历options
List<Option> options = cli.getOptions();
for (int i = 0; i < options.size(); i++) {
Option option = options.get(i);
if (option.isHidden()){
continue;
}
commandVO.addOption(createOptionVO(option));
}
//arguments
List<com.taobao.middleware.cli.Argument> arguments = cli.getArguments();
for (int i = 0; i < arguments.size(); i++) {
com.taobao.middleware.cli.Argument argument = arguments.get(i);
if (argument.isHidden()){
continue;
}
commandVO.addArgument(createArgumentVO(argument));
}
}
}
return commandVO;
}
private ArgumentVO createArgumentVO(com.taobao.middleware.cli.Argument argument) {
ArgumentVO argumentVO = new ArgumentVO();
argumentVO.setArgName(argument.getArgName());
argumentVO.setMultiValued(argument.isMultiValued());
argumentVO.setRequired(argument.isRequired());
return argumentVO;
}
private CommandOptionVO createOptionVO(Option option) {
CommandOptionVO optionVO = new CommandOptionVO();
if (!isEmptyName(option.getLongName())) {
optionVO.setLongName(option.getLongName());
}
if (!isEmptyName(option.getShortName())) {
optionVO.setShortName(option.getShortName());
}
optionVO.setDescription(option.getDescription());
optionVO.setAcceptValue(option.acceptValue());
return optionVO;
}
private boolean isEmptyName(String name) {
return name == null || name.equals(Option.NO_NAME);
}
@Override
public void complete(Completion completion) {
List<Command> commands = allCommands(completion.session());
List<String> names = new ArrayList<String>(commands.size());
for (Command command : commands) {
CLI cli = command.cli();
if (cli == null || cli.isHidden()) {
continue;
}
names.add(command.name());
}
CompletionUtils.complete(completion, names);
}
private List<Command> allCommands(Session session) {
List<CommandResolver> commandResolvers = session.getCommandResolvers();
List<Command> commands = new ArrayList<Command>();
for (CommandResolver commandResolver : commandResolvers) {
commands.addAll(commandResolver.commands());
}
return commands;
}
private Command findCommand(List<Command> commands) {
for (Command command : commands) {
if (command.name().equals(cmd)) {
return command;
}
}
return null;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/basic1000/StopCommand.java | core/src/main/java/com/taobao/arthas/core/command/basic1000/StopCommand.java | package com.taobao.arthas.core.command.basic1000;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.core.command.model.MessageModel;
import com.taobao.arthas.core.command.model.ResetModel;
import com.taobao.arthas.core.command.model.ShutdownModel;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.affect.EnhancerAffect;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* @author hengyunabc 2019-07-05
*/
@Name("stop")
@Summary("Stop/Shutdown Arthas server and exit the console.")
public class StopCommand extends AnnotatedCommand {
private static final Logger logger = LoggerFactory.getLogger(StopCommand.class);
@Override
public void process(CommandProcess process) {
shutdown(process);
}
private static void shutdown(CommandProcess process) {
ArthasBootstrap arthasBootstrap = ArthasBootstrap.getInstance();
try {
// 退出之前需要重置所有的增强类
process.appendResult(new MessageModel("Resetting all enhanced classes ..."));
EnhancerAffect enhancerAffect = arthasBootstrap.reset();
process.appendResult(new ResetModel(enhancerAffect));
process.appendResult(new ShutdownModel(true, "Arthas Server is going to shutdown..."));
} catch (Throwable e) {
logger.error("An error occurred when stopping arthas server.", e);
process.appendResult(new ShutdownModel(false, "An error occurred when stopping arthas server."));
} finally {
process.end();
arthasBootstrap.destroy();
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/hidden/JulyCommand.java | core/src/main/java/com/taobao/arthas/core/command/hidden/JulyCommand.java | package com.taobao.arthas.core.command.hidden;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.middleware.cli.annotations.Hidden;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* @author vlinux on 02/11/2016.
*/
@Name("july")
@Summary("don't ask why")
@Hidden
public class JulyCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
process.write(new String($$())).write("\n").end();
}
private static byte[] $$() {
return new byte[]{
0x49, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65,
0x20, 0x73, 0x61, 0x6d, 0x65, 0x20, 0x6d, 0x69, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x74, 0x68, 0x61, 0x74,
0x20, 0x79, 0x6f, 0x75, 0x20, 0x64, 0x69, 0x64, 0x0a, 0x49, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x6e, 0x6f, 0x74,
0x20, 0x6c, 0x65, 0x74, 0x20, 0x6d, 0x79, 0x73, 0x65, 0x6c, 0x66, 0x0a, 0x43, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6d,
0x79, 0x20, 0x68, 0x65, 0x61, 0x72, 0x74, 0x20, 0x73, 0x6f, 0x20, 0x6d, 0x75, 0x63, 0x68, 0x20, 0x6d, 0x69, 0x73,
0x65, 0x72, 0x79, 0x0a, 0x49, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x62, 0x72, 0x65, 0x61,
0x6b, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x61, 0x79, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x64, 0x69, 0x64, 0x0a, 0x59,
0x6f, 0x75, 0x20, 0x66, 0x65, 0x6c, 0x6c, 0x20, 0x73, 0x6f, 0x20, 0x68, 0x61, 0x72, 0x64, 0x0a, 0x0a, 0x49, 0x20,
0x76, 0x65, 0x20, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x61, 0x72, 0x64,
0x20, 0x77, 0x61, 0x79, 0x0a, 0x54, 0x6f, 0x20, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x69,
0x74, 0x20, 0x67, 0x65, 0x74, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x66, 0x61, 0x72, 0x0a, 0x0a, 0x42, 0x65, 0x63,
0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6e, 0x65, 0x76, 0x65, 0x72,
0x20, 0x73, 0x74, 0x72, 0x61, 0x79, 0x20, 0x74, 0x6f, 0x6f, 0x20, 0x66, 0x61, 0x72, 0x20, 0x66, 0x72, 0x6f, 0x6d,
0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x69, 0x64, 0x65, 0x77, 0x61, 0x6c, 0x6b, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75,
0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64,
0x20, 0x74, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x66,
0x65, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x73, 0x6f, 0x20, 0x49, 0x20, 0x64, 0x6f, 0x6e, 0x20, 0x74, 0x20, 0x67,
0x65, 0x74, 0x20, 0x68, 0x75, 0x72, 0x74, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20,
0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x20, 0x69, 0x74, 0x20, 0x68, 0x61, 0x72, 0x64, 0x20,
0x74, 0x6f, 0x20, 0x74, 0x72, 0x75, 0x73, 0x74, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x6d,
0x65, 0x2c, 0x20, 0x62, 0x75, 0x74, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x20, 0x61, 0x72, 0x6f,
0x75, 0x6e, 0x64, 0x20, 0x6d, 0x65, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79,
0x6f, 0x75, 0x0a, 0x49, 0x20, 0x61, 0x6d, 0x20, 0x61, 0x66, 0x72, 0x61, 0x69, 0x64, 0x0a, 0x0a, 0x49, 0x20, 0x6c,
0x6f, 0x73, 0x65, 0x20, 0x6d, 0x79, 0x20, 0x77, 0x61, 0x79, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x69, 0x74, 0x20, 0x73,
0x20, 0x6e, 0x6f, 0x74, 0x20, 0x74, 0x6f, 0x6f, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x62, 0x65, 0x66, 0x6f, 0x72,
0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x69, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x0a,
0x49, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x72, 0x79, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73,
0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6b, 0x6e, 0x6f, 0x77, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x73, 0x20, 0x77,
0x65, 0x61, 0x6b, 0x6e, 0x65, 0x73, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x65, 0x79, 0x65,
0x73, 0x0a, 0x49, 0x20, 0x6d, 0x20, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x66, 0x61, 0x6b,
0x65, 0x0a, 0x41, 0x20, 0x73, 0x6d, 0x69, 0x6c, 0x65, 0x2c, 0x20, 0x61, 0x20, 0x6c, 0x61, 0x75, 0x67, 0x68, 0x20,
0x65, 0x76, 0x65, 0x72, 0x79, 0x64, 0x61, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x6d, 0x79, 0x20, 0x6c, 0x69, 0x66, 0x65,
0x0a, 0x4d, 0x79, 0x20, 0x68, 0x65, 0x61, 0x72, 0x74, 0x20, 0x63, 0x61, 0x6e, 0x27, 0x74, 0x20, 0x70, 0x6f, 0x73,
0x73, 0x69, 0x62, 0x6c, 0x79, 0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x0a, 0x57, 0x68, 0x65, 0x6e, 0x20, 0x69, 0x74,
0x20, 0x77, 0x61, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x77, 0x68, 0x6f, 0x6c, 0x65, 0x20,
0x74, 0x6f, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68, 0x0a, 0x0a, 0x42, 0x65, 0x63, 0x61,
0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20,
0x73, 0x74, 0x72, 0x61, 0x79, 0x20, 0x74, 0x6f, 0x6f, 0x20, 0x66, 0x61, 0x72, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20,
0x74, 0x68, 0x65, 0x20, 0x73, 0x69, 0x64, 0x65, 0x77, 0x61, 0x6c, 0x6b, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73,
0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x20,
0x74, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x66, 0x65,
0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x73, 0x6f, 0x20, 0x49, 0x20, 0x64, 0x6f, 0x6e, 0x20, 0x74, 0x20, 0x67, 0x65,
0x74, 0x20, 0x68, 0x75, 0x72, 0x74, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79,
0x6f, 0x75, 0x0a, 0x49, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x20, 0x69, 0x74, 0x20, 0x68, 0x61, 0x72, 0x64, 0x20, 0x74,
0x6f, 0x20, 0x74, 0x72, 0x75, 0x73, 0x74, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x6d, 0x65,
0x2c, 0x20, 0x62, 0x75, 0x74, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x20, 0x61, 0x72, 0x6f, 0x75,
0x6e, 0x64, 0x20, 0x6d, 0x65, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f,
0x75, 0x0a, 0x49, 0x20, 0x61, 0x6d, 0x20, 0x61, 0x66, 0x72, 0x61, 0x69, 0x64, 0x0a, 0x0a, 0x49, 0x20, 0x77, 0x61,
0x74, 0x63, 0x68, 0x65, 0x64, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x64, 0x69, 0x65, 0x0a, 0x49, 0x20, 0x68, 0x65, 0x61,
0x72, 0x64, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x72, 0x79, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x20, 0x6e, 0x69,
0x67, 0x68, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x0a, 0x49,
0x20, 0x77, 0x61, 0x73, 0x20, 0x73, 0x6f, 0x20, 0x79, 0x6f, 0x75, 0x6e, 0x67, 0x0a, 0x59, 0x6f, 0x75, 0x20, 0x73,
0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x62, 0x65,
0x74, 0x74, 0x65, 0x72, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x65, 0x61, 0x6e, 0x20, 0x6f,
0x6e, 0x20, 0x6d, 0x65, 0x0a, 0x59, 0x6f, 0x75, 0x20, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x74, 0x68, 0x6f, 0x75,
0x67, 0x68, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x79, 0x6f, 0x6e, 0x65, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a,
0x59, 0x6f, 0x75, 0x20, 0x6a, 0x75, 0x73, 0x74, 0x20, 0x73, 0x61, 0x77, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x70,
0x61, 0x69, 0x6e, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x77, 0x20, 0x49, 0x20, 0x63, 0x72, 0x79, 0x20, 0x69,
0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65,
0x20, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x0a, 0x46, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65,
0x20, 0x64, 0x61, 0x6d, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x0a, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73,
0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74,
0x72, 0x61, 0x79, 0x20, 0x74, 0x6f, 0x6f, 0x20, 0x66, 0x61, 0x72, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68,
0x65, 0x20, 0x73, 0x69, 0x64, 0x65, 0x77, 0x61, 0x6c, 0x6b, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20,
0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49, 0x20, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x74, 0x6f,
0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x66, 0x65, 0x20, 0x73,
0x69, 0x64, 0x65, 0x20, 0x73, 0x6f, 0x20, 0x49, 0x20, 0x64, 0x6f, 0x6e, 0x20, 0x74, 0x20, 0x67, 0x65, 0x74, 0x20,
0x68, 0x75, 0x72, 0x74, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75,
0x0a, 0x49, 0x20, 0x74, 0x72, 0x79, 0x20, 0x6d, 0x79, 0x20, 0x68, 0x61, 0x72, 0x64, 0x65, 0x73, 0x74, 0x20, 0x6a,
0x75, 0x73, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x66, 0x6f, 0x72, 0x67, 0x65, 0x74, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79,
0x74, 0x68, 0x69, 0x6e, 0x67, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f,
0x75, 0x0a, 0x49, 0x20, 0x64, 0x6f, 0x6e, 0x20, 0x74, 0x20, 0x6b, 0x6e, 0x6f, 0x77, 0x20, 0x68, 0x6f, 0x77, 0x20,
0x74, 0x6f, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x61, 0x6e, 0x79, 0x6f, 0x6e, 0x65, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
0x69, 0x6e, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49,
0x20, 0x6d, 0x20, 0x61, 0x73, 0x68, 0x61, 0x6d, 0x65, 0x64, 0x20, 0x6f, 0x66, 0x20, 0x6d, 0x79, 0x20, 0x6c, 0x69,
0x66, 0x65, 0x20, 0x62, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x69, 0x74, 0x20, 0x73, 0x20, 0x65, 0x6d, 0x70,
0x74, 0x79, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x49,
0x20, 0x61, 0x6d, 0x20, 0x61, 0x66, 0x72, 0x61, 0x69, 0x64, 0x0a, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65,
0x20, 0x6f, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x0a, 0x42, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20,
0x79, 0x6f, 0x75, 0x0a, 0x2e, 0x2e, 0x2e, 0x0a, /*0x0a, 0x66, 0x6f, 0x72, 0x20, 0x6a, 0x75, 0x6c, 0x79, 0x0a, 0x0a,*/
};
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/hidden/ThanksCommand.java | core/src/main/java/com/taobao/arthas/core/command/hidden/ThanksCommand.java | package com.taobao.arthas.core.command.hidden;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.ArthasBanner;
import com.taobao.middleware.cli.annotations.Hidden;
import com.taobao.middleware.cli.annotations.Name;
import com.taobao.middleware.cli.annotations.Summary;
/**
* 工具介绍<br/>
* 感谢
*
* @author vlinux on 15/9/1.
*/
@Name("thanks")
@Summary("Credits to all personnel and organization who either contribute or help to this product. Thanks you all!")
@Hidden
public class ThanksCommand extends AnnotatedCommand {
@Override
public void process(CommandProcess process) {
process.write(ArthasBanner.credit()).write("\n").end();
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/PwdView.java | core/src/main/java/com/taobao/arthas/core/command/view/PwdView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.PwdModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/5/11
*/
public class PwdView extends ResultView<PwdModel> {
@Override
public void draw(CommandProcess process, PwdModel result) {
process.write(result.getWorkingDir()).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/PerfCounterView.java | core/src/main/java/com/taobao/arthas/core/command/view/PerfCounterView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.PerfCounterModel;
import com.taobao.arthas.core.command.model.PerfCounterVO;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.text.Decoration;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import java.util.List;
import static com.taobao.text.ui.Element.label;
/**
* View of 'perfcounter' command
*
* @author gongdewei 2020/4/27
*/
public class PerfCounterView extends ResultView<PerfCounterModel> {
@Override
public void draw(CommandProcess process, PerfCounterModel result) {
List<PerfCounterVO> perfCounters = result.getPerfCounters();
boolean details = result.isDetails();
TableElement table;
if (details) {
table = new TableElement(3, 1, 1, 10).leftCellPadding(1).rightCellPadding(1);
table.row(true, label("Name").style(Decoration.bold.bold()),
label("Variability").style(Decoration.bold.bold()),
label("Units").style(Decoration.bold.bold()), label("Value").style(Decoration.bold.bold()));
} else {
table = new TableElement(4, 6).leftCellPadding(1).rightCellPadding(1);
table.row(true, label("Name").style(Decoration.bold.bold()),
label("Value").style(Decoration.bold.bold()));
}
for (PerfCounterVO counter : perfCounters) {
if (details) {
table.row(counter.getName(), counter.getVariability(),
counter.getUnits(), String.valueOf(counter.getValue()));
} else {
table.row(counter.getName(), String.valueOf(counter.getValue()));
}
}
process.write(RenderUtil.render(table, process.width()));
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/MemoryCompilerView.java | core/src/main/java/com/taobao/arthas/core/command/view/MemoryCompilerView.java | 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) {
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
process.write("Memory compiler output:\n");
for (String file : result.getFiles()) {
process.write(file + '\n');
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ProfilerView.java | core/src/main/java/com/taobao/arthas/core/command/view/ProfilerView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ProfilerModel;
import com.taobao.arthas.core.command.monitor200.ProfilerCommand.ProfilerAction;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* Term view for ProfilerModel
*
* @author gongdewei 2020/4/27
*/
public class ProfilerView extends ResultView<ProfilerModel> {
@Override
public void draw(CommandProcess process, ProfilerModel model) {
if (model.getSupportedActions() != null) {
process.write("Supported Actions: " + model.getSupportedActions()).write("\n");
return;
}
drawExecuteResult(process, model);
if (ProfilerAction.start.name().equals(model.getAction())) {
if (model.getDuration() != null) {
process.write(String.format("profiler will silent stop after %d seconds.\n", model.getDuration().longValue()));
process.write("profiler output file will be: " + model.getOutputFile() + "\n");
}
} else if (ProfilerAction.stop.name().equals(model.getAction())) {
process.write("profiler output file: " + model.getOutputFile() + "\n");
}
}
private void drawExecuteResult(CommandProcess process, ProfilerModel model) {
if (model.getExecuteResult() != null) {
process.write(model.getExecuteResult());
if (!model.getExecuteResult().endsWith("\n")) {
process.write("\n");
}
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/HelpView.java | core/src/main/java/com/taobao/arthas/core/command/view/HelpView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.CommandVO;
import com.taobao.arthas.core.command.model.HelpModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.usage.StyledUsageFormatter;
import com.taobao.middleware.cli.CLI;
import com.taobao.text.Color;
import com.taobao.text.Decoration;
import com.taobao.text.Style;
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;
import static com.taobao.text.ui.Element.row;
/**
* @author gongdewei 2020/4/3
*/
public class HelpView extends ResultView<HelpModel> {
@Override
public void draw(CommandProcess process, HelpModel result) {
if (result.getCommands() != null) {
String message = RenderUtil.render(mainHelp(result.getCommands()), process.width());
process.write(message);
} else if (result.getDetailCommand() != null) {
process.write(commandHelp(result.getDetailCommand().cli(), process.width()));
}
}
private static Element mainHelp(List<CommandVO> commands) {
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
table.row(new LabelElement("NAME").style(Style.style(Decoration.bold)), new LabelElement("DESCRIPTION"));
for (CommandVO commandVO : commands) {
table.add(row().add(label(commandVO.getName()).style(Style.style(Color.green))).add(label(commandVO.getSummary())));
}
return table;
}
private static String commandHelp(CLI command, int width) {
return StyledUsageFormatter.styledUsage(command, width);
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/SearchClassView.java | core/src/main/java/com/taobao/arthas/core/command/view/SearchClassView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.FieldVO;
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.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
if (result.isDetailed()) {
process.write(RenderUtil.render(ClassUtils.renderClassInfo(result.getClassInfo(),
result.isWithField()), process.width()));
process.write("\n");
} else if (result.getClassNames() != null) {
for (String className : result.getClassNames()) {
process.write(className).write("\n");
}
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/CatView.java | core/src/main/java/com/taobao/arthas/core/command/view/CatView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.CatModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* Result view for CatCommand
* @author gongdewei 2020/5/11
*/
public class CatView extends ResultView<CatModel> {
@Override
public void draw(CommandProcess process, CatModel result) {
process.write(result.getContent()).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/EchoView.java | core/src/main/java/com/taobao/arthas/core/command/view/EchoView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.EchoModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/5/11
*/
public class EchoView extends ResultView<EchoModel> {
@Override
public void draw(CommandProcess process, EchoModel result) {
process.write(result.getContent()).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/JFRView.java | core/src/main/java/com/taobao/arthas/core/command/view/JFRView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.JFRModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author longxu 2022/7/25
*/
public class JFRView extends ResultView<JFRModel>{
@Override
public void draw(CommandProcess process, JFRModel result) {
writeln(process, result.getJfrOutput());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/JadView.java | core/src/main/java/com/taobao/arthas/core/command/view/JadView.java | 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.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
int width = process.width();
if (result.getMatchedClasses() != null) {
Element table = ClassUtils.renderMatchedClasses(result.getMatchedClasses());
process.write(RenderUtil.render(table, width)).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)), width));
process.write(RenderUtil.render(TypeRenderUtils.drawClassLoader(classInfo), width) + "\n");
}
if (result.getLocation() != null) {
process.write(RenderUtil.render(new LabelElement("Location: ").style(Decoration.bold.fg(Color.red)), width));
process.write(RenderUtil.render(new LabelElement(result.getLocation()).style(Decoration.bold.fg(Color.blue)), width) + "\n");
}
process.write(LangRenderUtil.render(result.getSource()) + "\n");
process.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/OgnlView.java | core/src/main/java/com/taobao/arthas/core/command/view/OgnlView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ObjectVO;
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;
/**
* Term view of OgnlCommand
* @author gongdewei 2020/4/29
*/
public class OgnlView extends ResultView<OgnlModel> {
@Override
public void draw(CommandProcess process, OgnlModel model) {
if (model.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, model.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
ObjectVO objectVO = model.getValue();
String resultStr = StringUtils.objectToString(objectVO.needExpand() ? new ObjectView(objectVO).draw() : objectVO.getObject());
process.write(resultStr).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/MemoryView.java | core/src/main/java/com/taobao/arthas/core/command/view/MemoryView.java | package com.taobao.arthas.core.command.view;
import java.lang.management.MemoryUsage;
import java.util.List;
import java.util.Map;
import com.taobao.arthas.core.command.model.MemoryEntryVO;
import com.taobao.arthas.core.command.model.MemoryModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.text.Color;
import com.taobao.text.Decoration;
import com.taobao.text.Style;
import com.taobao.text.ui.RowElement;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
/**
* View of 'memory' command
*
* @author hengyunabc 2022-03-01
*/
public class MemoryView extends ResultView<MemoryModel> {
@Override
public void draw(CommandProcess process, MemoryModel result) {
TableElement table = drawMemoryInfo(result.getMemoryInfo());
process.write(RenderUtil.render(table, process.width()));
}
static TableElement drawMemoryInfo(Map<String, List<MemoryEntryVO>> memoryInfo) {
TableElement table = new TableElement(3, 1, 1, 1, 1).rightCellPadding(1);
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("Memory",
"used", "total", "max", "usage"));
List<MemoryEntryVO> heapMemoryEntries = memoryInfo.get(MemoryEntryVO.TYPE_HEAP);
//heap memory
for (MemoryEntryVO memoryEntryVO : heapMemoryEntries) {
if (MemoryEntryVO.TYPE_HEAP.equals(memoryEntryVO.getName())) {
new MemoryEntry(memoryEntryVO).addTableRow(table, Decoration.bold.bold());
} else {
new MemoryEntry(memoryEntryVO).addTableRow(table);
}
}
//non-heap memory
List<MemoryEntryVO> nonheapMemoryEntries = memoryInfo.get(MemoryEntryVO.TYPE_NON_HEAP);
for (MemoryEntryVO memoryEntryVO : nonheapMemoryEntries) {
if (MemoryEntryVO.TYPE_NON_HEAP.equals(memoryEntryVO.getName())) {
new MemoryEntry(memoryEntryVO).addTableRow(table, Decoration.bold.bold());
} else {
new MemoryEntry(memoryEntryVO).addTableRow(table);
}
}
//buffer-pool
List<MemoryEntryVO> bufferPoolMemoryEntries = memoryInfo.get(MemoryEntryVO.TYPE_BUFFER_POOL);
if (bufferPoolMemoryEntries != null) {
for (MemoryEntryVO memoryEntryVO : bufferPoolMemoryEntries) {
new MemoryEntry(memoryEntryVO).addTableRow(table);
}
}
return table;
}
static class MemoryEntry {
String name;
long used;
long total;
long max;
int unit;
String unitStr;
public MemoryEntry(String name, long used, long total, long max) {
this.name = name;
this.used = used;
this.total = total;
this.max = max;
unitStr = "K";
unit = 1024;
if (used / 1024 / 1024 > 0) {
unitStr = "M";
unit = 1024 * 1024;
}
}
public MemoryEntry(String name, MemoryUsage usage) {
this(name, usage.getUsed(), usage.getCommitted(), usage.getMax());
}
public MemoryEntry(MemoryEntryVO memoryEntryVO) {
this(memoryEntryVO.getName(), memoryEntryVO.getUsed(), memoryEntryVO.getTotal(), memoryEntryVO.getMax());
}
private String format(long value) {
String valueStr = "-";
if (value == -1) {
return "-1";
}
if (value != Long.MIN_VALUE) {
valueStr = value / unit + unitStr;
}
return valueStr;
}
public void addTableRow(TableElement table) {
double usage = used / (double) (max == -1 || max == Long.MIN_VALUE ? total : max) * 100;
if (Double.isNaN(usage) || Double.isInfinite(usage)) {
usage = 0;
}
table.row(name, format(used), format(total), format(max), String.format("%.2f%%", usage));
}
public void addTableRow(TableElement table, Style.Composite style) {
double usage = used / (double) (max == -1 || max == Long.MIN_VALUE ? total : max) * 100;
if (Double.isNaN(usage) || Double.isInfinite(usage)) {
usage = 0;
}
table.add(new RowElement().style(style).add(name, format(used), format(total), format(max),
String.format("%.2f%%", usage)));
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/RowAffectView.java | core/src/main/java/com/taobao/arthas/core/command/view/RowAffectView.java | 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");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ResultView.java | core/src/main/java/com/taobao/arthas/core/command/view/ResultView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ResultModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* Command result view for telnet term/tty.
* Note: Result view is a reusable and stateless instance
*
* @author gongdewei 2020/3/27
*/
public abstract class ResultView<T extends ResultModel> {
/**
* formatted printing data to term/tty
*
* @param process
*/
public abstract void draw(CommandProcess process, T result);
/**
* write str and append a new line
*
* @param process
* @param str
*/
protected void writeln(CommandProcess process, String str) {
process.write(str).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/JvmView.java | core/src/main/java/com/taobao/arthas/core/command/view/JvmView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.JvmModel;
import com.taobao.arthas.core.command.model.JvmItemVO;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.text.Decoration;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static com.taobao.text.ui.Element.label;
/**
* View of 'jvm' command
*
* @author gongdewei 2020/4/24
*/
public class JvmView extends ResultView<JvmModel> {
@Override
public void draw(CommandProcess process, JvmModel result) {
TableElement table = new TableElement(2, 5).leftCellPadding(1).rightCellPadding(1);
for (Map.Entry<String, List<JvmItemVO>> entry : result.getJvmInfo().entrySet()) {
String group = entry.getKey();
List<JvmItemVO> items = entry.getValue();
table.row(true, label(group).style(Decoration.bold.bold()));
for (JvmItemVO item : items) {
String valueStr;
if (item.getValue() instanceof Map && item.getName().endsWith("MEMORY-USAGE")) {
valueStr = renderMemoryUsage((Map<String, Object>) item.getValue());
} else {
valueStr = renderItemValue(item.getValue());
}
if (item.getDesc() != null) {
table.row(item.getName() + "\n[" + item.getDesc() + "]", valueStr);
} else {
table.row(item.getName(), valueStr);
}
}
table.row("", "");
}
process.write(RenderUtil.render(table, process.width()));
}
private String renderCountTime(long[] value) {
//count/time
return value[0] + "/" + value[1];
}
private String renderItemValue(Object value) {
if (value == null) {
return "null";
}
if (value instanceof Collection) {
return renderCollectionValue((Collection) value);
} else if (value instanceof String[]) {
return renderArrayValue((String[]) value);
} else if (value instanceof Map) {
return renderMapValue((Map) value);
}
return String.valueOf(value);
}
private String renderCollectionValue(Collection<String> strings) {
final StringBuilder colSB = new StringBuilder();
if (strings.isEmpty()) {
colSB.append("[]");
} else {
for (String str : strings) {
colSB.append(str).append("\n");
}
}
return colSB.toString();
}
private String renderArrayValue(String... stringArray) {
final StringBuilder colSB = new StringBuilder();
if (null == stringArray
|| stringArray.length == 0) {
colSB.append("[]");
} else {
for (String str : stringArray) {
colSB.append(str).append("\n");
}
}
return colSB.toString();
}
private String renderMapValue(Map<String, Object> valueMap) {
final StringBuilder colSB = new StringBuilder();
if (valueMap != null) {
for (Map.Entry<String, Object> entry : valueMap.entrySet()) {
colSB.append(entry.getKey()).append(" : ").append(entry.getValue()).append("\n");
}
}
return colSB.toString();
}
private String renderMemoryUsage(Map<String, Object> valueMap) {
final StringBuilder colSB = new StringBuilder();
String[] keys = new String[]{"init", "used", "committed", "max"};
for (String key : keys) {
Object value = valueMap.get(key);
String valueStr = value != null ? formatMemoryByte((Long) value) : "";
colSB.append(key).append(" : ").append(valueStr).append("\n");
}
return colSB.toString();
}
private String formatMemoryByte(long bytes) {
return String.format("%s(%s)", bytes, StringUtils.humanReadableByteCount(bytes));
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/TraceView.java | core/src/main/java/com/taobao/arthas/core/command/view/TraceView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.MethodNode;
import com.taobao.arthas.core.command.model.ThreadNode;
import com.taobao.arthas.core.command.model.ThrowNode;
import com.taobao.arthas.core.command.model.TraceModel;
import com.taobao.arthas.core.command.model.TraceNode;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.DateUtils;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.arthas.core.view.Ansi;
import java.util.List;
import static java.lang.String.format;
/**
* Term view for TraceModel
* @author gongdewei 2020/4/29
*/
public class TraceView extends ResultView<TraceModel> {
private static final String STEP_FIRST_CHAR = "`---";
private static final String STEP_NORMAL_CHAR = "+---";
private static final String STEP_HAS_BOARD = "| ";
private static final String STEP_EMPTY_BOARD = " ";
private static final String TIME_UNIT = "ms";
private static final char PERCENTAGE = '%';
// 是否输出耗时
private boolean isPrintCost = true;
private MethodNode maxCostNode;
@Override
public void draw(CommandProcess process, TraceModel result) {
process.write(drawTree(result.getRoot())).write("\n");
}
public String drawTree(TraceNode root) {
//reset status
maxCostNode = null;
findMaxCostNode(root);
final StringBuilder treeSB = new StringBuilder(2048);
final Ansi highlighted = Ansi.ansi().fg(Ansi.Color.RED);
recursive(0, true, "", root, new Callback() {
@Override
public void callback(int deep, boolean isLast, String prefix, TraceNode node) {
treeSB.append(prefix).append(isLast ? STEP_FIRST_CHAR : STEP_NORMAL_CHAR);
renderNode(treeSB, node, highlighted);
if (!StringUtils.isBlank(node.getMark())) {
treeSB.append(" [").append(node.getMark()).append(node.marks() > 1 ? "," + node.marks() : "").append("]");
}
treeSB.append("\n");
}
});
return treeSB.toString();
}
private void renderNode(StringBuilder sb, TraceNode node, Ansi highlighted) {
//render cost: [0.366865ms]
if (isPrintCost && node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
String costStr = renderCost(methodNode);
if (node == maxCostNode) {
// the node with max cost will be highlighted
sb.append(highlighted.a(costStr).reset().toString());
} else {
sb.append(costStr);
}
}
//render method name
if (node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
//clazz.getName() + ":" + method.getName() + "()"
sb.append(methodNode.getClassName()).append(":").append(methodNode.getMethodName()).append("()");
// #lineNumber
if (methodNode.getLineNumber()!= -1) {
sb.append(" #").append(methodNode.getLineNumber());
}
} else if (node instanceof ThreadNode) {
//render thread info
ThreadNode threadNode = (ThreadNode) node;
//ts=2020-04-29 10:34:00;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@18b4aac2
sb.append(format("ts=%s;thread_name=%s;id=%d;is_daemon=%s;priority=%d;TCCL=%s",
DateUtils.formatDateTime(threadNode.getTimestamp()),
threadNode.getThreadName(),
threadNode.getThreadId(),
threadNode.isDaemon(),
threadNode.getPriority(),
threadNode.getClassloader()));
//trace_id
if (threadNode.getTraceId() != null) {
sb.append(";trace_id=").append(threadNode.getTraceId());
}
if (threadNode.getRpcId() != null) {
sb.append(";rpc_id=").append(threadNode.getRpcId());
}
} else if (node instanceof ThrowNode) {
ThrowNode throwNode = (ThrowNode) node;
sb.append("throw:").append(throwNode.getException())
.append(" #").append(throwNode.getLineNumber())
.append(" [").append(throwNode.getMessage()).append("]");
} else {
throw new UnsupportedOperationException("unknown trace node: " + node.getClass());
}
}
private String renderCost(MethodNode node) {
StringBuilder sb = new StringBuilder();
if (node.getTimes() <= 1) {
if(node.parent() instanceof ThreadNode) {
sb.append('[').append(nanoToMillis(node.getCost())).append(TIME_UNIT).append("] ");
}else {
MethodNode parentNode = (MethodNode) node.parent();
String percentage = String.format("%.2f", node.getCost()*100.0/parentNode.getTotalCost());
sb.append('[').append(percentage).append(PERCENTAGE).append(" ").append(nanoToMillis(node.getCost())).append(TIME_UNIT).append(" ").append("] ");
}
} else {
if(node.parent() instanceof ThreadNode) {
sb.append("[min=").append(nanoToMillis(node.getMinCost())).append(TIME_UNIT).append(",max=")
.append(nanoToMillis(node.getMaxCost())).append(TIME_UNIT).append(",total=")
.append(nanoToMillis(node.getTotalCost())).append(TIME_UNIT).append(",count=")
.append(node.getTimes()).append("] ");
}else {
MethodNode parentNode = (MethodNode) node.parent();
String percentage = String.format("%.2f",node.getTotalCost()*100.0/parentNode.getTotalCost());
sb.append('[').append(percentage).append(PERCENTAGE).append(" min=").append(nanoToMillis(node.getMinCost())).append(TIME_UNIT).append(",max=")
.append(nanoToMillis(node.getMaxCost())).append(TIME_UNIT).append(",total=")
.append(nanoToMillis(node.getTotalCost())).append(TIME_UNIT).append(",count=")
.append(node.getTimes()).append("] ");
}
}
return sb.toString();
}
/**
* 递归遍历
*/
private void recursive(int deep, boolean isLast, String prefix, TraceNode node, Callback callback) {
callback.callback(deep, isLast, prefix, node);
if (!isLeaf(node)) {
List<TraceNode> children = node.getChildren();
if (children == null) {
return;
}
final int size = children.size();
for (int index = 0; index < size; index++) {
final boolean isLastFlag = index == size - 1;
final String currentPrefix = isLast ? prefix + STEP_EMPTY_BOARD : prefix + STEP_HAS_BOARD;
recursive(
deep + 1,
isLastFlag,
currentPrefix,
children.get(index),
callback
);
}
}
}
/**
* 查找耗时最大的节点,便于后续高亮展示
* @param node
*/
private void findMaxCostNode(TraceNode node) {
if (node instanceof MethodNode && !isRoot(node) && !isRoot(node.parent())) {
MethodNode aNode = (MethodNode) node;
if (maxCostNode == null || maxCostNode.getTotalCost() < aNode.getTotalCost()) {
maxCostNode = aNode;
}
}
if (!isLeaf(node)) {
List<TraceNode> children = node.getChildren();
if (children != null) {
for (TraceNode n: children) {
findMaxCostNode(n);
}
}
}
}
private boolean isRoot(TraceNode node) {
return node.parent() == null;
}
private boolean isLeaf(TraceNode node) {
List<TraceNode> children = node.getChildren();
return children == null || children.isEmpty();
}
/**
* convert nano-seconds to milli-seconds
*/
double nanoToMillis(long nanoSeconds) {
return nanoSeconds / 1000000.0;
}
/**
* 遍历回调接口
*/
private interface Callback {
void callback(int deep, boolean isLast, String prefix, TraceNode node);
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/Base64View.java | core/src/main/java/com/taobao/arthas/core/command/view/Base64View.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.Base64Model;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
*
* @author hengyunabc 2021-01-05
*
*/
public class Base64View extends ResultView<Base64Model> {
@Override
public void draw(CommandProcess process, Base64Model result) {
String content = result.getContent();
if (content != null) {
process.write(content);
}
process.write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/RedefineView.java | core/src/main/java/com/taobao/arthas/core/command/view/RedefineView.java | 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) {
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
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());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ThreadView.java | core/src/main/java/com/taobao/arthas/core/command/view/ThreadView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.BusyThreadInfo;
import com.taobao.arthas.core.command.model.ThreadModel;
import com.taobao.arthas.core.command.model.ThreadVO;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.ThreadUtil;
import com.taobao.text.ui.LabelElement;
import com.taobao.text.util.RenderUtil;
import java.util.List;
import java.util.Map;
/**
* View of 'thread' command
*
* @author gongdewei 2020/4/26
*/
public class ThreadView extends ResultView<ThreadModel> {
@Override
public void draw(CommandProcess process, ThreadModel result) {
if (result.getThreadInfo() != null) {
// no cpu usage info
String content = ThreadUtil.getFullStacktrace(result.getThreadInfo());
process.write(content);
} else if (result.getBusyThreads() != null) {
List<BusyThreadInfo> threadInfos = result.getBusyThreads();
for (BusyThreadInfo info : threadInfos) {
String stacktrace = ThreadUtil.getFullStacktrace(info, -1, -1);
process.write(stacktrace).write("\n");
}
} else if (result.getBlockingLockInfo() != null) {
String stacktrace = ThreadUtil.getFullStacktrace(result.getBlockingLockInfo());
process.write(stacktrace);
} else if (result.getThreadStateCount() != null) {
Map<Thread.State, Integer> threadStateCount = result.getThreadStateCount();
List<ThreadVO> threadStats = result.getThreadStats();
//sum total thread count
int total = 0;
for (Integer value : threadStateCount.values()) {
total += value;
}
int internalThreadCount = 0;
for (ThreadVO thread : threadStats) {
if (thread.getId() <= 0) {
internalThreadCount += 1;
}
}
total += internalThreadCount;
StringBuilder threadStat = new StringBuilder();
threadStat.append("Threads Total: ").append(total);
for (Thread.State s : Thread.State.values()) {
Integer count = threadStateCount.get(s);
threadStat.append(", ").append(s.name()).append(": ").append(count);
}
if (internalThreadCount > 0) {
threadStat.append(", Internal threads: ").append(internalThreadCount);
}
String stat = RenderUtil.render(new LabelElement(threadStat), process.width());
//thread stats
int height;
if (result.isAll()) {
height = threadStats.size() + 1;
} else {
height = Math.max(5, process.height() - 2);
//remove blank lines
height = Math.min(height, threadStats.size() + 2);
}
String content = ViewRenderUtil.drawThreadInfo(threadStats, process.width(), height);
process.write(stat + content);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/StatusView.java | core/src/main/java/com/taobao/arthas/core/command/view/StatusView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.StatusModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/3/27
*/
public class StatusView extends ResultView<StatusModel> {
@Override
public void draw(CommandProcess process, StatusModel result) {
if (result.getMessage() != null) {
writeln(process, result.getMessage());
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/RetransformView.java | core/src/main/java/com/taobao/arthas/core/command/view/RetransformView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.klass100.RetransformCommand.RetransformEntry;
import com.taobao.arthas.core.command.model.RetransformModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.text.Decoration;
import com.taobao.text.ui.RowElement;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
/**
*
* @author hengyunabc 2021-01-06
*
*/
public class RetransformView extends ResultView<RetransformModel> {
@Override
public void draw(CommandProcess process, RetransformModel result) {
// 匹配到多个 classloader
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
// retransform -d
if (result.getDeletedRetransformEntry() != null) {
process.write("Delete RetransformEntry by id success. id: " + result.getDeletedRetransformEntry().getId());
process.write("\n");
return;
}
// retransform -l
if (result.getRetransformEntries() != null) {
// header
TableElement table = new TableElement(1, 1, 1, 1, 1).rightCellPadding(1);
table.add(new RowElement().style(Decoration.bold.bold()).add("Id", "ClassName", "TransformCount", "LoaderHash",
"LoaderClassName"));
for (RetransformEntry entry : result.getRetransformEntries()) {
table.row("" + entry.getId(), "" + entry.getClassName(), "" + entry.getTransformCount(), "" + entry.getHashCode(),
"" + entry.getClassLoaderClass());
}
process.write(RenderUtil.render(table));
return;
}
// retransform /tmp/Demo.class
if (result.getRetransformClasses() != null) {
StringBuilder sb = new StringBuilder();
for (String aClass : result.getRetransformClasses()) {
sb.append(aClass).append("\n");
}
process.write("retransform success, size: " + result.getRetransformCount()).write(", classes:\n")
.write(sb.toString());
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/DashboardView.java | core/src/main/java/com/taobao/arthas/core/command/view/DashboardView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.*;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.text.Color;
import com.taobao.text.Decoration;
import com.taobao.text.ui.RowElement;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* View of 'dashboard' command
*
* @author gongdewei 2020/4/22
*/
public class DashboardView extends ResultView<DashboardModel> {
@Override
public void draw(CommandProcess process, DashboardModel result) {
int width = process.width();
int height = process.height();
// 上半部分放thread top。下半部分再切分为田字格,其中上面两格放memory, gc的信息。下面两格放tomcat,
// runtime的信息
int totalHeight = height - 1;
int threadTopHeight;
if (totalHeight <= 24) {
//总高度较小时取1/2
threadTopHeight = totalHeight / 2;
} else {
//总高度较大时取1/3,但不少于上面的值(24/2=12)
threadTopHeight = totalHeight / 3;
if (threadTopHeight < 12) {
threadTopHeight = 12;
}
}
int lowerHalf = totalHeight - threadTopHeight;
//Memory至少保留8行, 显示metaspace信息
int memoryInfoHeight = lowerHalf / 2;
if (memoryInfoHeight < 8) {
memoryInfoHeight = Math.min(8, lowerHalf);
}
//runtime
TableElement runtimeInfoTable = drawRuntimeInfo(result.getRuntimeInfo());
//tomcat
TableElement tomcatInfoTable = drawTomcatInfo(result.getTomcatInfo());
int runtimeInfoHeight = Math.max(runtimeInfoTable.getRows().size(), tomcatInfoTable == null ? 0 : tomcatInfoTable.getRows().size());
if (runtimeInfoHeight < lowerHalf - memoryInfoHeight) {
//如果runtimeInfo高度有剩余,则增大MemoryInfo的高度
memoryInfoHeight = lowerHalf - runtimeInfoHeight;
} else {
runtimeInfoHeight = lowerHalf - memoryInfoHeight;
}
//如果MemoryInfo高度有剩余,则增大ThreadHeight
int maxMemoryInfoHeight = getMemoryInfoHeight(result.getMemoryInfo());
memoryInfoHeight = Math.min(memoryInfoHeight, maxMemoryInfoHeight);
threadTopHeight = totalHeight - memoryInfoHeight - runtimeInfoHeight;
String threadInfo = ViewRenderUtil.drawThreadInfo(result.getThreads(), width, threadTopHeight);
String memoryAndGc = drawMemoryInfoAndGcInfo(result.getMemoryInfo(), result.getGcInfos(), width, memoryInfoHeight);
String runTimeAndTomcat = drawRuntimeInfoAndTomcatInfo(runtimeInfoTable, tomcatInfoTable, width, runtimeInfoHeight);
process.write(threadInfo + memoryAndGc + runTimeAndTomcat);
}
static String drawMemoryInfoAndGcInfo(Map<String, List<MemoryEntryVO>> memoryInfo, List<GcInfoVO> gcInfos, int width, int height) {
TableElement table = new TableElement(1, 1);
TableElement memoryInfoTable = MemoryView.drawMemoryInfo(memoryInfo);
TableElement gcInfoTable = drawGcInfo(gcInfos);
table.row(memoryInfoTable, gcInfoTable);
return RenderUtil.render(table, width, height);
}
private static int getMemoryInfoHeight(Map<String, List<MemoryEntryVO>> memoryInfo) {
int height = 1;
for (List<MemoryEntryVO> memoryEntryVOS : memoryInfo.values()) {
height += memoryEntryVOS.size();
}
return height;
}
private static TableElement drawGcInfo(List<GcInfoVO> gcInfos) {
TableElement table = new TableElement(1, 1).rightCellPadding(1);
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("GC", ""));
for (GcInfoVO gcInfo : gcInfos) {
table.add(new RowElement().style(Decoration.bold.bold()).add("gc." + gcInfo.getName() + ".count",
"" + gcInfo.getCollectionCount()));
table.row("gc." + gcInfo.getName() + ".time(ms)", "" + gcInfo.getCollectionTime());
}
return table;
}
String drawRuntimeInfoAndTomcatInfo(TableElement runtimeInfoTable, TableElement tomcatInfoTable, int width, int height) {
if (height <= 0) {
return "";
}
TableElement resultTable = new TableElement(1, 1);
if (tomcatInfoTable != null) {
resultTable.row(runtimeInfoTable, tomcatInfoTable);
} else {
resultTable = runtimeInfoTable;
}
return RenderUtil.render(resultTable, width, height);
}
private static TableElement drawRuntimeInfo(RuntimeInfoVO runtimeInfo) {
TableElement table = new TableElement(1, 1).rightCellPadding(1);
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("Runtime", ""));
table.row("os.name", runtimeInfo.getOsName());
table.row("os.version", runtimeInfo.getOsVersion());
table.row("java.version", runtimeInfo.getJavaVersion());
table.row("java.home", runtimeInfo.getJavaHome());
table.row("systemload.average", String.format("%.2f", runtimeInfo.getSystemLoadAverage()));
table.row("processors", "" + runtimeInfo.getProcessors());
table.row("timestamp/uptime", new Date(runtimeInfo.getTimestamp()).toString() + "/" + runtimeInfo.getUptime() + "s");
return table;
}
private static String formatBytes(long size) {
int unit = 1;
String unitStr = "B";
if (size / 1024 > 0) {
unit = 1024;
unitStr = "K";
} else if (size / 1024 / 1024 > 0) {
unit = 1024 * 1024;
unitStr = "M";
}
return String.format("%d%s", size / unit, unitStr);
}
private TableElement drawTomcatInfo(TomcatInfoVO tomcatInfo) {
if (tomcatInfo == null) {
return null;
}
//header
TableElement table = new TableElement(1, 1).rightCellPadding(1);
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("Tomcat", ""));
if (tomcatInfo.getConnectorStats() != null) {
for (TomcatInfoVO.ConnectorStats connectorStat : tomcatInfo.getConnectorStats()) {
table.add(new RowElement().style(Decoration.bold.bold()).add("connector", connectorStat.getName()));
table.row("QPS", String.format("%.2f", connectorStat.getQps()));
table.row("RT(ms)", String.format("%.2f", connectorStat.getRt()));
table.row("error/s", String.format("%.2f", connectorStat.getError()));
table.row("received/s", formatBytes(connectorStat.getReceived()));
table.row("sent/s", formatBytes(connectorStat.getSent()));
}
}
if (tomcatInfo.getThreadPools() != null) {
for (TomcatInfoVO.ThreadPool threadPool : tomcatInfo.getThreadPools()) {
table.add(new RowElement().style(Decoration.bold.bold()).add("threadpool", threadPool.getName()));
table.row("busy", "" + threadPool.getBusy());
table.row("total", "" + threadPool.getTotal());
}
}
return table;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/SystemPropertyView.java | core/src/main/java/com/taobao/arthas/core/command/view/SystemPropertyView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.SystemPropertyModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/4/2
*/
public class SystemPropertyView extends ResultView<SystemPropertyModel> {
@Override
public void draw(CommandProcess process, SystemPropertyModel result) {
process.write(ViewRenderUtil.renderKeyValueTable(result.getProps(), process.width()));
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/EnhancerView.java | core/src/main/java/com/taobao/arthas/core/command/view/EnhancerView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.EnhancerModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* Term view for EnhancerModel
* @author gongdewei 2020/7/21
*/
public class EnhancerView extends ResultView<EnhancerModel> {
@Override
public void draw(CommandProcess process, EnhancerModel result) {
// ignore enhance result status, judge by the following output
if (result.getEffect() != null) {
process.write(ViewRenderUtil.renderEnhancerAffect(result.getEffect()));
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/StackView.java | core/src/main/java/com/taobao/arthas/core/command/view/StackView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.StackModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.DateUtils;
import com.taobao.arthas.core.util.ThreadUtil;
/**
* Term view for StackModel
* @author gongdewei 2020/4/13
*/
public class StackView extends ResultView<StackModel> {
@Override
public void draw(CommandProcess process, StackModel result) {
StringBuilder sb = new StringBuilder();
sb.append(ThreadUtil.getThreadTitle(result)).append("\n");
StackTraceElement[] stackTraceElements = result.getStackTrace();
StackTraceElement locationStackTraceElement = stackTraceElements[0];
String locationString = String.format(" @%s.%s()", locationStackTraceElement.getClassName(),
locationStackTraceElement.getMethodName());
sb.append(locationString).append("\n");
int skip = 1;
for (int index = skip; index < stackTraceElements.length; index++) {
StackTraceElement ste = stackTraceElements[index];
sb.append(" at ")
.append(ste.getClassName())
.append(".")
.append(ste.getMethodName())
.append("(")
.append(ste.getFileName())
.append(":")
.append(ste.getLineNumber())
.append(")\n");
}
process.write("ts=" + DateUtils.formatDateTime(result.getTs()) + ";" + sb.toString() + "\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/DumpClassView.java | core/src/main/java/com/taobao/arthas/core/command/view/DumpClassView.java | 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.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
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);
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/SearchMethodView.java | core/src/main/java/com/taobao/arthas/core/command/view/SearchMethodView.java | 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) {
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
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");
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/MessageView.java | core/src/main/java/com/taobao/arthas/core/command/view/MessageView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.MessageModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/4/2
*/
public class MessageView extends ResultView<MessageModel> {
@Override
public void draw(CommandProcess process, MessageModel result) {
writeln(process, result.getMessage());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/VersionView.java | core/src/main/java/com/taobao/arthas/core/command/view/VersionView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.VersionModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/3/27
*/
public class VersionView extends ResultView<VersionModel> {
@Override
public void draw(CommandProcess process, VersionModel result) {
writeln(process, result.getVersion());
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/WatchView.java | core/src/main/java/com/taobao/arthas/core/command/view/WatchView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ObjectVO;
import com.taobao.arthas.core.command.model.WatchModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.DateUtils;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.arthas.core.view.ObjectView;
/**
* Term view for WatchModel
*
* @author gongdewei 2020/3/27
*/
public class WatchView extends ResultView<WatchModel> {
@Override
public void draw(CommandProcess process, WatchModel model) {
ObjectVO objectVO = model.getValue();
String result = StringUtils.objectToString(
objectVO.needExpand() ? new ObjectView(model.getSizeLimit(), objectVO).draw() : objectVO.getObject());
process.write("method=" + model.getClassName() + "." + model.getMethodName() + " location=" + model.getAccessPoint() + "\n");
process.write("ts=" + DateUtils.formatDateTime(model.getTs()) + "; [cost=" + model.getCost() + "ms] result=" + result + "\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ShutdownView.java | core/src/main/java/com/taobao/arthas/core/command/view/ShutdownView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ShutdownModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/6/22
*/
public class ShutdownView extends ResultView<ShutdownModel> {
@Override
public void draw(CommandProcess process, ShutdownModel result) {
process.write(result.getMessage()).write("\n");
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ClassLoaderView.java | core/src/main/java/com/taobao/arthas/core/command/view/ClassLoaderView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.klass100.ClassLoaderCommand.ClassLoaderStat;
import com.taobao.arthas.core.command.klass100.ClassLoaderCommand.ClassLoaderUrlStat;
import com.taobao.arthas.core.command.klass100.ClassLoaderCommand.UrlClassStat;
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.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* @author gongdewei 2020/4/21
*/
public class ClassLoaderView extends ResultView<ClassLoaderModel> {
@Override
public void draw(CommandProcess process, ClassLoaderModel result) {
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
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());
}
if (result.getUrlStats() != null) {
drawUrlStats(process, result.getUrlStats());
}
if (result.getUrlClassStats() != null) {
drawUrlClassStats(process, result.getClassLoader(), result.getUrlClassStats(),
Boolean.TRUE.equals(result.getUrlClassStatsDetail()));
}
}
private void drawUrlClassStats(CommandProcess process, ClassLoaderVO classLoader, List<UrlClassStat> urlClassStats,
boolean detail) {
if (classLoader != null) {
process.write(classLoader.getName() + ", hash:" + classLoader.getHash() + "\n");
}
boolean hasMatched = false;
for (UrlClassStat stat : urlClassStats) {
if (stat.getMatchedClassCount() != null) {
hasMatched = true;
break;
}
}
if (!detail) {
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
RowElement header = new RowElement().style(Decoration.bold.bold());
if (hasMatched) {
header.add("url", "loadedClassCount", "matchedClassCount");
} else {
header.add("url", "loadedClassCount");
}
table.add(header);
for (UrlClassStat stat : urlClassStats) {
if (hasMatched) {
table.row(stat.getUrl(), "" + stat.getLoadedClassCount(), "" + stat.getMatchedClassCount());
} else {
table.row(stat.getUrl(), "" + stat.getLoadedClassCount());
}
}
process.write(RenderUtil.render(table, process.width()))
.write(com.taobao.arthas.core.util.Constants.EMPTY_STRING);
return;
}
for (UrlClassStat stat : urlClassStats) {
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
StringBuilder title = new StringBuilder();
title.append(stat.getUrl())
.append(" (loaded: ").append(stat.getLoadedClassCount());
if (hasMatched) {
title.append(", matched: ").append(stat.getMatchedClassCount());
}
title.append(")");
table.row(new LabelElement(title.toString()).style(Decoration.bold.bold()));
List<String> classes = stat.getClasses();
if (classes != null) {
for (String className : classes) {
table.row(className);
}
}
if (stat.isTruncated() && classes != null) {
int total = hasMatched ? stat.getMatchedClassCount() : stat.getLoadedClassCount();
table.row(new LabelElement("... (showing first " + classes.size() + " of " + total
+ ", use -n/--limit to change limit)"));
}
process.write(RenderUtil.render(table, process.width()))
.write("\n");
}
}
private void drawUrlStats(CommandProcess process, Map<ClassLoaderVO, ClassLoaderUrlStat> urlStats) {
for (Entry<ClassLoaderVO, ClassLoaderUrlStat> entry : urlStats.entrySet()) {
ClassLoaderVO classLoaderVO = entry.getKey();
ClassLoaderUrlStat urlStat = entry.getValue();
// 忽略 sun.reflect.DelegatingClassLoader 等动态ClassLoader
if (urlStat.getUsedUrls().isEmpty() && urlStat.getUnUsedUrls().isEmpty()) {
continue;
}
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
table.row(new LabelElement(classLoaderVO.getName() + ", hash:" + classLoaderVO.getHash())
.style(Decoration.bold.bold()));
Collection<String> usedUrls = urlStat.getUsedUrls();
table.row(new LabelElement("Used URLs:").style(Decoration.bold.bold()));
for (String url : usedUrls) {
table.row(url);
}
Collection<String> UnnsedUrls = urlStat.getUnUsedUrls();
table.row(new LabelElement("Unused URLs:").style(Decoration.bold.bold()));
for (String url : UnnsedUrls) {
table.row(url);
}
process.write(RenderUtil.render(table, process.width()))
.write("\n");
}
}
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;
}
public static void drawClassLoaders(CommandProcess process, Collection<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(Collection<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(Collection<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);
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/SystemEnvView.java | core/src/main/java/com/taobao/arthas/core/command/view/SystemEnvView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.SystemEnvModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/4/2
*/
public class SystemEnvView extends ResultView<SystemEnvModel> {
@Override
public void draw(CommandProcess process, SystemEnvModel result) {
process.write(ViewRenderUtil.renderKeyValueTable(result.getEnv(), process.width()));
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/GetStaticView.java | core/src/main/java/com/taobao/arthas/core/command/view/GetStaticView.java | 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) {
if (result.getMatchedClassLoaders() != null) {
process.write("Matched classloaders: \n");
ClassLoaderView.drawClassLoaders(process, result.getMatchedClassLoaders(), false);
process.write("\n");
return;
}
if (result.getField() != null) {
ObjectVO field = result.getField();
String valueStr = StringUtils.objectToString(field.needExpand() ? new ObjectView(field).draw() : field.getObject());
process.write("field: " + result.getFieldName() + "\n" + valueStr + "\n");
} else if (result.getMatchedClasses() != null) {
Element table = ClassUtils.renderMatchedClasses(result.getMatchedClasses());
process.write(RenderUtil.render(table)).write("\n");
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/OptionsView.java | core/src/main/java/com/taobao/arthas/core/command/view/OptionsView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.OptionVO;
import com.taobao.arthas.core.command.model.OptionsModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.text.Decoration;
import com.taobao.text.ui.Element;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import java.util.Collection;
import static com.taobao.text.ui.Element.label;
/**
* @author gongdewei 2020/4/15
*/
public class OptionsView extends ResultView<OptionsModel> {
@Override
public void draw(CommandProcess process, OptionsModel result) {
if (result.getOptions() != null) {
process.write(RenderUtil.render(drawShowTable(result.getOptions()), process.width()));
} else if (result.getChangeResult() != null) {
TableElement table = ViewRenderUtil.renderChangeResult(result.getChangeResult());
process.write(RenderUtil.render(table, process.width()));
}
}
private Element drawShowTable(Collection<OptionVO> options) {
TableElement table = new TableElement(1, 1, 2, 1, 3, 6)
.leftCellPadding(1).rightCellPadding(1);
table.row(true, label("LEVEL").style(Decoration.bold.bold()),
label("TYPE").style(Decoration.bold.bold()),
label("NAME").style(Decoration.bold.bold()),
label("VALUE").style(Decoration.bold.bold()),
label("SUMMARY").style(Decoration.bold.bold()),
label("DESCRIPTION").style(Decoration.bold.bold()));
for (final OptionVO optionVO : options) {
table.row("" + optionVO.getLevel(),
optionVO.getType(),
optionVO.getName(),
optionVO.getValue(),
optionVO.getSummary(),
optionVO.getDescription());
}
return table;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ResultViewResolver.java | core/src/main/java/com/taobao/arthas/core/command/view/ResultViewResolver.java | package com.taobao.arthas.core.command.view;
import com.alibaba.arthas.deps.org.slf4j.Logger;
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
import com.taobao.arthas.core.command.model.ResultModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Result view resolver for term
*
* @author gongdewei 2020/3/27
*/
public class ResultViewResolver {
private static final Logger logger = LoggerFactory.getLogger(ResultViewResolver.class);
// modelClass -> view
private Map<Class, ResultView> resultViewMap = new ConcurrentHashMap<Class, ResultView>();
public ResultViewResolver() {
initResultViews();
}
/**
* 需要调用此方法初始化注册ResultView
*/
private void initResultViews() {
try {
registerView(RowAffectView.class);
//basic1000
registerView(StatusView.class);
registerView(VersionView.class);
registerView(MessageView.class);
registerView(HelpView.class);
//registerView(HistoryView.class);
registerView(EchoView.class);
registerView(CatView.class);
registerView(Base64View.class);
registerView(OptionsView.class);
registerView(SystemPropertyView.class);
registerView(SystemEnvView.class);
registerView(PwdView.class);
registerView(VMOptionView.class);
registerView(SessionView.class);
registerView(ResetView.class);
registerView(ShutdownView.class);
//klass100
registerView(ClassLoaderView.class);
registerView(DumpClassView.class);
registerView(GetStaticView.class);
registerView(JadView.class);
registerView(MemoryCompilerView.class);
registerView(OgnlView.class);
registerView(RedefineView.class);
registerView(RetransformView.class);
registerView(SearchClassView.class);
registerView(SearchMethodView.class);
//logger
registerView(LoggerView.class);
//monitor2000
registerView(DashboardView.class);
registerView(JvmView.class);
registerView(MemoryView.class);
registerView(MBeanView.class);
registerView(PerfCounterView.class);
registerView(ThreadView.class);
registerView(ProfilerView.class);
registerView(EnhancerView.class);
registerView(MonitorView.class);
registerView(StackView.class);
registerView(TimeTunnelView.class);
registerView(TraceView.class);
registerView(WatchView.class);
registerView(VmToolView.class);
registerView(JFRView.class);
} catch (Throwable e) {
logger.error("register result view failed", e);
}
}
public ResultView getResultView(ResultModel model) {
return resultViewMap.get(model.getClass());
}
public ResultViewResolver registerView(Class modelClass, ResultView view) {
//TODO 检查model的type是否重复,避免复制代码带来的bug
this.resultViewMap.put(modelClass, view);
return this;
}
public ResultViewResolver registerView(ResultView view) {
Class modelClass = getModelClass(view);
if (modelClass == null) {
throw new NullPointerException("model class is null");
}
return this.registerView(modelClass, view);
}
public void registerView(Class<? extends ResultView> viewClass) {
ResultView view = null;
try {
view = viewClass.newInstance();
} catch (Throwable e) {
throw new RuntimeException("create view instance failure, viewClass:" + viewClass, e);
}
this.registerView(view);
}
/**
* Get model class of result view
*
* @return
*/
public static <V extends ResultView> Class getModelClass(V view) {
//类反射获取子类的draw方法第二个参数的ResultModel具体类型
Class<? extends ResultView> viewClass = view.getClass();
Method[] declaredMethods = viewClass.getDeclaredMethods();
for (int i = 0; i < declaredMethods.length; i++) {
Method method = declaredMethods[i];
if (method.getName().equals("draw")) {
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length == 2
&& parameterTypes[0] == CommandProcess.class
&& parameterTypes[1] != ResultModel.class
&& ResultModel.class.isAssignableFrom(parameterTypes[1])) {
return parameterTypes[1];
}
}
}
return null;
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/TimeTunnelView.java | core/src/main/java/com/taobao/arthas/core/command/view/TimeTunnelView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ObjectVO;
import com.taobao.arthas.core.command.model.TimeFragmentVO;
import com.taobao.arthas.core.command.model.TimeTunnelModel;
import com.taobao.arthas.core.command.monitor200.TimeTunnelTable;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.StringUtils;
import com.taobao.arthas.core.view.ObjectView;
import com.taobao.text.ui.Element;
import com.taobao.text.ui.TableElement;
import com.taobao.text.util.RenderUtil;
import static com.taobao.arthas.core.command.monitor200.TimeTunnelTable.*;
import static java.lang.String.format;
/**
* Term view for TimeTunnelCommand
* @author gongdewei 2020/4/27
*/
public class TimeTunnelView extends ResultView<TimeTunnelModel> {
@Override
public void draw(CommandProcess process, TimeTunnelModel timeTunnelModel) {
Integer sizeLimit = timeTunnelModel.getSizeLimit();
if (timeTunnelModel.getTimeFragmentList() != null) {
//show list table: tt -l / tt -t
Element table = drawTimeTunnelTable(timeTunnelModel.getTimeFragmentList(), timeTunnelModel.getFirst());
process.write(RenderUtil.render(table, process.width()));
} else if (timeTunnelModel.getTimeFragment() != null) {
//show detail of single TimeFragment: tt -i 1000
TimeFragmentVO tf = timeTunnelModel.getTimeFragment();
TableElement table = TimeTunnelTable.createDefaultTable();
TimeTunnelTable.drawTimeTunnel(table, tf);
TimeTunnelTable.drawParameters(table, tf.getParams());
TimeTunnelTable.drawReturnObj(table, tf, sizeLimit);
TimeTunnelTable.drawThrowException(table, tf);
process.write(RenderUtil.render(table, process.width()));
} else if (timeTunnelModel.getWatchValue() != null) {
//watch single TimeFragment: tt -i 1000 -w 'params'
ObjectVO valueVO = timeTunnelModel.getWatchValue();
if (valueVO.needExpand()) {
process.write(new ObjectView(sizeLimit, valueVO).draw()).write("\n");
} else {
process.write(StringUtils.objectToString(valueVO.getObject())).write("\n");
}
} else if (timeTunnelModel.getWatchResults() != null) {
//search & watch: tt -s 'returnObj!=null' -w 'returnObj'
TableElement table = TimeTunnelTable.createDefaultTable();
TimeTunnelTable.drawWatchTableHeader(table);
TimeTunnelTable.drawWatchResults(table, timeTunnelModel.getWatchResults(), sizeLimit);
process.write(RenderUtil.render(table, process.width()));
} else if (timeTunnelModel.getReplayResult() != null) {
//replay: tt -i 1000 -p
TimeFragmentVO replayResult = timeTunnelModel.getReplayResult();
Integer replayNo = timeTunnelModel.getReplayNo();
TableElement table = TimeTunnelTable.createDefaultTable();
TimeTunnelTable.drawPlayHeader(replayResult.getClassName(), replayResult.getMethodName(), replayResult.getObject(), replayResult.getIndex(), table);
TimeTunnelTable.drawParameters(table, replayResult.getParams());
if (replayResult.isReturn()) {
TimeTunnelTable.drawPlayResult(table, replayResult.getReturnObj(), sizeLimit, replayResult.getCost());
} else {
TimeTunnelTable.drawPlayException(table, replayResult.getThrowExp());
}
process.write(RenderUtil.render(table, process.width()))
.write(format("Time fragment[%d] successfully replayed %d times.", replayResult.getIndex(), replayNo))
.write("\n\n");
}
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
alibaba/arthas | https://github.com/alibaba/arthas/blob/17eb3c17e764728e6bf2cf3a37d56620e8835fd0/core/src/main/java/com/taobao/arthas/core/command/view/ResetView.java | core/src/main/java/com/taobao/arthas/core/command/view/ResetView.java | package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.ResetModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* @author gongdewei 2020/6/22
*/
public class ResetView extends ResultView<ResetModel> {
@Override
public void draw(CommandProcess process, ResetModel result) {
process.write(ViewRenderUtil.renderEnhancerAffect(result.getAffect()));
}
}
| java | Apache-2.0 | 17eb3c17e764728e6bf2cf3a37d56620e8835fd0 | 2026-01-04T14:45:57.082411Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.