use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class EncodingStrategyTestBase method getBufferSizes.
private Map<EncodingStrategy<T>, Integer> getBufferSizes(List<T> values) {
Map<EncodingStrategy<T>, Integer> bufferSizes = new HashMap<>();
for (EncodingStrategy<T> strategy : getEncodingStrategies()) {
Buffer encodedBuffer = new AutomaticBuffer();
codec.encodeValues(encodedBuffer, strategy, values);
int encodedBufferSize = encodedBuffer.getBuffer().length;
bufferSizes.put(strategy, encodedBufferSize);
}
logger.debug("Strategies : {}", bufferSizes);
return bufferSizes;
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class AgentStatDataPointCodecTest method test_single_timestamp.
@Test
public void test_single_timestamp() {
// Given
final long givenTimestamp = System.currentTimeMillis();
final List<Long> expectedTimestamp = Arrays.asList(givenTimestamp);
final Buffer timestampBuffer = new AutomaticBuffer();
// When
codec.encodeTimestamps(timestampBuffer, expectedTimestamp);
// Then
List<Long> decodedTimestamp = codec.decodeTimestamps(givenTimestamp, new FixedBuffer(timestampBuffer.getBuffer()), 1);
Assert.assertEquals(expectedTimestamp, decodedTimestamp);
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class ApplicationMapStatisticsUtils method makeRowKey.
/**
* <pre>
* rowkey format = "APPLICATIONNAME(max 24bytes)" + apptype(2byte) + "TIMESTAMP(8byte)"
* </pre>
*
* @param applicationName
* @param timestamp
* @return
*/
public static byte[] makeRowKey(String applicationName, short applicationType, long timestamp) {
Objects.requireNonNull(applicationName, "applicationName");
final byte[] applicationNameBytes = BytesUtils.toBytes(applicationName);
final Buffer buffer = new AutomaticBuffer(2 + applicationNameBytes.length + 2 + 8);
// buffer.put2PrefixedString(applicationName);
buffer.putShort((short) applicationNameBytes.length);
buffer.putBytes(applicationNameBytes);
buffer.putShort(applicationType);
long reverseTimeMillis = TimeUtils.reverseTimeMillis(timestamp);
buffer.putLong(reverseTimeMillis);
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class ApplicationMapStatisticsUtils method makeColumnName.
public static byte[] makeColumnName(short serviceType, String applicationName, String destHost, short slotNumber) {
Objects.requireNonNull(applicationName, "applicationName");
destHost = StringUtils.defaultString(destHost, "");
// approximate size of destHost
final Buffer buffer = new AutomaticBuffer(BytesUtils.SHORT_BYTE_LENGTH + PinpointConstants.APPLICATION_NAME_MAX_LEN + destHost.length() + BytesUtils.SHORT_BYTE_LENGTH);
buffer.putShort(serviceType);
buffer.putShort(slotNumber);
buffer.put2PrefixedString(applicationName);
buffer.putBytes(BytesUtils.toBytes(destHost));
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.
the class TransactionCodecTest method encodeValuesTest.
@Test
public void encodeValuesTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
TransactionCodec transactionCodec = new TransactionCodec(new AgentStatDataPointCodec());
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinTransactionBoList = createJoinTransactionBoList(currentTime);
encodedValueBuffer.putByte(transactionCodec.getVersion());
transactionCodec.encodeValues(encodedValueBuffer, joinTransactionBoList);
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(), transactionCodec.getVersion());
List<JoinStatBo> decodedJoinTransactionBoList = transactionCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinTransactionBoList.size(); i++) {
assertEquals(decodedJoinTransactionBoList.get(i), joinTransactionBoList.get(i));
}
}
Aggregations