Search in sources :

Example 1 with FixedBuffer

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);
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 2 with FixedBuffer

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

Example 3 with FixedBuffer

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));
    }
}
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 4 with FixedBuffer

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

Example 5 with FixedBuffer

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);
}
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) CheckSum(com.navercorp.pinpoint.hbase.schema.core.CheckSum)

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