use of com.shulie.instrument.simulator.module.model.memory.MemoryInfo in project LinkAgent by shulieTech.
the class PerfPlugin method info.
@Command("info")
public CommandResponse info(Map<String, String> args) {
try {
CommandResponse<List<ThreadInfo>> threadResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_THREAD, PerfConstants.MODULE_COMMAND_THREAD_INFO, threadParams);
CommandResponse<GcInfo> gcResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_GC, PerfConstants.MODULE_COMMAND_GC_INFO);
CommandResponse<MemoryInfo> memoryResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_MEMORY, PerfConstants.MODULE_COMMAND_MEMORY_INFO);
List<ThreadInfo> threadInfos = Collections.EMPTY_LIST;
if (!threadResp.isSuccess()) {
logger.error("Perf: collect perf thread info err! {}", threadResp.getMessage());
} else {
threadInfos = threadResp.getResult();
}
GcInfo gcInfo = null;
if (!gcResp.isSuccess()) {
logger.error("Perf: collect perf gc info err! {}", gcResp.getMessage());
} else {
gcInfo = gcResp.getResult();
}
MemoryInfo memoryInfo = null;
if (!memoryResp.isSuccess()) {
logger.error("Perf: collect perf memory info err! {}", memoryResp.getMessage());
} else {
memoryInfo = memoryResp.getResult();
}
PerfResponse response = PerfResponseBuilder.build(threadInfos, gcInfo, memoryInfo);
return CommandResponse.success(response);
} catch (Throwable e) {
logger.error("Perf: collect perf data occurred a unknow error. ", e);
return CommandResponse.failure(e);
}
}
use of com.shulie.instrument.simulator.module.model.memory.MemoryInfo in project LinkAgent by shulieTech.
the class PerfPlugin method collect.
private void collect() {
CommandResponse<List<ThreadInfo>> threadResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_THREAD, PerfConstants.MODULE_COMMAND_THREAD_INFO, threadParams);
CommandResponse<GcInfo> gcResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_GC, PerfConstants.MODULE_COMMAND_GC_INFO);
CommandResponse<MemoryInfo> memoryResp = moduleCommandInvoker.invokeCommand(PerfConstants.MODULE_ID_MEMORY, PerfConstants.MODULE_COMMAND_MEMORY_INFO);
List<ThreadInfo> threadInfos = Collections.EMPTY_LIST;
if (!threadResp.isSuccess()) {
logger.error("Perf: collect perf thread info err! {}", threadResp.getMessage());
} else {
threadInfos = threadResp.getResult();
}
GcInfo gcInfo = null;
if (!gcResp.isSuccess()) {
logger.error("Perf: collect perf gc info err! {}", gcResp.getMessage());
} else {
gcInfo = gcResp.getResult();
}
MemoryInfo memoryInfo = null;
if (!memoryResp.isSuccess()) {
logger.error("Perf: collect perf memory info err! {}", memoryResp.getMessage());
} else {
memoryInfo = memoryResp.getResult();
}
PerfResponse response = PerfResponseBuilder.build(threadInfos, gcInfo, memoryInfo);
push(response);
}
use of com.shulie.instrument.simulator.module.model.memory.MemoryInfo in project LinkAgent by shulieTech.
the class MemoryModule method info.
@Command(value = "info", description = "内存信息")
public CommandResponse info(final Map<String, String> args) {
try {
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
MemoryInfo memoryInfo = new MemoryInfo();
// heap
MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
memoryInfo.setHeapMemory(createMemoryEntry(TYPE_HEAP, heapMemoryUsage));
List<MemoryEntry> heapMemEntries = new ArrayList<MemoryEntry>();
for (MemoryPoolMXBean poolMXBean : memoryPoolMXBeans) {
if (MemoryType.HEAP.equals(poolMXBean.getType())) {
MemoryUsage usage = poolMXBean.getUsage();
heapMemEntries.add(createMemoryEntry(poolMXBean.getName(), usage));
}
}
memoryInfo.setHeapMemories(heapMemEntries);
// non-heap
MemoryUsage nonHeapMemoryUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
List<MemoryEntry> nonheapMemEntries = new ArrayList<MemoryEntry>();
memoryInfo.setNonheapMemory(createMemoryEntry(TYPE_NON_HEAP, nonHeapMemoryUsage));
for (MemoryPoolMXBean poolMXBean : memoryPoolMXBeans) {
if (MemoryType.NON_HEAP.equals(poolMXBean.getType())) {
MemoryUsage usage = poolMXBean.getUsage();
nonheapMemEntries.add(createMemoryEntry(poolMXBean.getName(), usage));
}
}
memoryInfo.setNonheapMemories(nonheapMemEntries);
memoryInfo.setBufferPoolMemories(getBufferPoolMemoryInfo());
return CommandResponse.success(memoryInfo);
} catch (Throwable e) {
return CommandResponse.failure(e);
}
}
Aggregations