Search in sources :

Example 11 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class ManagementLogger method read.

@Override
public void read(Message message) {
    ReadBuffer in = message.getContent().asReadBuffer();
    String senderId = message.getSenderId();
    Serializer serializer = graph.getDataSerializer();
    MgmtLogType logType = serializer.readObjectNotNull(in, MgmtLogType.class);
    Preconditions.checkNotNull(logType);
    if (logType == MgmtLogType.CACHED_TYPE_EVICTION) {
        long evictionId = VariableLong.readPositive(in);
        long numEvictions = VariableLong.readPositive(in);
        for (int i = 0; i < numEvictions; i++) {
            long typeId = VariableLong.readPositive(in);
            schemaCache.expireSchemaElement(typeId);
        }
        Thread ack = new Thread(new SendAckOnTxClose(evictionId, senderId, graph.getOpenTransactions()));
        ack.setDaemon(true);
        ack.start();
    } else if (logType == MgmtLogType.CACHED_TYPE_EVICTION_ACK) {
        String receiverId = serializer.readObjectNotNull(in, String.class);
        long evictionId = VariableLong.readPositive(in);
        if (receiverId.equals(graph.getConfiguration().getUniqueGraphId())) {
            //Acknowledgements targeted at this instance
            EvictionTrigger evictTrigger = evictionTriggerMap.get(evictionId);
            if (evictTrigger != null) {
                evictTrigger.receivedAcknowledgement(senderId);
            } else
                log.error("Could not find eviction trigger for {} from {}", evictionId, senderId);
        }
    } else
        assert logType == MgmtLogType.CONFIG_MUTATION;
}
Also used : ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Serializer(com.thinkaurelius.titan.graphdb.database.serialize.Serializer)

Example 12 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class ConsistentKeyLockerSerializer method fromLockColumn.

public TimestampRid fromLockColumn(StaticBuffer lockKey, TimestampProvider provider) {
    ReadBuffer r = lockKey.asReadBuffer();
    int len = r.length();
    long tsNS = r.getLong();
    len -= 8;
    byte[] curRid = new byte[len];
    for (int i = 0; r.hasRemaining(); i++) {
        curRid[i] = r.getByte();
    }
    StaticBuffer rid = new StaticArrayBuffer(curRid);
    Instant time = provider.getTime(tsNS);
    return new TimestampRid(time, rid);
}
Also used : ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Instant(java.time.Instant) StaticArrayBuffer(com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer)

Example 13 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class IDManagementTest method writingInlineEdgeTypes.

@Test
public void writingInlineEdgeTypes() {
    int numTries = 100;
    WriteBuffer out = new WriteByteBuffer(8 * numTries);
    for (SystemRelationType t : SYSTEM_TYPES) {
        IDHandler.writeInlineRelationType(out, t.longId());
    }
    for (long i = 1; i <= numTries; i++) {
        IDHandler.writeInlineRelationType(out, IDManager.getSchemaId(IDManager.VertexIDType.UserEdgeLabel, i * 1000));
    }
    ReadBuffer in = out.getStaticBuffer().asReadBuffer();
    for (SystemRelationType t : SYSTEM_TYPES) {
        assertEquals(t, SystemTypeManager.getSystemType(IDHandler.readInlineRelationType(in)));
    }
    for (long i = 1; i <= numTries; i++) {
        assertEquals(i * 1000, IDManager.stripEntireRelationTypePadding(IDHandler.readInlineRelationType(in)));
    }
}
Also used : ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) WriteBuffer(com.thinkaurelius.titan.diskstorage.WriteBuffer) WriteByteBuffer(com.thinkaurelius.titan.diskstorage.util.WriteByteBuffer) Test(org.junit.Test)

Example 14 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method enumSerializeTest.

@Test
public void enumSerializeTest() {
    serialize.registerClass(1, TEnum.class, new TEnumSerializer());
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(TEnum.TWO);
    out.writeObjectNotNull(TEnum.THREE);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    if (printStats)
        log.debug(bufferStats(b));
    assertEquals(TEnum.TWO, serialize.readObjectNotNull(b, TEnum.class));
    assertEquals(TEnum.THREE, serialize.readObjectNotNull(b, TEnum.class));
    assertFalse(b.hasRemaining());
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test)

Example 15 with ReadBuffer

use of com.thinkaurelius.titan.diskstorage.ReadBuffer in project titan by thinkaurelius.

the class SerializerTest method classSerialization.

@Test
public void classSerialization() {
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(Boolean.class);
    out.writeObjectNotNull(Byte.class);
    out.writeObjectNotNull(Double.class);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    assertEquals(Boolean.class, serialize.readObjectNotNull(b, Class.class));
    assertEquals(Byte.class, serialize.readObjectNotNull(b, Class.class));
    assertEquals(Double.class, serialize.readObjectNotNull(b, Class.class));
}
Also used : DataOutput(com.thinkaurelius.titan.graphdb.database.serialize.DataOutput) ReadBuffer(com.thinkaurelius.titan.diskstorage.ReadBuffer) Test(org.junit.Test)

Aggregations

ReadBuffer (com.thinkaurelius.titan.diskstorage.ReadBuffer)19 DataOutput (com.thinkaurelius.titan.graphdb.database.serialize.DataOutput)12 Test (org.junit.Test)12 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)8 WriteBuffer (com.thinkaurelius.titan.diskstorage.WriteBuffer)4 WriteByteBuffer (com.thinkaurelius.titan.diskstorage.util.WriteByteBuffer)4 Serializer (com.thinkaurelius.titan.graphdb.database.serialize.Serializer)2 Instant (java.time.Instant)2 LongObjectHashMap (com.carrotsearch.hppc.LongObjectHashMap)1 EntryMetaData (com.thinkaurelius.titan.diskstorage.EntryMetaData)1 StaticArrayBuffer (com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer)1 IDHandler (com.thinkaurelius.titan.graphdb.database.idhandling.IDHandler)1 RelationTypeParse (com.thinkaurelius.titan.graphdb.database.idhandling.IDHandler.RelationTypeParse)1 StandardSerializer (com.thinkaurelius.titan.graphdb.database.serialize.StandardSerializer)1 RelationCategory (com.thinkaurelius.titan.graphdb.internal.RelationCategory)1 EdgeDirection (com.thinkaurelius.titan.graphdb.relations.EdgeDirection)1 RelationCache (com.thinkaurelius.titan.graphdb.relations.RelationCache)1 ImplicitKey (com.thinkaurelius.titan.graphdb.types.system.ImplicitKey)1 Map (java.util.Map)1 StopWatch (org.apache.commons.lang.time.StopWatch)1