use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class LegacyAgentStatMapper method readAgentStatThriftDto.
// FIXME (2014.08) Legacy support for TAgentStat Thrift DTO stored directly into hbase.
@Deprecated
private List<AgentStat> readAgentStatThriftDto(String agentId, long timestamp, byte[] tAgentStatByteArray) throws TException {
// CompactProtocol used
TDeserializer deserializer = new TDeserializer(factory);
TAgentStat tAgentStat = new TAgentStat();
deserializer.deserialize(tAgentStat, tAgentStatByteArray);
TJvmGc gc = tAgentStat.getGc();
if (gc == null) {
return Collections.emptyList();
}
AgentStatMemoryGcBo.Builder memoryGcBoBuilder = new AgentStatMemoryGcBo.Builder(tAgentStat.getAgentId(), tAgentStat.getStartTimestamp(), tAgentStat.getTimestamp());
memoryGcBoBuilder.gcType(gc.getType().name());
memoryGcBoBuilder.jvmMemoryHeapUsed(gc.getJvmMemoryHeapUsed());
memoryGcBoBuilder.jvmMemoryHeapMax(gc.getJvmMemoryHeapMax());
memoryGcBoBuilder.jvmMemoryNonHeapUsed(gc.getJvmMemoryNonHeapUsed());
memoryGcBoBuilder.jvmMemoryNonHeapMax(gc.getJvmMemoryNonHeapMax());
memoryGcBoBuilder.jvmGcOldCount(gc.getJvmGcOldCount());
memoryGcBoBuilder.jvmGcOldTime(gc.getJvmGcOldTime());
AgentStat agentStat = new AgentStat(agentId, timestamp);
AgentStatMemoryGcBo agentStatMemoryGcBo = memoryGcBoBuilder.build();
agentStat.setGcType(agentStatMemoryGcBo.getGcType());
agentStat.setGcOldCount(agentStatMemoryGcBo.getJvmGcOldCount());
agentStat.setGcOldTime(agentStatMemoryGcBo.getJvmGcOldTime());
agentStat.setHeapUsed(agentStatMemoryGcBo.getJvmMemoryHeapUsed());
agentStat.setHeapMax(agentStatMemoryGcBo.getJvmMemoryHeapMax());
agentStat.setNonHeapUsed(agentStatMemoryGcBo.getJvmMemoryNonHeapUsed());
agentStat.setNonHeapMax(agentStatMemoryGcBo.getJvmMemoryNonHeapMax());
List<AgentStat> result = new ArrayList<>(1);
result.add(agentStat);
return result;
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class LegacyAgentStatMapperTest method createResultForLegacyWith_AGENT_STAT_CF_STATISTICS_V1.
private Result createResultForLegacyWith_AGENT_STAT_CF_STATISTICS_V1() throws TException {
final TAgentStat agentStat = new TAgentStat();
final TJvmGc gc = new TJvmGc();
gc.setType(GC_TYPE);
gc.setJvmGcOldCount(GC_OLD_COUNT);
gc.setJvmGcOldTime(GC_OLD_TIME);
gc.setJvmMemoryHeapUsed(HEAP_USED);
gc.setJvmMemoryHeapMax(HEAP_MAX);
gc.setJvmMemoryNonHeapUsed(NON_HEAP_USED);
gc.setJvmMemoryNonHeapMax(NON_HEAP_MAX);
agentStat.setGc(gc);
final TProtocolFactory factory = new TCompactProtocol.Factory();
final TSerializer serializer = new TSerializer(factory);
final byte[] qualifier = AGENT_STAT_CF_STATISTICS_V1;
final byte[] value = serializer.serialize(agentStat);
return Result.create(Arrays.asList(createCell(qualifier, value)));
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat in project pinpoint by naver.
the class AgentStatHandler method handleAgentStatBatch.
private <T extends TAgentStatBatch> void handleAgentStatBatch(T agentStatBatch) {
if (logger.isDebugEnabled()) {
logger.debug("Received AgentStats={}", agentStatBatch);
}
String agentId = agentStatBatch.getAgentId();
long startTimestamp = agentStatBatch.getStartTimestamp();
for (TAgentStat agentStat : agentStatBatch.getAgentStats()) {
handleAgentStat(agentId, startTimestamp, agentStat);
}
}
use of com.navercorp.pinpoint.thrift.dto.TAgentStat 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.thrift.dto.TAgentStat 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);
}
Aggregations