use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class HbaseApplicationTraceIndexDao method insert.
@Override
public void insert(final SpanBo span) {
Objects.requireNonNull(span, "span");
if (logger.isDebugEnabled()) {
logger.debug("insert ApplicationTraceIndex: {}", span);
}
// Assert agentId
CollectorUtils.checkAgentId(span.getAgentId());
// Assert applicationName
CollectorUtils.checkApplicationName(span.getApplicationId());
final Buffer buffer = new AutomaticBuffer(10 + HbaseTableConstants.AGENT_ID_MAX_LEN);
buffer.putVInt(span.getElapsed());
buffer.putSVInt(span.getErrCode());
buffer.putPrefixedString(span.getAgentId());
final byte[] value = buffer.getBuffer();
final long acceptedTime = acceptedTimeService.getAcceptedTime();
final byte[] distributedKey = createRowKey(span, acceptedTime);
final Put put = new Put(distributedKey);
put.addColumn(DESCRIPTOR.getName(), makeQualifier(span), acceptedTime, value);
final TableName applicationTraceIndexTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
hbaseTemplate.asyncPut(applicationTraceIndexTableName, put);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanEncoderTest method assertSpan.
private void assertSpan(SpanBo spanBo) {
spanBo.setCollectorAcceptTime(getCollectorAcceptTime());
SpanEncodingContext<SpanBo> encodingContext = new SpanEncodingContext<>(spanBo);
Buffer qualifier = wrapBuffer(spanEncoder.encodeSpanQualifier(encodingContext));
Buffer column = wrapBuffer(spanEncoder.encodeSpanColumnValue(encodingContext));
SpanDecodingContext decodingContext = new SpanDecodingContext();
decodingContext.setTransactionId(spanBo.getTransactionId());
decodingContext.setCollectorAcceptedTime(spanBo.getCollectorAcceptTime());
SpanBo decode = (SpanBo) spanDecoder.decode(qualifier, column, decodingContext);
// TODO Check CI log
// logger.debug("span dump \noriginal spanBo:{} \ndecode spanBo:{} ", spanBo, decode);
List<String> notSerializedField = newArrayList("parentApplicationId", "parentApplicationServiceType");
List<String> excludeField = newArrayList("annotationBoList", "spanEventBoList");
notSerializedField.addAll(excludeField);
Assert.assertTrue(EqualsBuilder.reflectionEquals(decode, spanBo, notSerializedField));
logger.debug("{} {}", spanBo.getAnnotationBoList(), decode.getAnnotationBoList());
Assert.assertTrue("annotation", EqualsBuilder.reflectionEquals(spanBo.getAnnotationBoList(), decode.getAnnotationBoList()));
List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
List<SpanEventBo> decodedSpanEventBoList = decode.getSpanEventBoList();
Assert.assertTrue(EqualsBuilder.reflectionEquals(spanEventBoList, decodedSpanEventBoList));
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class EncodingStrategyTestBase method testStrategy.
public <T> void testStrategy(List<T> expectedValues, EncodingStrategy<T> strategy) {
Buffer encodeBuffer = new AutomaticBuffer();
strategy.encodeValues(encodeBuffer, expectedValues);
Buffer decodeBuffer = new FixedBuffer(encodeBuffer.getBuffer());
List<T> actualValues = strategy.decodeValues(decodeBuffer, expectedValues.size());
Assert.assertEquals(expectedValues, actualValues);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentInfoMapper method createBuilderFromValue.
private AgentInfoBo.Builder createBuilderFromValue(byte[] serializedAgentInfo) {
final Buffer buffer = new FixedBuffer(serializedAgentInfo);
final AgentInfoBo.Builder builder = new AgentInfoBo.Builder();
builder.setHostName(buffer.readPrefixedString());
builder.setIp(buffer.readPrefixedString());
builder.setPorts(buffer.readPrefixedString());
builder.setApplicationName(buffer.readPrefixedString());
builder.setServiceTypeCode(buffer.readShort());
builder.setPid(buffer.readInt());
builder.setAgentVersion(buffer.readPrefixedString());
builder.setStartTime(buffer.readLong());
builder.setEndTimeStamp(buffer.readLong());
builder.setEndStatus(buffer.readInt());
// FIXME - 2015.09 v1.5.0 added vmVersion (check for compatibility)
if (buffer.hasRemaining()) {
builder.setVmVersion(buffer.readPrefixedString());
}
// FIXME - 2018.06 v1.8.0 added container (check for compatibility)
if (buffer.hasRemaining()) {
builder.isContainer(buffer.readBoolean());
}
// 2021.03.24 added agent name
if (buffer.hasRemaining()) {
builder.setAgentName(buffer.readPrefixedString());
}
return builder;
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentLifeCycleMapper method createAgentLifeCycleBo.
private AgentLifeCycleBo createAgentLifeCycleBo(Cell valueCell) {
if (valueCell == null) {
return null;
}
byte[] value = CellUtil.cloneValue(valueCell);
final Buffer buffer = new FixedBuffer(value);
final int version = buffer.readInt();
if (version == 0) {
final String agentId = buffer.readPrefixedString();
final long startTimestamp = buffer.readLong();
final long eventTimestamp = buffer.readLong();
final long eventIdentifier = buffer.readLong();
final AgentLifeCycleState agentLifeCycleState = AgentLifeCycleState.getStateByCode(buffer.readShort());
final AgentLifeCycleBo agentLifeCycleBo = new AgentLifeCycleBo(agentId, startTimestamp, eventTimestamp, eventIdentifier, agentLifeCycleState);
return agentLifeCycleBo;
}
return null;
}
Aggregations