use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class ResponseTimeMapperTest method testResponseTimeMapperTest.
@Test
public void testResponseTimeMapperTest() throws Exception {
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();
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.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);
}
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class HbaseHostApplicationMapDao method createColumnName.
private byte[] createColumnName(String host, String bindApplicationName, short bindServiceType) {
Buffer buffer = new AutomaticBuffer();
buffer.putPrefixedString(host);
buffer.putPrefixedString(bindApplicationName);
buffer.putShort(bindServiceType);
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class HbaseHostApplicationMapDao method createRowKey0.
byte[] createRowKey0(String parentApplicationName, short parentServiceType, long statisticsRowSlot, String parentAgentId) {
// even if a agentId be added for additional specifications, it may be safe to scan rows.
// But is it needed to add parentAgentServiceType?
final int SIZE = HBaseTables.APPLICATION_NAME_MAX_LEN + 2 + 8;
final Buffer rowKeyBuffer = new AutomaticBuffer(SIZE);
rowKeyBuffer.putPadString(parentApplicationName, HBaseTables.APPLICATION_NAME_MAX_LEN);
rowKeyBuffer.putShort(parentServiceType);
rowKeyBuffer.putLong(TimeUtils.reverseTimeMillis(statisticsRowSlot));
// rowKeyBuffer.putPadString(parentAgentId, HBaseTables.AGENT_NAME_MAX_LEN);
return rowKeyBuffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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);
}
Aggregations