mirror of https://github.com/alibaba/arthas.git
transform commands: heapdump, perfcounter
parent
5b7603eebe
commit
25a8ba9f4f
@ -0,0 +1,42 @@
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
|
||||
/**
|
||||
* VO for PerfCounterCommand
|
||||
*
|
||||
* @author gongdewei 2020/4/27
|
||||
*/
|
||||
public class PerfCounterVO {
|
||||
|
||||
private String name;
|
||||
private String units;
|
||||
private String variability;
|
||||
private Object value;
|
||||
|
||||
public PerfCounterVO() {
|
||||
}
|
||||
|
||||
public PerfCounterVO(String name, Object value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public PerfCounterVO(String name, String units, String variability, Object value) {
|
||||
this.name = name;
|
||||
this.units = units;
|
||||
this.variability = variability;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setUnits(String units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public void setVariability(String variability) {
|
||||
this.variability = variability;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
public String getVariability() {
|
||||
return variability;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
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()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue