use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class SpanBoTest method serialize_V1.
@Test
public void serialize_V1() {
final SpanBo spanBo = new SpanBo();
spanBo.setAgentId("agentId");
spanBo.setApplicationId("applicationId");
spanBo.setEndPoint("end");
spanBo.setRpc("rpc");
spanBo.setParentSpanId(5);
spanBo.setAgentStartTime(1);
TransactionId transactionId = new TransactionId("agentId", 2, 3);
spanBo.setTransactionId(transactionId);
spanBo.setElapsed(4);
spanBo.setStartTime(5);
spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
spanBo.setLoggingTransactionInfo(LoggingInfo.INFO.getCode());
spanBo.setExceptionInfo(1000, "Exception");
ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
SpanBo newSpanBo = new SpanBo();
Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
logger.debug("length:{}", i);
Assert.assertEquals(bytes.limit(), i);
Assert.assertEquals(newSpanBo.getAgentId(), spanBo.getAgentId());
Assert.assertEquals(newSpanBo.getApplicationId(), spanBo.getApplicationId());
Assert.assertEquals(newSpanBo.getAgentStartTime(), spanBo.getAgentStartTime());
Assert.assertEquals(newSpanBo.getElapsed(), spanBo.getElapsed());
Assert.assertEquals(newSpanBo.getEndPoint(), spanBo.getEndPoint());
Assert.assertEquals(newSpanBo.getErrCode(), spanBo.getErrCode());
Assert.assertEquals(newSpanBo.getFlag(), spanBo.getFlag());
// not included for serialization
// Assert.assertEquals(newSpanBo.getTraceAgentStartTime(), spanBo.getTraceAgentStartTime());
// Assert.assertEquals(newSpanBo.getTraceTransactionSequence(), spanBo.getTraceTransactionSequence());
Assert.assertEquals(newSpanBo.getParentSpanId(), spanBo.getParentSpanId());
Assert.assertEquals(newSpanBo.getServiceType(), spanBo.getServiceType());
Assert.assertEquals(newSpanBo.getApplicationServiceType(), spanBo.getServiceType());
Assert.assertEquals(newSpanBo.getVersion(), spanBo.getVersion());
Assert.assertEquals(newSpanBo.getLoggingTransactionInfo(), spanBo.getLoggingTransactionInfo());
Assert.assertEquals(newSpanBo.getExceptionId(), spanBo.getExceptionId());
Assert.assertEquals(newSpanBo.getExceptionMessage(), spanBo.getExceptionMessage());
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class SpanBoTest method serialize2_V1.
@Test
public void serialize2_V1() {
SpanBo spanBo = new SpanBo();
spanBo.setAgentId("agent");
String service = createString(5);
spanBo.setApplicationId(service);
String endPoint = createString(127);
spanBo.setEndPoint(endPoint);
String rpc = createString(255);
spanBo.setRpc(rpc);
spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
spanBo.setApplicationServiceType(ServiceType.UNKNOWN.getCode());
final ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
SpanBo newSpanBo = new SpanBo();
Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
logger.debug("length:{}", i);
Assert.assertEquals(bytes.limit(), i);
Assert.assertEquals(spanBo.getServiceType(), spanBo.getServiceType());
Assert.assertEquals(spanBo.getApplicationServiceType(), spanBo.getApplicationServiceType());
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class TransactionIdMapper method parseVarTransactionId.
public static TransactionId parseVarTransactionId(byte[] bytes, int offset, int length) {
if (bytes == null) {
throw new NullPointerException("bytes must not be null");
}
final Buffer buffer = new OffsetFixedBuffer(bytes, offset, length);
// skip elapsed time (not used) hbase column prefix - only used for filtering.
// Not sure if we can reduce the data size any further.
// buffer.readInt();
String agentId = buffer.readPrefixedString();
long agentStartTime = buffer.readSVLong();
long transactionSequence = buffer.readVLong();
return new TransactionId(agentId, agentStartTime, transactionSequence);
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class AgentStatMapperV2 method mapRow.
@Override
public List<T> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
final byte[] distributedRowKey = result.getRow();
final String agentId = this.hbaseOperationFactory.getAgentId(distributedRowKey);
final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey);
List<T> dataPoints = new ArrayList<>();
for (Cell cell : result.rawCells()) {
if (CellUtil.matchingFamily(cell, HBaseTables.AGENT_STAT_CF_STATISTICS)) {
Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer);
AgentStatDecodingContext decodingContext = new AgentStatDecodingContext();
decodingContext.setAgentId(agentId);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
List<T> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
for (T candidate : candidates) {
if (filter(candidate)) {
continue;
}
dataPoints.add(candidate);
}
}
}
// Reverse sort as timestamp is stored in a reversed order.
Collections.sort(dataPoints, REVERSE_TIMESTAMP_COMPARATOR);
return dataPoints;
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class SpanMapperV2 method mapRow.
@Override
public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
byte[] rowKey = result.getRow();
final TransactionId transactionId = this.rowKeyDecoder.decodeRowKey(rowKey);
final Cell[] rawCells = result.rawCells();
ListMultimap<AgentKey, SpanBo> spanMap = LinkedListMultimap.create();
List<SpanChunkBo> spanChunkList = new ArrayList<>();
final SpanDecodingContext decodingContext = new SpanDecodingContext();
decodingContext.setTransactionId(transactionId);
for (Cell cell : rawCells) {
SpanDecoder spanDecoder = null;
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HBaseTables.TRACE_V2_CF_SPAN)) {
decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Buffer columnValue = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
spanDecoder = resolveDecoder(columnValue);
final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
if (decodeObject instanceof SpanBo) {
SpanBo spanBo = (SpanBo) decodeObject;
if (logger.isDebugEnabled()) {
logger.debug("spanBo:{}", spanBo);
}
AgentKey agentKey = newAgentKey(spanBo);
spanMap.put(agentKey, spanBo);
} else if (decodeObject instanceof SpanChunkBo) {
SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
if (logger.isDebugEnabled()) {
logger.debug("spanChunkBo:{}", spanChunkBo);
}
spanChunkList.add(spanChunkBo);
}
} else {
logger.warn("Unknown ColumnFamily :{}", Bytes.toStringBinary(CellUtil.cloneFamily(cell)));
}
nextCell(spanDecoder, decodingContext);
}
decodingContext.finish();
return buildSpanBoList(spanMap, spanChunkList);
}
Aggregations