Search in sources :

Example 6 with FixedBuffer

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

the class AnnotationTranscoder method decodeLongIntIntByteByteStringValue.

private Object decodeLongIntIntByteByteStringValue(byte[] data) {
    final Buffer buffer = new FixedBuffer(data);
    final byte bitField = buffer.readByte();
    final long longValue = buffer.readVLong();
    final int intValue1 = buffer.readVInt();
    int intValue2 = -1;
    if (BitFieldUtils.testBit(bitField, 0)) {
        intValue2 = buffer.readVInt();
    }
    byte byteValue1 = -1;
    if (BitFieldUtils.testBit(bitField, 1)) {
        byteValue1 = buffer.readByte();
    }
    byte byteValue2 = -1;
    if (BitFieldUtils.testBit(bitField, 2)) {
        byteValue2 = buffer.readByte();
    }
    String stringValue = null;
    if (BitFieldUtils.testBit(bitField, 3)) {
        stringValue = BytesUtils.toString(buffer.readPrefixedBytes());
    }
    return new LongIntIntByteByteStringValue(longValue, intValue1, intValue2, byteValue1, byteValue2, stringValue);
}
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) LongIntIntByteByteStringValue(com.navercorp.pinpoint.common.util.LongIntIntByteByteStringValue)

Example 7 with FixedBuffer

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

the class AnnotationTranscoder method decodeStringStringValue.

// private Object decodeIntStringStringValue(byte[] data) {
// final Buffer buffer = new FixedBuffer(data);
// final int intValue = buffer.readSVInt();
// final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
// final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
// return new IntStringStringValue(intValue, stringValue1, stringValue2);
// }
// 
// private byte[] encodeIntStringStringValue(Object o) {
// final TIntStringStringValue tIntStringStringValue = (TIntStringStringValue) o;
// final int intValue = tIntStringStringValue.getIntValue();
// final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
// final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
// // TODO increase by a more precise value
// final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
// final Buffer buffer = new AutomaticBuffer(bufferSize);
// buffer.putSVInt(intValue);
// buffer.putPrefixedBytes(stringValue1);
// buffer.putPrefixedBytes(stringValue2);
// return buffer.getBuffer();
// }
// 
// private int getBufferSize(byte[] stringValue1, byte[] stringValue2, int reserve) {
// int length = 0;
// if (stringValue1 != null) {
// length += stringValue1.length;
// }
// if (stringValue2 != null) {
// length += stringValue2.length;
// 
// }
// return length + reserve;
// }
// 
private Object decodeStringStringValue(byte[] data) {
    final Buffer buffer = new FixedBuffer(data);
    final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
    final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
    return new StringStringValue(stringValue1, stringValue2);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 8 with FixedBuffer

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

the class AnnotationTranscoder method decodeIntBooleanIntBooleanValue.

private Object decodeIntBooleanIntBooleanValue(byte[] data) {
    final Buffer buffer = new FixedBuffer(data);
    final int intValue1 = buffer.readVInt();
    final boolean booleanValue1 = buffer.readBoolean();
    final int intValue2 = buffer.readVInt();
    final boolean booleanValue2 = buffer.readBoolean();
    return new IntBooleanIntBooleanValue(intValue1, booleanValue1, intValue2, booleanValue2);
}
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) IntBooleanIntBooleanValue(com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue)

Example 9 with FixedBuffer

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

the class DataSourceCodecTest method encodeAndDecodeTest.

@Test
public void encodeAndDecodeTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
    final DataSourceCodec dataSourceCodec = new DataSourceCodec(agentStatDataPointCodec);
    final List<JoinStatBo> joinDataSourceListBoList = createJoinDataSourceListBoList(currentTime);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    encodedValueBuffer.putByte(dataSourceCodec.getVersion());
    dataSourceCodec.encodeValues(encodedValueBuffer, joinDataSourceListBoList);
    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(), dataSourceCodec.getVersion());
    List<JoinStatBo> decodedJoinDataSourceListBoList = dataSourceCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedJoinDataSourceListBoList.size(); ++i) {
        assertEquals(decodedJoinDataSourceListBoList.get(i), joinDataSourceListBoList.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)

Example 10 with FixedBuffer

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

the class CpuLoadCodecTest method encodeAndDecodeTest.

@Test
public void encodeAndDecodeTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
    final CpuLoadCodec cpuLoadCodec = new CpuLoadCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinStatBo> joinCpuLoadBoList = createJoinCpuLoadBoList(currentTime);
    encodedValueBuffer.putByte(cpuLoadCodec.getVersion());
    cpuLoadCodec.encodeValues(encodedValueBuffer, joinCpuLoadBoList);
    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(), cpuLoadCodec.getVersion());
    List<JoinStatBo> decodedjoinCpuLoadBoList = cpuLoadCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedjoinCpuLoadBoList.size(); i++) {
        assertEquals(decodedjoinCpuLoadBoList.get(i), joinCpuLoadBoList.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)39 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)39 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)23 Test (org.junit.Test)16 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)10 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)10 Date (java.util.Date)10 ByteBuffer (java.nio.ByteBuffer)5 Cell (org.apache.hadoop.hbase.Cell)4 ArrayList (java.util.ArrayList)3 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)2 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)2 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)2 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)2 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)2 Application (com.navercorp.pinpoint.web.vo.Application)2 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)1 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1