Search in sources :

Example 1 with JvmGcType

use of com.navercorp.pinpoint.common.server.bo.JvmGcType 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);
    EncodingStrategy<Long> heapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> heapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldCountEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldTimeEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    // decode values
    List<Long> heapUseds = this.codec.decodeValues(valueBuffer, heapUsedEncodingStrategy, numValues);
    List<Long> heapMaxes = this.codec.decodeValues(valueBuffer, heapMaxEncodingStrategy, numValues);
    List<Long> nonHeapUseds = this.codec.decodeValues(valueBuffer, nonHeapUsedEncodingStrategy, numValues);
    List<Long> nonHeapMaxes = this.codec.decodeValues(valueBuffer, nonHeapMaxEncodingStrategy, numValues);
    List<Long> gcOldCounts = this.codec.decodeValues(valueBuffer, gcOldCountEncodingStrategy, numValues);
    List<Long> gcOldTimes = this.codec.decodeValues(valueBuffer, gcOldTimeEncodingStrategy, numValues);
    List<JvmGcBo> jvmGcBos = new ArrayList<JvmGcBo>(numValues);
    for (int i = 0; i < numValues; ++i) {
        JvmGcBo jvmGcBo = new JvmGcBo();
        jvmGcBo.setAgentId(agentId);
        jvmGcBo.setTimestamp(timestamps.get(i));
        jvmGcBo.setGcType(gcType);
        jvmGcBo.setHeapUsed(heapUseds.get(i));
        jvmGcBo.setHeapMax(heapMaxes.get(i));
        jvmGcBo.setNonHeapUsed(nonHeapUseds.get(i));
        jvmGcBo.setNonHeapMax(nonHeapMaxes.get(i));
        jvmGcBo.setGcOldCount(gcOldCounts.get(i));
        jvmGcBo.setGcOldTime(gcOldTimes.get(i));
        jvmGcBos.add(jvmGcBo);
    }
    return jvmGcBos;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) 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 JvmGcType

use of com.navercorp.pinpoint.common.server.bo.JvmGcType in project pinpoint by naver.

the class JvmGcSampler method sampleDataPoints.

@Override
public SampledJvmGc sampleDataPoints(int timeWindowIndex, long timestamp, List<JvmGcBo> dataPoints, JvmGcBo previousDataPoint) {
    JvmGcType jvmGcType = JvmGcType.UNKNOWN;
    List<Long> heapUseds = new ArrayList<>(dataPoints.size());
    List<Long> heapMaxes = new ArrayList<>(dataPoints.size());
    List<Long> nonHeapUseds = new ArrayList<>(dataPoints.size());
    List<Long> nonHeapMaxes = new ArrayList<>(dataPoints.size());
    List<Long> gcOldCounts = new ArrayList<>(dataPoints.size());
    List<Long> gcOldTimes = new ArrayList<>(dataPoints.size());
    // dataPoints are in descending order
    JvmGcBo previousBo = previousDataPoint;
    for (int i = dataPoints.size() - 1; i >= 0; --i) {
        JvmGcBo jvmGcBo = dataPoints.get(i);
        jvmGcType = jvmGcBo.getGcType();
        if (jvmGcBo.getHeapUsed() != JvmGcBo.UNCOLLECTED_VALUE) {
            heapUseds.add(jvmGcBo.getHeapUsed());
        }
        if (jvmGcBo.getHeapMax() != JvmGcBo.UNCOLLECTED_VALUE) {
            heapMaxes.add(jvmGcBo.getHeapMax());
        }
        if (jvmGcBo.getNonHeapUsed() != JvmGcBo.UNCOLLECTED_VALUE) {
            nonHeapUseds.add(jvmGcBo.getNonHeapUsed());
        }
        if (jvmGcBo.getNonHeapMax() != JvmGcBo.UNCOLLECTED_VALUE) {
            nonHeapMaxes.add(jvmGcBo.getNonHeapMax());
        }
        if (previousBo != null) {
            // Added to maintain backwards compatibility for data that do not have agent start timestamp.
            if (checkJvmRestart(previousBo, jvmGcBo)) {
                if (isGcCollected(jvmGcBo)) {
                    gcOldCounts.add(jvmGcBo.getGcOldCount());
                    gcOldTimes.add(jvmGcBo.getGcOldTime());
                } else {
                    jvmGcBo.setGcOldCount(0L);
                    jvmGcBo.setGcOldTime(0L);
                }
            } else {
                if (isGcCollected(jvmGcBo) && isGcCollected(previousBo)) {
                    gcOldCounts.add(jvmGcBo.getGcOldCount() - previousBo.getGcOldCount());
                    gcOldTimes.add(jvmGcBo.getGcOldTime() - previousBo.getGcOldTime());
                } else {
                    if (!isGcCollected(jvmGcBo)) {
                        jvmGcBo.setGcOldCount(previousBo.getGcOldCount());
                        jvmGcBo.setGcOldTime(previousBo.getGcOldTime());
                    }
                }
            }
        } else {
            if (isGcCollected(jvmGcBo)) {
                if (timeWindowIndex > 0) {
                    gcOldCounts.add(jvmGcBo.getGcOldCount());
                    gcOldTimes.add(jvmGcBo.getGcOldTime());
                } else {
                    gcOldCounts.add(0L);
                    gcOldTimes.add(0L);
                }
            }
        }
        previousBo = jvmGcBo;
    }
    SampledJvmGc sampledJvmGc = new SampledJvmGc();
    sampledJvmGc.setJvmGcType(jvmGcType);
    sampledJvmGc.setHeapUsed(createSampledPoint(timestamp, heapUseds));
    sampledJvmGc.setHeapMax(createSampledPoint(timestamp, heapMaxes));
    sampledJvmGc.setNonHeapUsed(createSampledPoint(timestamp, nonHeapUseds));
    sampledJvmGc.setNonHeapMax(createSampledPoint(timestamp, nonHeapMaxes));
    sampledJvmGc.setGcOldCount(createSampledPoint(timestamp, gcOldCounts));
    sampledJvmGc.setGcOldTime(createSampledPoint(timestamp, gcOldTimes));
    return sampledJvmGc;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) ArrayList(java.util.ArrayList) JvmGcType(com.navercorp.pinpoint.common.server.bo.JvmGcType) SampledJvmGc(com.navercorp.pinpoint.web.vo.stat.SampledJvmGc) UncollectedPoint(com.navercorp.pinpoint.web.vo.chart.UncollectedPoint) Point(com.navercorp.pinpoint.web.vo.chart.Point)

