use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class TraceIndexScatterMapper2 method createDot.
private Dot createDot(Cell cell) {
final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
int elapsed = valueBuffer.readVInt();
if (elapsed < responseOffsetFrom || elapsed > responseOffsetTo) {
return null;
}
int exceptionCode = valueBuffer.readSVInt();
String agentId = valueBuffer.readPrefixedString();
long reverseAcceptedTime = BytesUtils.bytesToLong(cell.getRowArray(), cell.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
long acceptedTime = TimeUtils.recoveryTimeMillis(reverseAcceptedTime);
final int qualifierOffset = cell.getQualifierOffset();
// TransactionId transactionId = new TransactionId(buffer,
// qualifierOffset);
// for temporary, used TransactionIdMapper
TransactionId transactionId = TransactionIdMapper.parseVarTransactionId(cell.getQualifierArray(), qualifierOffset, cell.getQualifierLength());
return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class TraceIndexScatterMapper3 method createDot.
private Dot createDot(Cell cell) {
final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
int elapsed = valueBuffer.readVInt();
int exceptionCode = valueBuffer.readSVInt();
String agentId = valueBuffer.readPrefixedString();
long reverseAcceptedTime = BytesUtils.bytesToLong(cell.getRowArray(), cell.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
long acceptedTime = TimeUtils.recoveryTimeMillis(reverseAcceptedTime);
// TransactionId transactionId = new TransactionId(buffer,
// qualifierOffset);
// for temporary, used TransactionIdMapper
TransactionId transactionId = TransactionIdMapper.parseVarTransactionId(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class MapStatisticsCallerMapper method mapRow.
@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return new LinkDataMap();
}
logger.debug("mapRow:{}", rowNum);
final byte[] rowKey = getOriginalKey(result.getRow());
final Buffer row = new FixedBuffer(rowKey);
final Application caller = readCallerApplication(row);
final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
// key is destApplicationName.
final LinkDataMap linkDataMap = new LinkDataMap();
for (Cell cell : result.rawCells()) {
final Buffer buffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Application callee = readCalleeApplication(buffer);
if (filter.filter(callee)) {
continue;
}
String calleeHost = buffer.readPrefixedString();
short histogramSlot = buffer.readShort();
boolean isError = histogramSlot == (short) -1;
String callerAgentId = buffer.readPrefixedString();
long requestCount = getValueToLong(cell);
if (logger.isDebugEnabled()) {
logger.debug(" Fetched Caller.(New) {} {} -> {} (slot:{}/{}) calleeHost:{}", caller, callerAgentId, callee, histogramSlot, requestCount, calleeHost);
}
final short slotTime = (isError) ? (short) -1 : histogramSlot;
if (StringUtils.isEmpty(calleeHost)) {
calleeHost = callee.getName();
}
linkDataMap.addLinkData(caller, callerAgentId, callee, calleeHost, timestamp, slotTime, requestCount);
}
return linkDataMap;
}
use of com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer in project pinpoint by naver.
the class SpanMapper 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();
Map<AgentKey, SpanBo> spanMap = new LinkedHashMap<>();
ListMultimap<AgentKey, SpanEventBo> spanEventBoListMap = ArrayListMultimap.create();
ListMultimap<Long, AnnotationBo> annotationBoListMap = ArrayListMultimap.create();
final SpanDecodingContext decodingContext = new SpanDecodingContext();
decodingContext.setTransactionId(transactionId);
for (Cell cell : rawCells) {
decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_SPAN)) {
Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
final SpanBo spanBo = spanDecoder.decodeSpanBo(qualifierBuffer, valueBuffer, decodingContext);
AgentKey agentKey = newAgentKey(spanBo);
spanMap.put(agentKey, spanBo);
} else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_TERMINALSPAN)) {
final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
SpanEventBo spanEventBo = spanDecoder.decodeSpanEventBo(qualifier, valueBuffer, decodingContext);
AgentKey agentKey = newAgentKey(decodingContext);
spanEventBoListMap.put(agentKey, spanEventBo);
} else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_ANNOTATION)) {
final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
List<AnnotationBo> annotationBoList = annotationBoDecoder.decode(qualifier, valueBuffer, decodingContext);
if (CollectionUtils.isNotEmpty(annotationBoList)) {
long spanId = decodingContext.getSpanId();
annotationBoListMap.putAll(spanId, annotationBoList);
}
}
spanDecoder.next(decodingContext);
}
decodingContext.finish();
for (Map.Entry<AgentKey, SpanEventBo> spanBoEntry : spanEventBoListMap.entries()) {
final AgentKey agentKey = spanBoEntry.getKey();
SpanBo spanBo = spanMap.get(agentKey);
if (spanBo != null) {
SpanEventBo value = spanBoEntry.getValue();
spanBo.addSpanEvent(value);
} else {
if (logger.isInfoEnabled()) {
logger.info("Span not exist spanId:{} spanEvent:{}", spanBoEntry.getKey(), spanBoEntry.getValue());
}
}
}
List<SpanBo> spanList = Lists.newArrayList(spanMap.values());
if (!annotationBoListMap.isEmpty()) {
addAnnotation(spanList, annotationBoListMap);
}
return spanList;
}
Aggregations