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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations