Search in sources :

Example 6 with OffsetFixedBuffer

use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer 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(HBaseTables.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 7 with OffsetFixedBuffer

use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer 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(Lists.<AnnotationBo>newArrayList(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, new SpanEventBo(), 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 8 with OffsetFixedBuffer

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

the class HbaseApplicationTraceIndexColumnTest method indexedColumnName.

@Test
public void indexedColumnName() {
    final int elapsed = 1234;
    final String agentId = "agentId";
    final long agentStartTime = 1234567890L;
    final long transactionSequence = 1234567890L;
    // final Buffer buffer= new AutomaticBuffer(32);
    // buffer.putPrefixedString(agentId);
    // buffer.putSVar(transactionId.getAgentStartTime());
    // buffer.putVar(transactionId.getTransactionSequence());
    // return buffer.getBuffer();
    final Buffer originalBuffer = new AutomaticBuffer(16);
    originalBuffer.putVInt(elapsed);
    originalBuffer.putPrefixedString(agentId);
    originalBuffer.putSVLong(agentStartTime);
    originalBuffer.putVLong(transactionSequence);
    byte[] source = originalBuffer.getBuffer();
    final Buffer fetched = new OffsetFixedBuffer(source);
    Assert.assertEquals(elapsed, fetched.readVInt());
    Assert.assertEquals(agentId, fetched.readPrefixedString());
    Assert.assertEquals(agentStartTime, fetched.readSVLong());
    Assert.assertEquals(transactionSequence, fetched.readVLong());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Test(org.junit.Test)

Example 9 with OffsetFixedBuffer

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

the class SpanEventBoTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    SpanBo spanBo = new SpanBo();
    spanBo.setAgentId("testAgent");
    spanBo.setApplicationId("testApp");
    spanBo.setAgentStartTime(1);
    spanBo.setSpanId(12);
    SpanEventBo spanEventBo = new SpanEventBo();
    spanEventBo.setDepth(3);
    spanEventBo.setDestinationId("testdest");
    spanEventBo.setEndElapsed(2);
    spanEventBo.setEndPoint("endpoint");
    spanEventBo.setNextSpanId(4);
    spanEventBo.setRpc("rpc");
    spanEventBo.setServiceType(ServiceType.STAND_ALONE.getCode());
    spanEventBo.setStartElapsed(100);
    spanEventBo.setNextAsyncId(1000);
    SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(spanBo, spanEventBo);
    ByteBuffer bytes = serializer.writeValue(spanEventEncodingContext);
    SpanEventBo newSpanEventBo = new SpanEventBo();
    SpanDecodingContext spanDecodingContext = new SpanDecodingContext();
    Buffer buffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
    int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer, spanDecodingContext);
    Assert.assertEquals(bytes.limit(), i);
    Assert.assertEquals(spanBo.getAgentId(), spanDecodingContext.getAgentId());
    Assert.assertEquals(spanBo.getApplicationId(), spanDecodingContext.getApplicationId());
    Assert.assertEquals(spanBo.getAgentStartTime(), spanDecodingContext.getAgentStartTime());
    Assert.assertEquals(spanEventBo.getDepth(), newSpanEventBo.getDepth());
    Assert.assertEquals(spanEventBo.getDestinationId(), newSpanEventBo.getDestinationId());
    Assert.assertEquals(spanEventBo.getEndElapsed(), newSpanEventBo.getEndElapsed());
    Assert.assertEquals(spanEventBo.getEndPoint(), newSpanEventBo.getEndPoint());
    Assert.assertEquals(spanEventBo.getNextSpanId(), newSpanEventBo.getNextSpanId());
    Assert.assertEquals(spanEventBo.getRpc(), newSpanEventBo.getRpc());
    Assert.assertEquals(spanEventBo.getServiceType(), newSpanEventBo.getServiceType());
    Assert.assertEquals(spanEventBo.getStartElapsed(), newSpanEventBo.getStartElapsed());
    Assert.assertEquals(spanEventBo.getNextAsyncId(), newSpanEventBo.getNextAsyncId());
    spanEventBo.setSequence((short) 3);
    newSpanEventBo.setSequence((short) 3);
    Assert.assertEquals(spanEventBo.getSequence(), newSpanEventBo.getSequence());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) 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 10 with OffsetFixedBuffer

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

the class TraceIndexScatterMapper method createDot.

private Dot createDot(Cell cell) {
    final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
    int elapsed = valueBuffer.readVInt();
    int exceptionCode = valueBuffer.readSVInt();
    String agentId = valueBuffer.readPrefixedString();
    long reverseAcceptedTime = BytesUtils.bytesToLong(cell.getRowArray(), cell.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
    long acceptedTime = TimeUtils.recoveryTimeMillis(reverseAcceptedTime);
    final int qualifierOffset = cell.getQualifierOffset();
    TransactionId transactionId = TransactionIdMapper.parseVarTransactionId(cell.getQualifierArray(), qualifierOffset, cell.getQualifierLength());
    return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Dot(com.navercorp.pinpoint.web.vo.scatter.Dot) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)14 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)14 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)7 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)6 Test (org.junit.Test)5 ByteBuffer (java.nio.ByteBuffer)4 Cell (org.apache.hadoop.hbase.Cell)4 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)3 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)3 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)2 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)2 Application (com.navercorp.pinpoint.web.vo.Application)2 ArrayList (java.util.ArrayList)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext)1 SpanDecoder (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecoder)1 SpanEncoder (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanEncoder)1