use of com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2 in project pinpoint by naver.
the class JvmGcCodecV1 method decodeValues.
@Override
public List<JvmGcBo> decodeValues(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
final String agentId = decodingContext.getAgentId();
final long baseTimestamp = decodingContext.getBaseTimestamp();
final long timestampDelta = decodingContext.getTimestampDelta();
final long initialTimestamp = baseTimestamp + timestampDelta;
final JvmGcType gcType = JvmGcType.getTypeByCode(valueBuffer.readVInt());
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);
JvmGcCodecV2.JvmGcCodecDecoder decoder = new JvmGcCodecV2.JvmGcCodecDecoder(codec);
decoder.decode(valueBuffer, headerDecoder, numValues);
List<JvmGcBo> jvmGcBos = new ArrayList<>(numValues);
for (int i = 0; i < numValues; i++) {
JvmGcBo jvmGcBo = decoder.getValue(i);
jvmGcBo.setAgentId(agentId);
jvmGcBo.setTimestamp(timestamps.get(i));
jvmGcBo.setGcType(gcType);
jvmGcBos.add(jvmGcBo);
}
return jvmGcBos;
}
use of com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2 in project pinpoint by naver.
the class JvmGcCodecV1 method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<JvmGcBo> jvmGcBos) {
if (CollectionUtils.isEmpty(jvmGcBos)) {
throw new IllegalArgumentException("jvmGcBos must not be empty");
}
final int gcTypeCode = jvmGcBos.get(0).getGcType().getTypeCode();
valueBuffer.putVInt(gcTypeCode);
final int numValues = jvmGcBos.size();
valueBuffer.putVInt(numValues);
List<Long> timestamps = new ArrayList<>(numValues);
JvmGcCodecV2.JvmGcCodecEncoder encoder = new JvmGcCodecV2.JvmGcCodecEncoder(codec);
for (JvmGcBo jvmGcBo : jvmGcBos) {
timestamps.add(jvmGcBo.getTimestamp());
encoder.addValue(jvmGcBo);
}
this.codec.encodeTimestamps(valueBuffer, timestamps);
encoder.encode(valueBuffer);
}
Aggregations