use of com.navercorp.pinpoint.common.util.TransactionId 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.util.TransactionId in project pinpoint by naver.
the class HbaseTraceDaoV2 method select0.
private List<List<SpanBo>> select0(List<TransactionId> transactionIdList, byte[] columnFamily, Filter filter) {
if (CollectionUtils.isEmpty(transactionIdList)) {
return Collections.emptyList();
}
final List<Get> multiGet = new ArrayList<>(transactionIdList.size());
for (TransactionId transactionId : transactionIdList) {
final Get get = createGet(transactionId, columnFamily, filter);
multiGet.add(get);
}
return template2.get(HBaseTables.TRACE_V2, multiGet, spanMapperV2);
}
use of com.navercorp.pinpoint.common.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);
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);
}
use of com.navercorp.pinpoint.common.util.TransactionId in project pinpoint by naver.
the class ScatterDataTest method createDotList.
private List<Dot> createDotList(String agentId, String transactionAgentId, int createSize, long from) {
long currentTime = System.currentTimeMillis();
List<TransactionId> transactionIdList = new ArrayList<>(createSize);
for (int i = 0; i < createSize; i++) {
transactionIdList.add(new TransactionId(transactionAgentId, currentTime, i));
}
long acceptedTime = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
int executionTime = (int) Math.abs(ThreadLocalRandom.current().nextLong(60 * 1000));
List<Dot> dotList = new ArrayList<>(createSize);
for (int i = 0; i < createSize; i++) {
int exceptionCode = ThreadLocalRandom.current().nextInt(0, 2);
dotList.add(new Dot(transactionIdList.get(i), Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from), executionTime, exceptionCode, agentId));
}
long seed = System.nanoTime();
Collections.shuffle(dotList, new Random(seed));
return dotList;
}
use of com.navercorp.pinpoint.common.util.TransactionId in project pinpoint by naver.
the class ScatterDataTest method addDotTest2.
@Test
public void addDotTest2() throws Exception {
long from = 1000;
long to = 10000;
int xGroupUnit = 100;
int yGroupUnit = 100;
ScatterData scatterData = new ScatterData(from, to, xGroupUnit, yGroupUnit);
long currentTime = System.currentTimeMillis();
TransactionId transactionId1 = new TransactionId(transactionAgentId, currentTime, 1);
TransactionId transactionId2 = new TransactionId(transactionAgentId, currentTime, 2);
long acceptedTime = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
int executionTime = (int) Math.abs(ThreadLocalRandom.current().nextLong(60 * 1000));
long acceptedTime2 = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
Dot dot1 = new Dot(transactionId1, acceptedTime2, executionTime, 0, agentId);
Dot dot2 = new Dot(transactionId2, acceptedTime2, executionTime, 1, agentId);
scatterData.addDot(dot1);
scatterData.addDot(dot2);
Map<Long, DotGroups> scatterDataMap = scatterData.getScatterDataMap();
Collection<DotGroups> values = scatterDataMap.values();
Assert.assertTrue(values.size() == 1);
for (DotGroups dotGroups : values) {
Map<Dot, DotGroup> dotGroupLeaders = dotGroups.getDotGroupLeaders();
Assert.assertTrue(dotGroupLeaders.keySet().size() == 2);
}
}
Aggregations