Example 3 with JvmGcType

use of com.navercorp.pinpoint.common.server.bo.JvmGcType in project pinpoint by naver.

the class JvmGcCodecV2 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> startTimestamps = this.codec.decodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, numValues);
    List<Long> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
    // decode headers
    final byte[] header = valueBuffer.readPrefixedBytes();
    AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
    EncodingStrategy<Long> heapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> heapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldCountEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldTimeEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    // decode values
    List<Long> heapUseds = this.codec.decodeValues(valueBuffer, heapUsedEncodingStrategy, numValues);
    List<Long> heapMaxes = this.codec.decodeValues(valueBuffer, heapMaxEncodingStrategy, numValues);
    List<Long> nonHeapUseds = this.codec.decodeValues(valueBuffer, nonHeapUsedEncodingStrategy, numValues);
    List<Long> nonHeapMaxes = this.codec.decodeValues(valueBuffer, nonHeapMaxEncodingStrategy, numValues);
    List<Long> gcOldCounts = this.codec.decodeValues(valueBuffer, gcOldCountEncodingStrategy, numValues);
    List<Long> gcOldTimes = this.codec.decodeValues(valueBuffer, gcOldTimeEncodingStrategy, numValues);
    List<JvmGcBo> jvmGcBos = new ArrayList<JvmGcBo>(numValues);
    for (int i = 0; i < numValues; ++i) {
        JvmGcBo jvmGcBo = new JvmGcBo();
        jvmGcBo.setAgentId(agentId);
        jvmGcBo.setStartTimestamp(startTimestamps.get(i));
        jvmGcBo.setTimestamp(timestamps.get(i));
        jvmGcBo.setGcType(gcType);
        jvmGcBo.setHeapUsed(heapUseds.get(i));
        jvmGcBo.setHeapMax(heapMaxes.get(i));
        jvmGcBo.setNonHeapUsed(nonHeapUseds.get(i));
        jvmGcBo.setNonHeapMax(nonHeapMaxes.get(i));
        jvmGcBo.setGcOldCount(gcOldCounts.get(i));
        jvmGcBo.setGcOldTime(gcOldTimes.get(i));
        jvmGcBos.add(jvmGcBo);
    }
    return jvmGcBos;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) 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)

Aggregations

JvmGcType (com.navercorp.pinpoint.common.server.bo.JvmGcType)3 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)3 ArrayList (java.util.ArrayList)3 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)2 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)2 Point (com.navercorp.pinpoint.web.vo.chart.Point)1 UncollectedPoint (com.navercorp.pinpoint.web.vo.chart.UncollectedPoint)1 SampledJvmGc (com.navercorp.pinpoint.web.vo.stat.SampledJvmGc)1