Search in sources :

Example 86 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 87 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class AgentEventMessageDeserializerV1 method deserializeDeadlockBo.

private DeadlockBo deserializeDeadlockBo(final byte[] eventBody) {
    final Buffer buffer = new FixedBuffer(eventBody);
    final int deadlockedThreadCount = buffer.readInt();
    final int threadDumpBoListSize = buffer.readVInt();
    final List<ThreadDumpBo> threadDumpBoList = new ArrayList<>(threadDumpBoListSize);
    if (threadDumpBoListSize > 0) {
        threadDumpBoList.add(readThreadDumpBo(buffer));
    }
    final DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(deadlockedThreadCount);
    deadlockBo.setThreadDumpBoList(threadDumpBoList);
    return deadlockBo;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ArrayList(java.util.ArrayList) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)

Example 88 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 89 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 90 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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));
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) Test(org.junit.Test)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)107 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)76 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)57 ByteBuffer (java.nio.ByteBuffer)27 Test (org.junit.Test)24 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)15 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)11 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)11 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)9 Cell (org.apache.hadoop.hbase.Cell)9 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)8 ArrayList (java.util.ArrayList)6 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)4 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)4 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)4 Put (org.apache.hadoop.hbase.client.Put)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)3