Search in sources :

Example 1 with CheckSum

use of com.navercorp.pinpoint.hbase.schema.core.CheckSum in project pinpoint by naver.

the class CheckSumTest method computeAndParse.

@Test
public void computeAndParse() {
    String randomValue = UUID.randomUUID().toString();
    CheckSum checkSum = CheckSum.compute(CheckSum.getCurrentVersion(), randomValue);
    CheckSum parsedCheckSum = CheckSum.parse(checkSum.toString());
    Assert.assertEquals(checkSum.getVersion(), parsedCheckSum.getVersion());
    Assert.assertEquals(checkSum.getCheckSum(), parsedCheckSum.getCheckSum());
}
Also used : CheckSum(com.navercorp.pinpoint.hbase.schema.core.CheckSum) Test(org.junit.Test)

Example 2 with CheckSum

use of com.navercorp.pinpoint.hbase.schema.core.CheckSum 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)

Example 3 with CheckSum

use of com.navercorp.pinpoint.hbase.schema.core.CheckSum in project pinpoint by naver.

the class SchemaChangeLogCodec method writeData.

@Override
public byte[] writeData(SchemaChangeLog schemaChangeLog) {
    final Buffer buffer = new AutomaticBuffer();
    buffer.putShort(CURRENT_VERSION);
    buffer.putPrefixedString(schemaChangeLog.getId());
    buffer.putLong(schemaChangeLog.getExecTimestamp());
    buffer.putInt(schemaChangeLog.getExecOrder());
    CheckSum checkSum = schemaChangeLog.getCheckSum();
    buffer.putInt(checkSum.getVersion());
    buffer.putPrefixedString(checkSum.getCheckSum());
    buffer.putPrefixedString(schemaChangeLog.getValue());
    return buffer.getBuffer();
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) CheckSum(com.navercorp.pinpoint.hbase.schema.core.CheckSum) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 4 with CheckSum

use of com.navercorp.pinpoint.hbase.schema.core.CheckSum in project pinpoint by naver.

the class SchemaChangeLogServiceImpl method recordChangeSet.

private SchemaChangeLog recordChangeSet(String namespace, long executionTimestamp, int executionOrder, ChangeSet changeSet) {
    CheckSum checkSum = CheckSum.compute(CheckSum.getCurrentVersion(), changeSet.getValue());
    SchemaChangeLog schemaChangeLog = new SchemaChangeLog.Builder().id(changeSet.getId()).execTimestamp(executionTimestamp).execOrder(executionOrder).checkSum(checkSum).value(changeSet.getValue()).build();
    schemaChangeLogDao.insertChangeLog(namespace, schemaChangeLog);
    return schemaChangeLog;
}
Also used : CheckSum(com.navercorp.pinpoint.hbase.schema.core.CheckSum) SchemaChangeLog(com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog)

Aggregations

CheckSum (com.navercorp.pinpoint.hbase.schema.core.CheckSum)4 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)2 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)2 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)2 SchemaChangeLog (com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog)1 Test (org.junit.Test)1