use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo in project pinpoint by naver.
the class CpuLoadCodec 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> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
// decode headers
final byte[] header = valueBuffer.readPrefixedBytes();
AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
JoinLongFieldEncodingStrategy jvmCpuLoadEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
JoinLongFieldEncodingStrategy systemCpuLoadEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
// decode values
final List<JoinLongFieldBo> jvmCpuLoadList = this.codec.decodeValues(valueBuffer, jvmCpuLoadEncodingStrategy, numValues);
final List<JoinLongFieldBo> systemCpuLoadList = this.codec.decodeValues(valueBuffer, systemCpuLoadEncodingStrategy, numValues);
List<JoinStatBo> joinCpuLoadBoList = new ArrayList<>(numValues);
for (int i = 0; i < numValues; i++) {
JoinCpuLoadBo joinCpuLoadBo = new JoinCpuLoadBo();
joinCpuLoadBo.setId(id);
joinCpuLoadBo.setTimestamp(timestamps.get(i));
joinCpuLoadBo.setJvmCpuLoadJoinValue(jvmCpuLoadList.get(i).toLongFieldBo());
joinCpuLoadBo.setSystemCpuLoadJoinValue(systemCpuLoadList.get(i).toLongFieldBo());
joinCpuLoadBoList.add(joinCpuLoadBo);
}
return joinCpuLoadBoList;
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo in project pinpoint by naver.
the class CpuLoadCodec method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<JoinStatBo> joinCpuLoadBoList) {
if (CollectionUtils.isEmpty(joinCpuLoadBoList)) {
throw new IllegalArgumentException("cpuLoadBoList must not be empty");
}
final int numValues = joinCpuLoadBoList.size();
valueBuffer.putVInt(numValues);
List<Long> timestamps = new ArrayList<>(numValues);
JoinLongFieldStrategyAnalyzer.Builder jvmCpuLoadAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
JoinLongFieldStrategyAnalyzer.Builder systemCpuLoadAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
for (JoinStatBo joinStatBo : joinCpuLoadBoList) {
JoinCpuLoadBo joinCpuLoadBo = (JoinCpuLoadBo) joinStatBo;
timestamps.add(joinCpuLoadBo.getTimestamp());
jvmCpuLoadAnalyzerBuilder.addValue(joinCpuLoadBo.getJvmCpuLoadJoinValue().toLongFieldBo());
systemCpuLoadAnalyzerBuilder.addValue(joinCpuLoadBo.getSystemCpuLoadJoinValue().toLongFieldBo());
}
codec.encodeTimestamps(valueBuffer, timestamps);
encodeDataPoints(valueBuffer, jvmCpuLoadAnalyzerBuilder.build(), systemCpuLoadAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo in project pinpoint by naver.
the class TBaseFlatMapperTest method flatMapTest.
@Test
public void flatMapTest() throws Exception {
ApplicationCache applicationCache = newMockApplicationCache();
TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch();
ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
RawData rawData = newRawData(tfAgentStatBatch);
mapper.flatMap(rawData, collector);
assertEquals(dataList.size(), 2);
Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
assertEquals(data1.f0, AGENT_ID);
assertEquals(data1.f2.longValue(), 1491274143454L);
JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
assertEquals(joinAgentStatBo.getId(), AGENT_ID);
assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
assertJoinCpuLoadBo(joinAgentStatBo.getJoinCpuLoadBoList());
Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
assertEquals(data2.f0, APPLICATION_ID);
assertEquals(data2.f2.longValue(), 1491274140000L);
JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
assertJoinCpuLoadBo(joinApplicationStatBo.getJoinCpuLoadBoList());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo in project pinpoint by naver.
the class TBaseFlatMapperTest method flatMap2Test.
@Test
public void flatMap2Test() throws Exception {
ApplicationCache applicationCache = newMockApplicationCache();
TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch2();
ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
RawData rawdata = newRawData(tfAgentStatBatch);
mapper.flatMap(rawdata, collector);
assertEquals(dataList.size(), 2);
Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
assertEquals(data1.f0, AGENT_ID);
assertEquals(data1.f2.longValue(), 1491274143454L);
JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
assertEquals(joinAgentStatBo.getId(), AGENT_ID);
assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
assertJoinMemoryBo(joinAgentStatBo.getJoinMemoryBoList());
Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
assertEquals(data2.f0, APPLICATION_ID);
assertEquals(data2.f2.longValue(), 1491274140000L);
JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
assertJoinMemoryBo(joinApplicationStatBo.getJoinMemoryBoList());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo in project pinpoint by naver.
the class DirectBufferCodecTest method createJoinDirectBufferBoList.
private List<JoinStatBo> createJoinDirectBufferBoList(long currentTime) {
final String id = "test_app";
final List<JoinStatBo> joinDirectBufferBoList = new ArrayList<>();
JoinDirectBufferBo joinDirectBufferBo1 = new JoinDirectBufferBo(id, 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", currentTime);
JoinDirectBufferBo joinDirectBufferBo2 = new JoinDirectBufferBo(id, 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", currentTime + 5000);
JoinDirectBufferBo joinDirectBufferBo4 = new JoinDirectBufferBo(id, 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", currentTime + 15000);
JoinDirectBufferBo joinDirectBufferBo3 = new JoinDirectBufferBo(id, 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", currentTime + 10000);
JoinDirectBufferBo joinDirectBufferBo5 = new JoinDirectBufferBo(id, 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", currentTime + 20000);
joinDirectBufferBoList.add(joinDirectBufferBo1);
joinDirectBufferBoList.add(joinDirectBufferBo2);
joinDirectBufferBoList.add(joinDirectBufferBo3);
joinDirectBufferBoList.add(joinDirectBufferBo4);
joinDirectBufferBoList.add(joinDirectBufferBo5);
return joinDirectBufferBoList;
}
Aggregations