Search in sources :

Example 41 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 42 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 43 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)

Example 44 with AutomaticBuffer

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

the class AnnotationTranscoder method encodeIntStringValue.

private byte[] encodeIntStringValue(Object value) {
    final IntStringValue tIntStringValue = (IntStringValue) value;
    final int intValue = tIntStringValue.getIntValue();
    final byte[] stringValue = BytesUtils.toBytes(tIntStringValue.getStringValue());
    // TODO increase by a more precise value
    final int bufferSize = getBufferSize(stringValue, 4 + 8);
    final Buffer buffer = new AutomaticBuffer(bufferSize);
    buffer.putSVInt(intValue);
    buffer.putPrefixedBytes(stringValue);
    return buffer.getBuffer();
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 45 with AutomaticBuffer

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

the class AnnotationTranscoder method encodeStringStringValue.

private byte[] encodeStringStringValue(Object o) {
    final StringStringValue tStringStringValue = (StringStringValue) o;
    final byte[] stringValue1 = BytesUtils.toBytes(tStringStringValue.getStringValue1());
    final byte[] stringValue2 = BytesUtils.toBytes(tStringStringValue.getStringValue2());
    // TODO increase by a more precise value
    final int bufferSize = getBufferSize(stringValue1, stringValue2);
    final Buffer buffer = new AutomaticBuffer(bufferSize);
    buffer.putPrefixedBytes(stringValue1);
    buffer.putPrefixedBytes(stringValue2);
    return buffer.getBuffer();
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Aggregations

AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)68 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)68 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)30 Test (org.junit.Test)16 ByteBuffer (java.nio.ByteBuffer)15 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)10 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Put (org.apache.hadoop.hbase.client.Put)4 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)2 TableName (org.apache.hadoop.hbase.TableName)2 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1