use of com.navercorp.pinpoint.thrift.dto.TAgentStatBatch in project pinpoint by naver.
the class AgentStatMonitorTest method testAgentStatMonitor.
@Test
public void testAgentStatMonitor() throws InterruptedException {
// Given
final long collectionIntervalMs = 1000 * 1;
final int numCollectionsPerBatch = 2;
final int minNumBatchToTest = 2;
final long totalTestDurationMs = collectionIntervalMs + collectionIntervalMs * numCollectionsPerBatch * minNumBatchToTest;
// When
AgentStatMonitor monitor = new DefaultAgentStatMonitor(this.dataSender, "agentId", System.currentTimeMillis(), agentStatCollector, collectionIntervalMs, numCollectionsPerBatch);
monitor.start();
Thread.sleep(totalTestDurationMs);
monitor.stop();
// Then
assertTrue(tBaseRecorder.size() >= minNumBatchToTest);
for (TAgentStatBatch agentStatBatch : tBaseRecorder) {
logger.debug("agentStatBatch:{}", agentStatBatch);
assertTrue(agentStatBatch.getAgentStats().size() <= numCollectionsPerBatch);
}
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStatBatch in project pinpoint by naver.
the class AgentStatHandlerV2Test method testHandleForTAgentStatBatch.
@Test
public void testHandleForTAgentStatBatch() {
// Given
final int numBatches = 6;
final String agentId = "agentId";
final long startTimestamp = Long.MAX_VALUE;
final TAgentStatBatch agentStatBatch = createAgentStatBatch(agentId, startTimestamp, numBatches);
final AgentStatBo mappedAgentStat = new AgentStatBo();
when(this.agentStatBatchMapper.map(agentStatBatch)).thenReturn(mappedAgentStat);
// When
agentStatHandler.handle(agentStatBatch);
// Then
verify(jvmGcDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getJvmGcBos());
verify(jvmGcDetailedDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getJvmGcDetailedBos());
verify(cpuLoadDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getCpuLoadBos());
verify(transactionDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getTransactionBos());
verify(activeTraceDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getActiveTraceBos());
verify(dataSourceDao).insert(mappedAgentStat.getAgentId(), mappedAgentStat.getDataSourceListBos());
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStatBatch in project pinpoint by naver.
the class AgentStatHandler method handle.
@Override
public void handle(TBase<?, ?> tbase) {
// FIXME (2014.08) Legacy - TAgentStats should not be sent over the wire.
if (tbase instanceof TAgentStat) {
final TAgentStat agentStat = (TAgentStat) tbase;
String agentId = agentStat.getAgentId();
long startTimestamp = agentStat.getStartTimestamp();
handleAgentStat(agentId, startTimestamp, agentStat);
} else if (tbase instanceof TAgentStatBatch) {
handleAgentStatBatch((TAgentStatBatch) tbase);
} else {
throw new IllegalArgumentException("unexpected tbase:" + tbase + " expected:" + TAgentStat.class.getName() + " or " + TAgentStatBatch.class.getName());
}
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStatBatch in project pinpoint by naver.
the class AgentStatHandlerV2 method handle.
@Override
public void handle(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());
}
if (agentStatService != null) {
agentStatService.save(tbase);
}
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStatBatch in project pinpoint by naver.
the class AgentStatHandlerV2Test method createAgentStatBatch.
private TAgentStatBatch createAgentStatBatch(String agentId, long startTimestamp, int numBatches) {
final TAgentStatBatch agentStatBatch = new TAgentStatBatch();
agentStatBatch.setAgentId(agentId);
agentStatBatch.setStartTimestamp(startTimestamp);
final List<TAgentStat> agentStats = new ArrayList<>(numBatches);
for (int i = 0; i < numBatches; ++i) {
agentStats.add(createAgentStat(agentId, startTimestamp));
}
agentStatBatch.setAgentStats(agentStats);
return agentStatBatch;
}
Aggregations