Search in sources :

Example 1 with AgentStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo in project pinpoint by naver.

the class AgentStatBatchMapper method map.

@Override
public AgentStatBo map(TAgentStatBatch tAgentStatBatch) {
    if (!tAgentStatBatch.isSetAgentStats()) {
        return null;
    }
    AgentStatBo agentStatBo = new AgentStatBo();
    final String agentId = tAgentStatBatch.getAgentId();
    final long startTimestamp = tAgentStatBatch.getStartTimestamp();
    agentStatBo.setAgentId(agentId);
    List<JvmGcBo> jvmGcBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<JvmGcDetailedBo> jvmGcDetailedBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<CpuLoadBo> cpuLoadBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<TransactionBo> transactionBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<ActiveTraceBo> activeTraceBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<DataSourceListBo> dataSourceListBos = new ArrayList<DataSourceListBo>(tAgentStatBatch.getAgentStatsSize());
    for (TAgentStat tAgentStat : tAgentStatBatch.getAgentStats()) {
        final long timestamp = tAgentStat.getTimestamp();
        // jvmGc
        if (tAgentStat.isSetGc()) {
            JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
            setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
            jvmGcBos.add(jvmGcBo);
        }
        // jvmGcDetailed
        if (tAgentStat.isSetGc()) {
            if (tAgentStat.getGc().isSetJvmGcDetailed()) {
                JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
                setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
                jvmGcDetailedBos.add(jvmGcDetailedBo);
            }
        }
        // cpuLoad
        if (tAgentStat.isSetCpuLoad()) {
            CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
            setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
            cpuLoadBos.add(cpuLoadBo);
        }
        // transaction
        if (tAgentStat.isSetTransaction()) {
            TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
            setBaseData(transactionBo, agentId, startTimestamp, timestamp);
            transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
            transactionBos.add(transactionBo);
        }
        // activeTrace
        if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
            ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
            setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
            activeTraceBos.add(activeTraceBo);
        }
        // datasource
        if (tAgentStat.isSetDataSourceList()) {
            DataSourceListBo dataSourceListBo = new DataSourceListBo();
            setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
            TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
            if (dataSourceList.getDataSourceListSize() > 0) {
                for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
                    DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
                    setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
                    dataSourceListBo.add(dataSourceBo);
                }
            }
            dataSourceListBos.add(dataSourceListBo);
        }
    }
    agentStatBo.setJvmGcBos(jvmGcBos);
    agentStatBo.setJvmGcDetailedBos(jvmGcDetailedBos);
    agentStatBo.setCpuLoadBos(cpuLoadBos);
    agentStatBo.setTransactionBos(transactionBos);
    agentStatBo.setActiveTraceBos(activeTraceBos);
    agentStatBo.setDataSourceListBos(dataSourceListBos);
    return agentStatBo;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) JvmGcDetailedBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo) ArrayList(java.util.ArrayList) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) TDataSource(com.navercorp.pinpoint.thrift.dto.TDataSource) TDataSourceList(com.navercorp.pinpoint.thrift.dto.TDataSourceList) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) TransactionBo(com.navercorp.pinpoint.common.server.bo.stat.TransactionBo) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 2 with AgentStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo in project pinpoint by naver.

the class AgentStatHandlerV2Test method insertShouldNotBeCalledIfTAgentStatIsMappedToNull.

@Test
public void insertShouldNotBeCalledIfTAgentStatIsMappedToNull() {
    // Given
    final String agentId = "agentId";
    final long startTimestamp = Long.MAX_VALUE;
    final TAgentStat agentStat = createAgentStat(agentId, startTimestamp);
    final AgentStatBo mappedAgentStat = null;
    when(this.agentStatMapper.map(agentStat)).thenReturn(mappedAgentStat);
    // When
    agentStatHandler.handle(agentStat);
    // Then
    verifyZeroInteractions(jvmGcDao);
    verifyZeroInteractions(jvmGcDetailedDao);
    verifyZeroInteractions(cpuLoadDao);
    verifyZeroInteractions(transactionDao);
    verifyZeroInteractions(activeTraceDao);
    verifyZeroInteractions(dataSourceDao);
}
Also used : AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) Test(org.junit.Test)

Example 3 with AgentStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo in project pinpoint by naver.

the class AgentStatHandlerV2Test method testHandleForTAgentStat.

@Test
public void testHandleForTAgentStat() {
    // Given
    final String agentId = "agentId";
    final long startTimestamp = Long.MAX_VALUE;
    final TAgentStat agentStat = createAgentStat(agentId, startTimestamp);
    final AgentStatBo mappedAgentStat = new AgentStatBo();
    when(this.agentStatMapper.map(agentStat)).thenReturn(mappedAgentStat);
    // When
    agentStatHandler.handle(agentStat);
    // 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) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) Test(org.junit.Test)

Example 4 with AgentStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo 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 5 with AgentStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo in project pinpoint by naver.

the class GrpcAgentStatMapper method map.

public AgentStatBo map(PAgentStat agentStat) {
    if (agentStat == null) {
        return null;
    }
    final Header agentInfo = ServerContext.getAgentInfo();
    final String agentId = agentInfo.getAgentId();
    final long startTimestamp = agentInfo.getAgentStartTime();
    final AgentStatBo.Builder builder = AgentStatBo.newBuilder(agentId, startTimestamp);
    this.map(agentStat, builder);
    return builder.build();
}
Also used : AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) Header(com.navercorp.pinpoint.grpc.Header)

Aggregations

AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)40 Test (org.junit.Test)13 TFAgentStat (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat)9 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)5 ActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)4 DataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)4 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)4 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)4 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)3 TransactionBo (com.navercorp.pinpoint.common.server.bo.stat.TransactionBo)3 FileDescriptorBo (com.navercorp.pinpoint.common.server.bo.stat.FileDescriptorBo)2 JvmGcDetailedBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo)2 LoadedClassBo (com.navercorp.pinpoint.common.server.bo.stat.LoadedClassBo)2 ResponseTimeBo (com.navercorp.pinpoint.common.server.bo.stat.ResponseTimeBo)2 TotalThreadCountBo (com.navercorp.pinpoint.common.server.bo.stat.TotalThreadCountBo)2 Header (com.navercorp.pinpoint.grpc.Header)2 TAgentStatBatch (com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)2 TDataSource (com.navercorp.pinpoint.thrift.dto.TDataSource)2 TDataSourceList (com.navercorp.pinpoint.thrift.dto.TDataSourceList)2 TFActiveTraceHistogram (com.navercorp.pinpoint.thrift.dto.flink.TFActiveTraceHistogram)2