Search in sources :

Example 36 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class EncodingStrategyTestBase method testStrategy.

public <T> void testStrategy(List<T> expectedValues, EncodingStrategy<T> strategy) {
    Buffer encodeBuffer = new AutomaticBuffer();
    strategy.encodeValues(encodeBuffer, expectedValues);
    Buffer decodeBuffer = new FixedBuffer(encodeBuffer.getBuffer());
    List<T> actualValues = strategy.decodeValues(decodeBuffer, expectedValues.size());
    Assert.assertEquals(expectedValues, actualValues);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 37 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class ApplicationMapStatisticsUtils method makeRowKey.

/**
     * <pre>
     * rowkey format = "APPLICATIONNAME(max 24bytes)" + apptype(2byte) + "TIMESTAMP(8byte)"
     * </pre>
     *
     * @param applicationName
     * @param timestamp
     * @return
     */
public static byte[] makeRowKey(String applicationName, short applicationType, long timestamp) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    final byte[] applicationNameBytes = BytesUtils.toBytes(applicationName);
    final Buffer buffer = new AutomaticBuffer(2 + applicationNameBytes.length + 2 + 8);
    //        buffer.put2PrefixedString(applicationName);
    buffer.putShort((short) applicationNameBytes.length);
    buffer.putBytes(applicationNameBytes);
    buffer.putShort(applicationType);
    long reverseTimeMillis = TimeUtils.reverseTimeMillis(timestamp);
    buffer.putLong(reverseTimeMillis);
    return buffer.getBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 38 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class HbaseApplicationTraceIndexDao method makeResponseTimeFilter.

/**
     * make the hbase filter for selecting values of y-axis(response time) in order to select transactions in scatter chart.
     * 4 bytes for elapsed time should be attached for the prefix of column qualifier for to use this filter.
     *
     * @param area
     * @param offsetTransactionId
     * @param offsetTransactionElapsed
     * @return
     */
private Filter makeResponseTimeFilter(final SelectedScatterArea area, final TransactionId offsetTransactionId, int offsetTransactionElapsed) {
    // filter by response time
    ResponseTimeRange responseTimeRange = area.getResponseTimeRange();
    byte[] responseFrom = Bytes.toBytes(responseTimeRange.getFrom());
    byte[] responseTo = Bytes.toBytes(responseTimeRange.getTo());
    FilterList filterList = new FilterList(Operator.MUST_PASS_ALL);
    filterList.addFilter(new QualifierFilter(CompareOp.GREATER_OR_EQUAL, new BinaryPrefixComparator(responseFrom)));
    filterList.addFilter(new QualifierFilter(CompareOp.LESS_OR_EQUAL, new BinaryPrefixComparator(responseTo)));
    // add offset
    if (offsetTransactionId != null) {
        final Buffer buffer = new AutomaticBuffer(32);
        buffer.putInt(offsetTransactionElapsed);
        buffer.putPrefixedString(offsetTransactionId.getAgentId());
        buffer.putSVLong(offsetTransactionId.getAgentStartTime());
        buffer.putVLong(offsetTransactionId.getTransactionSequence());
        byte[] qualifierOffset = buffer.getBuffer();
        filterList.addFilter(new QualifierFilter(CompareOp.GREATER, new BinaryPrefixComparator(qualifierOffset)));
    }
    return filterList;
}
Also used : AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) BinaryPrefixComparator(org.apache.hadoop.hbase.filter.BinaryPrefixComparator) ResponseTimeRange(com.navercorp.pinpoint.web.vo.ResponseTimeRange) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FilterList(org.apache.hadoop.hbase.filter.FilterList) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Example 39 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class ApplicationMapStatisticsUtils method makeColumnName.

public static byte[] makeColumnName(short serviceType, String applicationName, String destHost, short slotNumber) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    if (destHost == null) {
        // throw new NullPointerException("destHost must not be null");
        destHost = "";
    }
    // approximate size of destHost
    final Buffer buffer = new AutomaticBuffer(BytesUtils.SHORT_BYTE_LENGTH + PinpointConstants.APPLICATION_NAME_MAX_LEN + destHost.length() + BytesUtils.SHORT_BYTE_LENGTH);
    buffer.putShort(serviceType);
    buffer.putShort(slotNumber);
    buffer.put2PrefixedString(applicationName);
    buffer.putBytes(BytesUtils.toBytes(destHost));
    return buffer.getBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Aggregations

AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)39 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)39 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)13 ByteBuffer (java.nio.ByteBuffer)9 Test (org.junit.Test)6 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 Put (org.apache.hadoop.hbase.client.Put)2 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 EncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.strategy.EncodingStrategy)1 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)1 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)1 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)1 HistogramSlot (com.navercorp.pinpoint.common.trace.HistogramSlot)1 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)1 TIntStringStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringStringValue)1