use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class ResponseTimeMapper method createResponseTime.
private ResponseTime createResponseTime(byte[] rowKey) {
final Buffer row = new FixedBuffer(rowKey);
String applicationName = row.read2PrefixedString();
short serviceTypeCode = row.readShort();
final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
ServiceType serviceType = registry.findServiceType(serviceTypeCode);
return new ResponseTime(applicationName, serviceType, timestamp);
}
use of com.navercorp.pinpoint.common.buffer.Buffer 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.buffer.Buffer 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);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class ApplicationStatMapper method mapRow.
@Override
public List<JoinStatBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
final byte[] distributedRowKey = result.getRow();
final String applicationId = this.hbaseOperationFactory.getApplicationId(distributedRowKey);
final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey);
List<JoinStatBo> dataPoints = new ArrayList<>();
for (Cell cell : result.rawCells()) {
if (CellUtil.matchingFamily(cell, HbaseColumnFamily.APPLICATION_STAT_STATISTICS.getName())) {
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);
ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
decodingContext.setApplicationId(applicationId);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
List<JoinStatBo> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
for (JoinStatBo candidate : candidates) {
long timestamp = candidate.getTimestamp();
if (this.filter.filter(timestamp)) {
continue;
}
dataPoints.add(candidate);
}
}
}
// Reverse sort as timestamp is stored in a reversed order.
dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR);
return dataPoints;
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class ApiMetaDataMapper method mapRow.
@Override
public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
final byte[] rowKey = getOriginalKey(result.getRow());
final MetaDataRowKey key = decoder.decodeRowKey(rowKey);
List<ApiMetaDataBo> apiMetaDataList = new ArrayList<>();
for (Cell cell : result.rawCells()) {
final byte[] value = getValue(cell);
Buffer buffer = new FixedBuffer(value);
final String apiInfo = buffer.readPrefixedString();
final int lineNumber = buffer.readInt();
MethodTypeEnum methodTypeEnum = MethodTypeEnum.DEFAULT;
if (buffer.hasRemaining()) {
methodTypeEnum = MethodTypeEnum.valueOf(buffer.readInt());
}
ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(key.getAgentId(), key.getAgentStartTime(), key.getId(), lineNumber, methodTypeEnum, apiInfo);
apiMetaDataList.add(apiMetaDataBo);
if (logger.isDebugEnabled()) {
logger.debug("read apiAnnotation:{}", apiMetaDataBo);
}
}
return apiMetaDataList;
}
Aggregations