use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class AnnotationBoDecoderTest method testWriteValue.
@Test
public void testWriteValue() throws Exception {
final AnnotationBo annotation = new AnnotationBo();
annotation.setKey(AnnotationKey.API.getCode());
final String value = RandomStringUtils.random(RandomUtils.nextInt(0, 20));
annotation.setValue(value);
final Buffer buffer = new AutomaticBuffer(128);
this.serializer.writeAnnotationList(Lists.newArrayList(annotation), buffer);
buffer.setOffset(0);
List<AnnotationBo> decode = annotationBoDecoder.decode(buffer);
Assert.assertEquals(decode.size(), 1);
AnnotationBo decodedAnnotation = decode.get(0);
Assert.assertEquals(annotation.getKey(), decodedAnnotation.getKey());
Assert.assertEquals(annotation.getValue(), decodedAnnotation.getValue());
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class TransactionIdUtils method writeTransactionId.
private static Buffer writeTransactionId(String agentId, long agentStartTime, long transactionSequence) {
// agentId may be null
// version + prefixed size + string + long + long
final Buffer buffer = new AutomaticBuffer(1 + 5 + 24 + 10 + 10);
buffer.putByte(VERSION);
buffer.putPrefixedString(agentId);
buffer.putVLong(agentStartTime);
buffer.putVLong(transactionSequence);
return buffer;
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class AnnotationTranscoder method encodeIntStringValue.
private byte[] encodeIntStringValue(Object value) {
final TIntStringValue tIntStringValue = (TIntStringValue) 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();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class AnnotationTranscoder method encodeIntStringStringValue.
private byte[] encodeIntStringStringValue(Object o) {
final TIntStringStringValue tIntStringStringValue = (TIntStringStringValue) o;
final int intValue = tIntStringStringValue.getIntValue();
final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
// TODO increase by a more precise value
final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
final Buffer buffer = new AutomaticBuffer(bufferSize);
buffer.putSVInt(intValue);
buffer.putPrefixedBytes(stringValue1);
buffer.putPrefixedBytes(stringValue2);
return buffer.getBuffer();
}
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);
}
}
Aggregations