use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.
the class TransactionIdComparatorTest method order.
@Test
public void order() {
List<Integer> numbers = new ArrayList<>(10);
for (int i = 0; i < 10; i++) {
numbers.add(i);
}
Collections.shuffle(numbers);
List<TransactionId> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(new TransactionId("A", 1, numbers.get(i)));
}
logger.debug("{}", list);
Collections.sort(list, comparator);
int i = 0;
for (TransactionId transactionId : list) {
Assert.assertEquals(i, transactionId.getTransactionSequence());
i++;
}
logger.debug("{}", list);
}
use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.
the class TransactionIdComparatorTest method diffSeqAsc.
@Test
public void diffSeqAsc() {
TransactionId id1 = new TransactionId("A1", 1, 1);
TransactionId id2 = new TransactionId("A1", 1, 2);
Assert.assertEquals(-1, comparator.compare(id1, id2));
}
use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.
the class TransactionIdComparatorTest method diffSeqDesc.
@Test
public void diffSeqDesc() {
TransactionId id1 = new TransactionId("A1", 1, 2);
TransactionId id2 = new TransactionId("A1", 1, 1);
Assert.assertEquals(1, comparator.compare(id1, id2));
}
use of com.navercorp.pinpoint.common.profiler.util.TransactionId 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);
final BufferFactory bufferFactory = new BufferFactory(cacheSize);
for (Cell cell : rawCells) {
SpanDecoder spanDecoder = null;
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HbaseColumnFamily.TRACE_V2_SPAN.getName())) {
decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
final Buffer qualifier = bufferFactory.createBuffer(CellUtil.cloneQualifier(cell));
final Buffer columnValue = bufferFactory.createBuffer(CellUtil.cloneValue(cell));
spanDecoder = resolveDecoder(columnValue);
final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
if (decodeObject instanceof SpanBo) {
SpanBo spanBo = (SpanBo) decodeObject;
if (logger.isTraceEnabled()) {
logger.trace("spanBo:{}", spanBo);
}
AgentKey agentKey = newAgentKey(spanBo);
spanMap.put(agentKey, spanBo);
} else if (decodeObject instanceof SpanChunkBo) {
SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
if (logger.isTraceEnabled()) {
logger.trace("spanChunkBo:{}", spanChunkBo);
}
spanChunkList.add(spanChunkBo);
}
} else {
if (logger.isWarnEnabled()) {
String columnFamily = Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
logger.warn("Unknown ColumnFamily :{}", columnFamily);
}
}
nextCell(spanDecoder, decodingContext);
}
decodingContext.finish();
return buildSpanBoList(spanMap, spanChunkList);
}
use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.
the class TransactionIdMapper method parseVarTransactionId.
public static TransactionId parseVarTransactionId(byte[] bytes, int offset, int length) {
Objects.requireNonNull(bytes, "bytes");
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);
}
Aggregations