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