Search in sources :

Example 16 with AutomaticBuffer

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

the class ResponseTimeMapperTest method testResponseTimeMapperTest.

@Test
public void testResponseTimeMapperTest() throws Exception {
    Buffer buffer = new AutomaticBuffer();
    HistogramSlot histogramSlot = ServiceType.STAND_ALONE.getHistogramSchema().findHistogramSlot(1000, false);
    short histogramSlotTime = histogramSlot.getSlotTime();
    buffer.putShort(histogramSlotTime);
    buffer.putBytes(Bytes.toBytes("agent"));
    byte[] bufferArray = buffer.getBuffer();
    byte[] valueArray = Bytes.toBytes(1L);
    Cell mockCell = CellUtil.createCell(HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, bufferArray, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum.getCode(), valueArray);
    ResponseTimeMapper responseTimeMapper = new ResponseTimeMapper();
    ResponseTime responseTime = new ResponseTime("applicationName", ServiceType.STAND_ALONE, System.currentTimeMillis());
    responseTimeMapper.recordColumn(responseTime, mockCell);
    Histogram agentHistogram = responseTime.findHistogram("agent");
    long fastCount = agentHistogram.getFastCount();
    Assert.assertEquals(fastCount, 1);
    long normal = agentHistogram.getNormalCount();
    Assert.assertEquals(normal, 0);
    long slow = agentHistogram.getSlowCount();
    Assert.assertEquals(slow, 0);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) HistogramSlot(com.navercorp.pinpoint.common.trace.HistogramSlot) Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ResponseTime(com.navercorp.pinpoint.web.vo.ResponseTime) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 17 with AutomaticBuffer

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

the class HbaseApplicationTraceIndexDao method insert.

@Override
public void insert(final TSpan span) {
    if (span == null) {
        throw new NullPointerException("span must not be null");
    }
    final Buffer buffer = new AutomaticBuffer(10 + AGENT_NAME_MAX_LEN);
    buffer.putVInt(span.getElapsed());
    buffer.putSVInt(span.getErr());
    buffer.putPrefixedString(span.getAgentId());
    final byte[] value = buffer.getBuffer();
    long acceptedTime = acceptedTimeService.getAcceptedTime();
    final byte[] distributedKey = createRowKey(span, acceptedTime);
    Put put = new Put(distributedKey);
    put.addColumn(APPLICATION_TRACE_INDEX_CF_TRACE, makeQualifier(span), acceptedTime, value);
    boolean success = hbaseTemplate.asyncPut(APPLICATION_TRACE_INDEX, put);
    if (!success) {
        hbaseTemplate.put(APPLICATION_TRACE_INDEX, put);
    }
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Put(org.apache.hadoop.hbase.client.Put)

Example 18 with AutomaticBuffer

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

the class HbaseHostApplicationMapDao method createColumnName.

private byte[] createColumnName(String host, String bindApplicationName, short bindServiceType) {
    Buffer buffer = new AutomaticBuffer();
    buffer.putPrefixedString(host);
    buffer.putPrefixedString(bindApplicationName);
    buffer.putShort(bindServiceType);
    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 19 with AutomaticBuffer

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

the class HbaseHostApplicationMapDao method createRowKey0.

byte[] createRowKey0(String parentApplicationName, short parentServiceType, long statisticsRowSlot, String parentAgentId) {
    // even if  a agentId be added for additional specifications, it may be safe to scan rows.
    // But is it needed to add parentAgentServiceType?
    final int SIZE = HBaseTables.APPLICATION_NAME_MAX_LEN + 2 + 8;
    final Buffer rowKeyBuffer = new AutomaticBuffer(SIZE);
    rowKeyBuffer.putPadString(parentApplicationName, HBaseTables.APPLICATION_NAME_MAX_LEN);
    rowKeyBuffer.putShort(parentServiceType);
    rowKeyBuffer.putLong(TimeUtils.reverseTimeMillis(statisticsRowSlot));
    //        rowKeyBuffer.putPadString(parentAgentId, HBaseTables.AGENT_NAME_MAX_LEN);
    return rowKeyBuffer.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 20 with AutomaticBuffer

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

the class HbaseApiMetaDataDao method insert.

@Override
public void insert(TApiMetaData apiMetaData) {
    if (logger.isDebugEnabled()) {
        logger.debug("insert:{}", apiMetaData);
    }
    ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(apiMetaData.getAgentId(), apiMetaData.getAgentStartTime(), apiMetaData.getApiId());
    byte[] rowKey = getDistributedKey(apiMetaDataBo.toRowKey());
    final Put put = new Put(rowKey);
    final Buffer buffer = new AutomaticBuffer(64);
    String api = apiMetaData.getApiInfo();
    buffer.putPrefixedString(api);
    if (apiMetaData.isSetLine()) {
        buffer.putInt(apiMetaData.getLine());
    } else {
        buffer.putInt(-1);
    }
    if (apiMetaData.isSetType()) {
        buffer.putInt(apiMetaData.getType());
    } else {
        buffer.putInt(0);
    }
    final byte[] apiMetaDataBytes = buffer.getBuffer();
    put.addColumn(HBaseTables.API_METADATA_CF_API, HBaseTables.API_METADATA_CF_API_QUALI_SIGNATURE, apiMetaDataBytes);
    hbaseTemplate.put(HBaseTables.API_METADATA, put);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) Put(org.apache.hadoop.hbase.client.Put)

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