use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class TransactionIdUtils method parseTransactionId.
public static TransactionId parseTransactionId(final byte[] transactionId) {
if (transactionId == null) {
throw new NullPointerException("transactionId must not be null");
}
final Buffer buffer = new FixedBuffer(transactionId);
final byte version = buffer.readByte();
if (version != VERSION) {
throw new IllegalArgumentException("invalid Version");
}
final String agentId = buffer.readPrefixedString();
final long agentStartTime = buffer.readVLong();
final long transactionSequence = buffer.readVLong();
if (agentId == null) {
return new TransactionId(agentStartTime, transactionSequence);
} else {
return new TransactionId(agentId, agentStartTime, transactionSequence);
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class HbaseHostApplicationMapDaoTest method testCreateRowKey.
@Test
public void testCreateRowKey() {
long statisticsRowSlot = timeSlot.getTimeSlot(System.currentTimeMillis());
byte[] parentApps = HbaseHostApplicationMapDao.createRowKey0("parentApp", ServiceType.STAND_ALONE.getCode(), statisticsRowSlot, null);
logger.debug("rowKey size:{}", parentApps.length);
Buffer readBuffer = new FixedBuffer(parentApps);
String appName = readBuffer.readPadStringAndRightTrim(HbaseTableConstants.APPLICATION_NAME_MAX_LEN);
short code = readBuffer.readShort();
long time = TimeUtils.recoveryTimeMillis(readBuffer.readLong());
Assert.assertEquals("applicationName check", appName, "parentApp");
Assert.assertEquals("serviceType check", code, ServiceType.STAND_ALONE.getCode());
Assert.assertEquals("time check", statisticsRowSlot, time);
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class FileDescriptorCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final FileDescriptorCodec fileDescriptorCodec = new FileDescriptorCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinFileDescriptorBoList = createJoinFileDescriptorBoList(currentTime);
encodedValueBuffer.putByte(fileDescriptorCodec.getVersion());
fileDescriptorCodec.encodeValues(encodedValueBuffer, joinFileDescriptorBoList);
final Buffer valueBuffer = new FixedBuffer(encodedValueBuffer.getBuffer());
;
final long baseTimestamp = AgentStatUtils.getBaseTimestamp(currentTime);
final long timestampDelta = currentTime - baseTimestamp;
final ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
decodingContext.setApplicationId(id);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
assertEquals(valueBuffer.readByte(), fileDescriptorCodec.getVersion());
List<JoinStatBo> decodedJoinFileDescriptorBoList = fileDescriptorCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinFileDescriptorBoList.size(); i++) {
assertEquals(decodedJoinFileDescriptorBoList.get(i), joinFileDescriptorBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class ApplicationMapStatisticsUtilsTest method testMakeColumnName2.
@Test
public void testMakeColumnName2() {
// short serviceType, String applicationName, String destHost, short slotNumber
final short slotNumber = 10;
final byte[] columnNameBytes = ApplicationMapStatisticsUtils.makeColumnName(ServiceType.STAND_ALONE.getCode(), "applicationName", "dest", slotNumber);
Buffer buffer = new FixedBuffer(columnNameBytes);
Assert.assertEquals(ServiceType.STAND_ALONE.getCode(), buffer.readShort());
Assert.assertEquals(10, buffer.readShort());
Assert.assertEquals("applicationName", buffer.read2PrefixedString());
int offset = buffer.getOffset();
byte[] interBuffer = buffer.getInternalBuffer();
Assert.assertEquals(BytesUtils.toString(interBuffer, offset, interBuffer.length - offset), "dest");
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class SchemaChangeLogCodec method readData.
@Override
public SchemaChangeLog readData(byte[] data) {
if (data == null) {
return null;
}
final Buffer buffer = new FixedBuffer(data);
short version = buffer.readShort();
if (version == 1) {
String id = buffer.readPrefixedString();
long execTimestamp = buffer.readLong();
int execOrder = buffer.readInt();
CheckSum checkSum = new CheckSum(buffer.readInt(), buffer.readPrefixedString());
String value = buffer.readPrefixedString();
return new SchemaChangeLog.Builder().id(id).execTimestamp(execTimestamp).execOrder(execOrder).checkSum(checkSum).value(value).build();
}
throw new IllegalStateException("Unsupported schema change log version : " + version);
}
Aggregations