Search in sources :

Example 1 with TAgentStatBatch

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);
    }
}
Also used : DefaultAgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch) DefaultAgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor) AgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor) Test(org.junit.Test)

Example 2 with TAgentStatBatch

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());
}
Also used : AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch) Test(org.junit.Test)

Example 3 with TAgentStatBatch

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());
    }
}
Also used : TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)

Example 4 with TAgentStatBatch

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);
    }
}
Also used : TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)

Example 5 with TAgentStatBatch

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;
}
Also used : TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) ArrayList(java.util.ArrayList) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)

Aggregations

TAgentStatBatch (com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)7 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)4 Test (org.junit.Test)3 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)2 AgentStatMonitor (com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor)1 DefaultAgentStatMonitor (com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor)1 ListenableDataSender (com.navercorp.pinpoint.test.ListenableDataSender)1 TBaseRecorderAdaptor (com.navercorp.pinpoint.test.TBaseRecorderAdaptor)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1