Search in sources :

Example 51 with Buffer

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

the class HostApplicationMapperVer2 method createAcceptedApplication.

// private void readRowKey(byte[] rowKey) {
// final Buffer rowKeyBuffer= new FixedBuffer(rowKey);
// final String parentApplicationName = rowKeyBuffer.readPadStringAndRightTrim(HBaseTableConstants.APPLICATION_NAME_MAX_LEN);
// final short parentApplicationServiceType = rowKeyBuffer.readShort();
// final long timeSlot = TimeUtils.recoveryTimeMillis(rowKeyBuffer.readLong());
// 
// if (logger.isDebugEnabled()) {
// logger.debug("parentApplicationName:{}/{} time:{}", parentApplicationName, parentApplicationServiceType, timeSlot);
// }
// }
private AcceptApplication createAcceptedApplication(Cell cell) {
    Buffer reader = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
    String host = reader.readPrefixedString();
    String bindApplicationName = reader.readPrefixedString();
    short bindServiceTypeCode = reader.readShort();
    final Application bindApplication = applicationFactory.createApplication(bindApplicationName, bindServiceTypeCode);
    return new AcceptApplication(host, bindApplication);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication)

Example 52 with Buffer

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

the class SpanMapperV2Test method test.

@Test
public void test() {
    SpanBo span = new SpanBo();
    span.setServiceType((short) 1000);
    span.setExceptionInfo(1, "spanException");
    SpanEventBo firstSpanEventBo = new SpanEventBo();
    firstSpanEventBo.setExceptionInfo(2, "first");
    firstSpanEventBo.setEndElapsed(100);
    AnnotationBo annotationBo = newAnnotation(200, "annotation");
    firstSpanEventBo.setAnnotationBoList(Collections.singletonList(annotationBo));
    firstSpanEventBo.setServiceType((short) 1003);
    firstSpanEventBo.setSequence((short) 0);
    span.addSpanEvent(firstSpanEventBo);
    // // next
    SpanEventBo nextSpanEventBo = new SpanEventBo();
    nextSpanEventBo.setEndElapsed(200);
    nextSpanEventBo.setServiceType((short) 2003);
    nextSpanEventBo.setSequence((short) 1);
    span.addSpanEvent(nextSpanEventBo);
    SpanEncodingContext<SpanBo> encodingContext = new SpanEncodingContext<>(span);
    SpanEncoder encoder = new SpanEncoderV0();
    ByteBuffer byteBuffer = encoder.encodeSpanColumnValue(encodingContext);
    Buffer buffer = new OffsetFixedBuffer(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.remaining());
    SpanBo readSpan = new SpanBo();
    SpanDecodingContext decodingContext = new SpanDecodingContext();
    decoder.readSpanValue(buffer, readSpan, decodingContext);
    Assert.assertEquals(readSpan.getSpanEventBoList().size(), 2);
    // span
    Assert.assertEquals(readSpan.getServiceType(), 1000);
    Assert.assertEquals(readSpan.hasException(), true);
    Assert.assertEquals(readSpan.getExceptionId(), 1);
    Assert.assertEquals(readSpan.getExceptionMessage(), "spanException");
    List<SpanEventBo> spanEventBoList = readSpan.getSpanEventBoList();
    SpanEventBo readFirst = spanEventBoList.get(0);
    SpanEventBo readNext = spanEventBoList.get(1);
    Assert.assertEquals(readFirst.getEndElapsed(), 100);
    Assert.assertEquals(readNext.getEndElapsed(), 200);
    Assert.assertEquals(readFirst.getExceptionId(), 2);
    Assert.assertEquals(readNext.hasException(), false);
    Assert.assertEquals(readFirst.getServiceType(), 1003);
    Assert.assertEquals(readNext.getServiceType(), 2003);
    Assert.assertEquals(readFirst.getSequence(), 0);
    Assert.assertEquals(readNext.getSequence(), 1);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanEncodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncodingContext) SpanDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext) SpanEncoder(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoder) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanEncoderV0(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoderV0) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ByteBuffer(java.nio.ByteBuffer) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 53 with Buffer

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

the class ResponseTimeMapperTest method testResponseTimeMapperTest.

@Test
public void testResponseTimeMapperTest() {
    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(mock(ServiceTypeRegistryService.class), mock(RowKeyDistributorByHashPrefix.class));
    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) ServiceTypeRegistryService(com.navercorp.pinpoint.loader.service.ServiceTypeRegistryService) RowKeyDistributorByHashPrefix(com.sematext.hbase.wd.RowKeyDistributorByHashPrefix) 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 54 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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)

Example 55 with Buffer

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

the class SpanEventSerializer method writeQualifier.

private ByteBuffer writeQualifier(SpanEventEncodingContext spanEventEncodingContext) {
    SpanEventBo spanEventBo = spanEventEncodingContext.getSpanEventBo();
    BasicSpan basicSpan = spanEventEncodingContext.getBasicSpan();
    final Buffer rowId = new AutomaticBuffer();
    rowId.putLong(basicSpan.getSpanId());
    rowId.putShort(spanEventBo.getSequence());
    rowId.putInt(spanEventBo.getAsyncId());
    rowId.putShort(spanEventBo.getAsyncSequence());
    return rowId.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) BasicSpan(com.navercorp.pinpoint.common.server.bo.BasicSpan) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)107 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)76 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)57 ByteBuffer (java.nio.ByteBuffer)27 Test (org.junit.Test)24 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)15 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)11 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)11 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)9 Cell (org.apache.hadoop.hbase.Cell)9 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)8 ArrayList (java.util.ArrayList)6 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)4 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)4 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)4 Put (org.apache.hadoop.hbase.client.Put)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)3