use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class ThriftAgentEventMapperTest method simpleTest1.
@Test
public void simpleTest1() {
final String agentId = "agentId";
final long startTimestamp = Long.MAX_VALUE;
final long eventTimestamp = startTimestamp;
final TAgentStat agentStat = createAgentStat(agentId, startTimestamp, eventTimestamp, 2);
DeadlockBo deadlockBo = new DeadlockBo();
deadlockBo.setDeadlockedThreadCount(agentStat.getDeadlock().getDeadlockedThreadCount());
DeadlockEventBo expectedEventBo = new DeadlockEventBo(agentId, startTimestamp, eventTimestamp, AgentEventType.AGENT_DEADLOCK_DETECTED, deadlockBo);
when(this.deadlockEventBoMapper.map(agentId, startTimestamp, startTimestamp, agentStat.getDeadlock())).thenReturn(expectedEventBo);
AgentEventBo actualEventBo = agentEventMapper.map(agentStat);
Assert.assertEquals(expectedEventBo, actualEventBo);
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class ThriftAgentEventBatchMapper method map.
public List<AgentEventBo> map(TAgentStatBatch tAgentStatBatch) {
if (tAgentStatBatch == null) {
return Collections.emptyList();
}
final List<TAgentStat> agentStats = tAgentStatBatch.getAgentStats();
if (CollectionUtils.isEmpty(agentStats)) {
return Collections.emptyList();
}
final String agentId = tAgentStatBatch.getAgentId();
final long startTimestamp = tAgentStatBatch.getStartTimestamp();
List<AgentEventBo> agentEventBoList = new ArrayList<>(agentStats.size());
for (TAgentStat tAgentStat : agentStats) {
final long timestamp = tAgentStat.getTimestamp();
if (tAgentStat.isSetDeadlock()) {
TDeadlock deadlock = tAgentStat.getDeadlock();
if (deadlock != null && deadlock.isSetDeadlockedThreadList()) {
agentEventBoList.add(deadlockEventBoMapper.map(agentId, startTimestamp, timestamp, deadlock));
}
}
}
return agentEventBoList;
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class ThriftAgentStatHandlerV2 method handleSimple.
void handleSimple(TBase<?, ?> tBase) {
// FIXME (2014.08) Legacy - TAgentStat should not be sent over the wire.
if (tBase instanceof TAgentStat) {
TAgentStat tAgentStat = (TAgentStat) tBase;
this.handleAgentStat(tAgentStat);
} else if (tBase instanceof TAgentStatBatch) {
TAgentStatBatch tAgentStatBatch = (TAgentStatBatch) tBase;
this.handleAgentStatBatch(tAgentStatBatch);
} else {
throw new IllegalArgumentException("unexpected tbase:" + tBase + " expected:" + TAgentStat.class.getName() + " or " + TAgentStatBatch.class.getName());
}
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class StatThriftMessageConverter method toMessage.
@Override
public TBase<?, ?> toMessage(MetricType message) {
if (message instanceof AgentStatMetricSnapshotBatch) {
final AgentStatMetricSnapshotBatch agentStatMetricSnapshotBatch = (AgentStatMetricSnapshotBatch) message;
final TAgentStatBatch agentStatBatch = new TAgentStatBatch();
agentStatBatch.setAgentId(agentStatMetricSnapshotBatch.getAgentId());
agentStatBatch.setStartTimestamp(agentStatMetricSnapshotBatch.getStartTimestamp());
for (AgentStatMetricSnapshot agentStatMetricSnapshot : agentStatMetricSnapshotBatch.getAgentStats()) {
final TAgentStat agentStat = convertAgentStat(agentStatMetricSnapshot);
agentStatBatch.addToAgentStats(agentStat);
}
return agentStatBatch;
} else if (message instanceof AgentStatMetricSnapshot) {
final AgentStatMetricSnapshot agentStatMetricSnapshot = (AgentStatMetricSnapshot) message;
final TAgentStat agentStat = convertAgentStat(agentStatMetricSnapshot);
return agentStat;
}
return null;
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class StatThriftMessageConverter method convertAgentStat.
private TAgentStat convertAgentStat(final AgentStatMetricSnapshot agentStatMetricSnapshot) {
final TAgentStat agentStat = new TAgentStat();
agentStat.setTimestamp(agentStatMetricSnapshot.getTimestamp());
agentStat.setCollectInterval(agentStatMetricSnapshot.getCollectInterval());
// Agent information
agentStat.setAgentId(agentStatMetricSnapshot.getAgentId());
agentStat.setStartTimestamp(agentStatMetricSnapshot.getStartTimestamp());
// Metric
final JvmGcMetricSnapshot jvmGcMetricSnapshot = agentStatMetricSnapshot.getGc();
if (jvmGcMetricSnapshot != null) {
final TJvmGc jvmGc = convertJvmGc(jvmGcMetricSnapshot);
agentStat.setGc(jvmGc);
}
final CpuLoadMetricSnapshot cpuLoadMetricSnapshot = agentStatMetricSnapshot.getCpuLoad();
if (cpuLoadMetricSnapshot != null) {
final TCpuLoad cpuLoad = convertCpuLoad(cpuLoadMetricSnapshot);
agentStat.setCpuLoad(cpuLoad);
}
final TransactionMetricSnapshot transactionMetricSnapshot = agentStatMetricSnapshot.getTransaction();
if (transactionMetricSnapshot != null) {
final TTransaction transaction = convertTransaction(transactionMetricSnapshot);
agentStat.setTransaction(transaction);
}
final ActiveTraceHistogram activeTraceHistogram = agentStatMetricSnapshot.getActiveTrace();
if (activeTraceHistogram != null) {
final TActiveTrace activeTrace = convertActiveTrace(activeTraceHistogram);
agentStat.setActiveTrace(activeTrace);
}
final DataSourceMetricSnapshot dataSourceMetricSnapshot = agentStatMetricSnapshot.getDataSourceList();
if (dataSourceMetricSnapshot != null) {
final TDataSourceList dataSourceList = convertDataSourceList(dataSourceMetricSnapshot);
agentStat.setDataSourceList(dataSourceList);
}
final ResponseTimeValue responseTimeValue = agentStatMetricSnapshot.getResponseTime();
if (responseTimeValue != null) {
final TResponseTime responseTime = convertResponseTime(responseTimeValue);
agentStat.setResponseTime(responseTime);
}
final DeadlockMetricSnapshot deadlockMetricSnapshot = agentStatMetricSnapshot.getDeadlock();
if (deadlockMetricSnapshot != null) {
final TDeadlock deadlock = convertDeadlock(deadlockMetricSnapshot);
agentStat.setDeadlock(deadlock);
}
final FileDescriptorMetricSnapshot fileDescriptorMetricSnapshot = agentStatMetricSnapshot.getFileDescriptor();
if (fileDescriptorMetricSnapshot != null) {
final TFileDescriptor fileDescriptor = convertFileDescriptor(fileDescriptorMetricSnapshot);
agentStat.setFileDescriptor(fileDescriptor);
}
final BufferMetricSnapshot bufferMetricSnapshot = agentStatMetricSnapshot.getDirectBuffer();
if (bufferMetricSnapshot != null) {
final TDirectBuffer directBuffer = convertDirectBuffer(bufferMetricSnapshot);
agentStat.setDirectBuffer(directBuffer);
}
final TotalThreadMetricSnapshot totalThreadMetricSnapshot = agentStatMetricSnapshot.getTotalThread();
if (totalThreadMetricSnapshot != null) {
final TTotalThreadCount totalThreadCount = convertTotalThreadCount(totalThreadMetricSnapshot);
agentStat.setTotalThreadCount(totalThreadCount);
}
final LoadedClassMetricSnapshot loadedClassMetricSnapshot = agentStatMetricSnapshot.getLoadedClassCount();
if (loadedClassMetricSnapshot != null) {
final TLoadedClass loadedClass = convertLoadedClass(loadedClassMetricSnapshot);
agentStat.setLoadedClass(loadedClass);
}
return agentStat;
}
Aggregations