Search in sources :

Example 1 with JvmGcCodecV2

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;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) JvmGcCodecV2(com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2) BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList) JvmGcType(com.navercorp.pinpoint.common.server.bo.JvmGcType) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)

Example 2 with JvmGcCodecV2

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);
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) JvmGcCodecV2(com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2) ArrayList(java.util.ArrayList)

Aggregations

JvmGcCodecV2 (com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2)2 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)2 ArrayList (java.util.ArrayList)2 JvmGcType (com.navercorp.pinpoint.common.server.bo.JvmGcType)1 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)1 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)1