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;
}
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);
}
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)));
}
}
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());
}
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));
}
Aggregations