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;
}
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);
}
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());
}
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());
}
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();
}
Aggregations