use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo in project pinpoint by naver.
the class ActiveTraceCodec method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<JoinStatBo> joinActiveTraceBoList) {
if (CollectionUtils.isEmpty(joinActiveTraceBoList)) {
throw new IllegalArgumentException("JoinActiveTraceBoList must not be empty");
}
final int numValues = joinActiveTraceBoList.size();
valueBuffer.putVInt(numValues);
List<Long> timestamps = new ArrayList<>(numValues);
UnsignedShortEncodingStrategy.Analyzer.Builder versionAnalyzerBuilder = new UnsignedShortEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder schemaTypeAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
JoinIntFieldStrategyAnalyzer.Builder totalCountAnalyzerBuilder = new JoinIntFieldStrategyAnalyzer.Builder();
for (JoinStatBo joinStatBo : joinActiveTraceBoList) {
JoinActiveTraceBo joinActiveTraceBo = (JoinActiveTraceBo) joinStatBo;
timestamps.add(joinActiveTraceBo.getTimestamp());
versionAnalyzerBuilder.addValue(joinActiveTraceBo.getVersion());
schemaTypeAnalyzerBuilder.addValue(joinActiveTraceBo.getHistogramSchemaType());
totalCountAnalyzerBuilder.addValue(joinActiveTraceBo.getTotalCountJoinValue());
}
codec.encodeTimestamps(valueBuffer, timestamps);
encodeDataPoints(valueBuffer, versionAnalyzerBuilder.build(), schemaTypeAnalyzerBuilder.build(), totalCountAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo in project pinpoint by naver.
the class ActiveTraceCodec method decodeValues.
@Override
public List<JoinStatBo> decodeValues(Buffer valueBuffer, ApplicationStatDecodingContext decodingContext) {
final String id = decodingContext.getApplicationId();
final long baseTimestamp = decodingContext.getBaseTimestamp();
final long timestampDelta = decodingContext.getTimestampDelta();
final long initialTimestamp = baseTimestamp + timestampDelta;
int numValues = valueBuffer.readVInt();
List<Long> timestampList = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
final byte[] header = valueBuffer.readPrefixedBytes();
AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
EncodingStrategy<Short> versionEncodingStrategy = UnsignedShortEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> schemaTypeEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
JoinIntFieldEncodingStrategy totalCountJoinIntValueEncodingStrategy = JoinIntFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
List<Short> versionList = this.codec.decodeValues(valueBuffer, versionEncodingStrategy, numValues);
List<Integer> schemaTypeList = this.codec.decodeValues(valueBuffer, schemaTypeEncodingStrategy, numValues);
List<JoinIntFieldBo> totalCountJoinIntValueList = this.codec.decodeValues(valueBuffer, totalCountJoinIntValueEncodingStrategy, numValues);
List<JoinStatBo> joinActiveTraceBoList = new ArrayList<>();
for (int i = 0; i < numValues; i++) {
JoinActiveTraceBo joinActiveTraceBo = new JoinActiveTraceBo();
joinActiveTraceBo.setId(id);
joinActiveTraceBo.setVersion(versionList.get(i));
joinActiveTraceBo.setTimestamp(timestampList.get(i));
joinActiveTraceBo.setHistogramSchemaType(schemaTypeList.get(i));
joinActiveTraceBo.setTotalCountJoinValue(totalCountJoinIntValueList.get(i));
joinActiveTraceBoList.add(joinActiveTraceBo);
}
return joinActiveTraceBoList;
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo in project pinpoint by naver.
the class JoinAgentStatBoMapperTest method map4Test.
@Test
public void map4Test() {
final String agentId = "testAgent";
final JoinAgentStatBoMapper joinAgentStatBoMapper = new JoinAgentStatBoMapper();
final TFAgentStatBatch tFAgentStatBatch = new TFAgentStatBatch();
tFAgentStatBatch.setStartTimestamp(1491274138454L);
tFAgentStatBatch.setAgentId(agentId);
final TFAgentStat tFAgentStat = new TFAgentStat();
tFAgentStat.setAgentId(agentId);
tFAgentStat.setTimestamp(1491274148454L);
final TFActiveTraceHistogram tFActiveTraceHistogram = new TFActiveTraceHistogram();
List<Integer> activeTraceCount = new ArrayList<>(4);
activeTraceCount.add(10);
activeTraceCount.add(20);
activeTraceCount.add(40);
activeTraceCount.add(50);
tFActiveTraceHistogram.setVersion((short) 2);
tFActiveTraceHistogram.setHistogramSchemaType(1);
tFActiveTraceHistogram.setActiveTraceCount(activeTraceCount);
final TFActiveTrace tfActiveTrace = new TFActiveTrace();
tfActiveTrace.setHistogram(tFActiveTraceHistogram);
tFAgentStat.setActiveTrace(tfActiveTrace);
final TFAgentStat tFAgentStat2 = new TFAgentStat();
tFAgentStat2.setAgentId(agentId);
tFAgentStat2.setTimestamp(1491275148454L);
tFAgentStat2.setCollectInterval(5000);
final TFActiveTraceHistogram tFActiveTraceHistogram2 = new TFActiveTraceHistogram();
List<Integer> activeTraceCount2 = new ArrayList<>(4);
activeTraceCount2.add(11);
activeTraceCount2.add(21);
activeTraceCount2.add(41);
activeTraceCount2.add(51);
tFActiveTraceHistogram2.setVersion((short) 2);
tFActiveTraceHistogram2.setHistogramSchemaType(1);
tFActiveTraceHistogram2.setActiveTraceCount(activeTraceCount2);
final TFActiveTrace tfActiveTrace2 = new TFActiveTrace();
tfActiveTrace2.setHistogram(tFActiveTraceHistogram2);
tFAgentStat2.setActiveTrace(tfActiveTrace2);
final List<TFAgentStat> tFAgentStatList = new ArrayList<>(2);
tFAgentStatList.add(tFAgentStat);
tFAgentStatList.add(tFAgentStat2);
tFAgentStatBatch.setAgentStats(tFAgentStatList);
JoinAgentStatBo joinAgentStatBo = joinAgentStatBoMapper.map(tFAgentStatBatch);
assertEquals(joinAgentStatBo.getId(), agentId);
assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274138454L);
assertEquals(joinAgentStatBo.getTimestamp(), 1491274148454L);
List<JoinActiveTraceBo> joinActiveTraceBoList = joinAgentStatBo.getJoinActiveTraceBoList();
assertEquals(joinActiveTraceBoList.size(), 2);
JoinActiveTraceBo joinActiveTraceBo = joinActiveTraceBoList.get(0);
assertEquals(joinActiveTraceBo.getId(), agentId);
assertEquals(joinActiveTraceBo.getTimestamp(), 1491274148454L);
assertEquals(joinActiveTraceBo.getVersion(), 2);
assertEquals(joinActiveTraceBo.getHistogramSchemaType(), 1);
assertEquals(joinActiveTraceBo.getTotalCountJoinValue(), new JoinIntFieldBo(120, 120, agentId, 120, agentId));
JoinActiveTraceBo joinActiveTraceBo2 = joinActiveTraceBoList.get(1);
assertEquals(joinActiveTraceBo2.getId(), agentId);
assertEquals(joinActiveTraceBo2.getTimestamp(), 1491275148454L);
assertEquals(joinActiveTraceBo2.getVersion(), 2);
assertEquals(joinActiveTraceBo2.getHistogramSchemaType(), 1);
assertEquals(joinActiveTraceBo2.getTotalCountJoinValue(), new JoinIntFieldBo(124, 124, agentId, 124, agentId));
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo in project pinpoint by naver.
the class JoinThriftActiveTraceBoMapperTest method mapTest.
@Test
public void mapTest() throws Exception {
final TFAgentStat tFAgentStat = new TFAgentStat();
final String id = "testAgent";
tFAgentStat.setAgentId(id);
tFAgentStat.setTimestamp(1491274148454L);
final TFActiveTraceHistogram tFActiveTraceHistogram = new TFActiveTraceHistogram();
List<Integer> activeTraceCount = new ArrayList<>(4);
activeTraceCount.add(10);
activeTraceCount.add(20);
activeTraceCount.add(40);
activeTraceCount.add(50);
tFActiveTraceHistogram.setVersion((short) 2);
tFActiveTraceHistogram.setHistogramSchemaType(1);
tFActiveTraceHistogram.setActiveTraceCount(activeTraceCount);
final TFActiveTrace tFActiveTrace = new TFActiveTrace();
tFActiveTrace.setHistogram(tFActiveTraceHistogram);
tFAgentStat.setActiveTrace(tFActiveTrace);
final JoinActiveTraceBoMapper joinActiveTraceBoMapper = new JoinActiveTraceBoMapper();
final JoinActiveTraceBo joinActiveTraceBo = joinActiveTraceBoMapper.map(tFAgentStat);
assertNotNull(joinActiveTraceBo);
assertEquals(joinActiveTraceBo.getId(), id);
assertEquals(joinActiveTraceBo.getTimestamp(), 1491274148454L);
assertEquals(joinActiveTraceBo.getVersion(), 2);
assertEquals(joinActiveTraceBo.getHistogramSchemaType(), 1);
assertEquals(joinActiveTraceBo.getTotalCountJoinValue(), new JoinIntFieldBo(120, 120, id, 120, id));
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo in project pinpoint by naver.
the class JoinActiveTraceBoMapper method map.
@Override
public JoinActiveTraceBo map(TFAgentStat tFAgentStat) {
if (!tFAgentStat.isSetActiveTrace()) {
return JoinActiveTraceBo.EMPTY_JOIN_ACTIVE_TRACE_BO;
}
final TFActiveTrace tFactiveTrace = tFAgentStat.getActiveTrace();
final String agentId = tFAgentStat.getAgentId();
if (tFactiveTrace.isSetHistogram() == false) {
return JoinActiveTraceBo.EMPTY_JOIN_ACTIVE_TRACE_BO;
}
final TFActiveTraceHistogram histogram = tFactiveTrace.getHistogram();
final int totalCount = calculateTotalCount(tFactiveTrace.getHistogram());
JoinActiveTraceBo joinActiveTraceBo = new JoinActiveTraceBo();
joinActiveTraceBo.setId(agentId);
joinActiveTraceBo.setTimestamp(tFAgentStat.getTimestamp());
joinActiveTraceBo.setHistogramSchemaType(histogram.getHistogramSchemaType());
joinActiveTraceBo.setVersion(histogram.getVersion());
joinActiveTraceBo.setTotalCountJoinValue(new JoinIntFieldBo(totalCount, totalCount, agentId, totalCount, agentId));
return joinActiveTraceBo;
}
Aggregations