use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo in project pinpoint by naver.
the class MemoryCodec 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 heapUsedEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
JoinLongFieldEncodingStrategy nonHeapUsedEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
// decode values
final List<JoinLongFieldBo> heapUsedList = this.codec.decodeValues(valueBuffer, heapUsedEncodingStrategy, numValues);
final List<JoinLongFieldBo> nonHeapUsedList = this.codec.decodeValues(valueBuffer, nonHeapUsedEncodingStrategy, numValues);
List<JoinStatBo> joinMemoryBoList = new ArrayList<>(numValues);
for (int i = 0; i < numValues; i++) {
JoinMemoryBo joinMemoryBo = new JoinMemoryBo();
joinMemoryBo.setId(id);
joinMemoryBo.setTimestamp(timestamps.get(i));
joinMemoryBo.setHeapUsedJoinValue(heapUsedList.get(i));
joinMemoryBo.setNonHeapUsedJoinValue(nonHeapUsedList.get(i));
joinMemoryBoList.add(joinMemoryBo);
}
return joinMemoryBoList;
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo in project pinpoint by naver.
the class MemoryCodec method encodeValues.
public void encodeValues(Buffer valueBuffer, List<JoinStatBo> joinMemoryBoList) {
if (CollectionUtils.isEmpty(joinMemoryBoList)) {
throw new IllegalArgumentException("MemoryBoList must not be empty");
}
final int numValues = joinMemoryBoList.size();
valueBuffer.putVInt(numValues);
List<Long> timestamps = new ArrayList<>(numValues);
JoinLongFieldStrategyAnalyzer.Builder heapUsedAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
JoinLongFieldStrategyAnalyzer.Builder nonHeapUsedAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
for (JoinStatBo joinStatBo : joinMemoryBoList) {
JoinMemoryBo joinMemoryBo = (JoinMemoryBo) joinStatBo;
timestamps.add(joinMemoryBo.getTimestamp());
heapUsedAnalyzerBuilder.addValue(joinMemoryBo.getHeapUsedJoinValue());
nonHeapUsedAnalyzerBuilder.addValue(joinMemoryBo.getNonHeapUsedJoinValue());
}
codec.encodeTimestamps(valueBuffer, timestamps);
encodeDataPoints(valueBuffer, heapUsedAnalyzerBuilder.build(), nonHeapUsedAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo in project pinpoint by naver.
the class JoinAgentStatBoMapperTest method map2Test.
@Test
public void map2Test() {
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 TFJvmGc tFJvmGc = new TFJvmGc();
tFJvmGc.setJvmMemoryHeapUsed(1000);
tFJvmGc.setJvmMemoryNonHeapUsed(300);
tFAgentStat.setGc(tFJvmGc);
final TFAgentStat tFAgentStat2 = new TFAgentStat();
tFAgentStat2.setAgentId(agentId);
tFAgentStat2.setTimestamp(1491275148454L);
final TFJvmGc tFJvmGc2 = new TFJvmGc();
tFJvmGc2.setJvmMemoryHeapUsed(2000);
tFJvmGc2.setJvmMemoryNonHeapUsed(500);
tFAgentStat2.setGc(tFJvmGc2);
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<JoinMemoryBo> joinMemoryBoList = joinAgentStatBo.getJoinMemoryBoList();
assertEquals(joinMemoryBoList.size(), 2);
JoinMemoryBo joinMemoryBo = joinMemoryBoList.get(0);
assertEquals(joinMemoryBo.getId(), agentId);
assertEquals(joinMemoryBo.getTimestamp(), 1491274148454L);
assertEquals((long) joinMemoryBo.getHeapUsedJoinValue().getAvg(), 1000);
assertEquals((long) joinMemoryBo.getNonHeapUsedJoinValue().getAvg(), 300);
JoinMemoryBo joinMemoryBo2 = joinMemoryBoList.get(1);
assertEquals(joinMemoryBo2.getId(), agentId);
assertEquals(joinMemoryBo2.getTimestamp(), 1491275148454L);
assertEquals((long) joinMemoryBo2.getHeapUsedJoinValue().getAvg(), 2000);
assertEquals((long) joinMemoryBo2.getNonHeapUsedJoinValue().getAvg(), 500);
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo in project pinpoint by naver.
the class JoinMemorySamplerTest method sampleDataPointsTest.
@Test
public void sampleDataPointsTest() throws Exception {
long currentTime = 1487149800000L;
List<JoinMemoryBo> joinMemoryBoList = createJoinMemoryBoList(currentTime);
AggreJoinMemoryBo aggreJoinMemoryBo = new JoinMemorySampler().sampleDataPoints(1, currentTime, joinMemoryBoList, JoinMemoryBo.EMPTY_JOIN_MEMORY_BO);
assertEquals(aggreJoinMemoryBo.getId(), ID);
assertEquals(aggreJoinMemoryBo.getTimestamp(), currentTime);
assertEquals(aggreJoinMemoryBo.getHeapUsedJoinValue(), new JoinLongFieldBo(3000L, 100L, "app_4_1", 8000L, "app_3_2"));
assertEquals(aggreJoinMemoryBo.getNonHeapUsedJoinValue(), new JoinLongFieldBo(300L, 50L, "app_1_3", 2900L, "app_5_4"));
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo in project pinpoint by naver.
the class JoinMemorySampler method sampleDataPoints.
@Override
public AggreJoinMemoryBo sampleDataPoints(int index, long timestamp, List<JoinMemoryBo> joinMemoryBoList, JoinMemoryBo previousDataPoint) {
if (CollectionUtils.isEmpty(joinMemoryBoList)) {
return AggreJoinMemoryBo.createUncollectedObject(timestamp);
}
JoinMemoryBo joinMemoryBo = JoinMemoryBo.joinMemoryBoList(joinMemoryBoList, timestamp);
String id = joinMemoryBo.getId();
final JoinLongFieldBo heapUsedJoinValue = joinMemoryBo.getHeapUsedJoinValue();
final JoinLongFieldBo nonHeapUsedJoinValue = joinMemoryBo.getNonHeapUsedJoinValue();
AggreJoinMemoryBo aggreJoinMemoryBo = new AggreJoinMemoryBo(id, timestamp, heapUsedJoinValue, nonHeapUsedJoinValue);
return aggreJoinMemoryBo;
}
Aggregations