use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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.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) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
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 HbaseApplicationTraceIndexDao method makeResponseTimeFilter.
/**
* make the hbase filter for selecting values of y-axis(response time) in order to select transactions in scatter chart.
* 4 bytes for elapsed time should be attached for the prefix of column qualifier for to use this filter.
*
* @param area
* @param offsetTransactionId
* @param offsetTransactionElapsed
* @return
*/
private Filter makeResponseTimeFilter(final SelectedScatterArea area, final TransactionId offsetTransactionId, int offsetTransactionElapsed) {
// filter by response time
ResponseTimeRange responseTimeRange = area.getResponseTimeRange();
byte[] responseFrom = Bytes.toBytes(responseTimeRange.getFrom());
byte[] responseTo = Bytes.toBytes(responseTimeRange.getTo());
FilterList filterList = new FilterList(Operator.MUST_PASS_ALL);
filterList.addFilter(new QualifierFilter(CompareOp.GREATER_OR_EQUAL, new BinaryPrefixComparator(responseFrom)));
filterList.addFilter(new QualifierFilter(CompareOp.LESS_OR_EQUAL, new BinaryPrefixComparator(responseTo)));
// add offset
if (offsetTransactionId != null) {
final Buffer buffer = new AutomaticBuffer(32);
buffer.putInt(offsetTransactionElapsed);
buffer.putPrefixedString(offsetTransactionId.getAgentId());
buffer.putSVLong(offsetTransactionId.getAgentStartTime());
buffer.putVLong(offsetTransactionId.getTransactionSequence());
byte[] qualifierOffset = buffer.getBuffer();
filterList.addFilter(new QualifierFilter(CompareOp.GREATER, new BinaryPrefixComparator(qualifierOffset)));
}
return filterList;
}
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) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (destHost == null) {
// throw new NullPointerException("destHost must not be null");
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();
}
Aggregations