use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.
the class FBUtilities method serialize.
public static <T> byte[] serialize(T object, IVersionedSerializer<T> serializer, int version) throws IOException {
int size = (int) serializer.serializedSize(object, version);
DataOutputBuffer buffer = new DataOutputBuffer(size);
serializer.serialize(object, buffer, version);
assert buffer.getLength() == size && buffer.getData().length == size : String.format("Final buffer length %s to accomodate data size of %s (predicted %s) for %s", buffer.getData().length, buffer.getLength(), size, object);
return buffer.getData();
}
use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.
the class ExpiringColumn method updateDigest.
@Override
public void updateDigest(MessageDigest digest) {
digest.update(name.duplicate());
digest.update(value.duplicate());
DataOutputBuffer buffer = new DataOutputBuffer();
try {
buffer.writeLong(timestamp);
buffer.writeByte(serializationFlags());
buffer.writeInt(timeToLive);
} catch (IOException e) {
throw new RuntimeException(e);
}
digest.update(buffer.getData(), 0, buffer.getLength());
}
use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.
the class RangeSliceCommandSerializer method getMessage.
public Message getMessage(Integer version) throws IOException {
DataOutputBuffer dob = new DataOutputBuffer();
serializer.serialize(this, dob, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.RANGE_SLICE, Arrays.copyOf(dob.getData(), dob.getLength()), version);
}
use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.
the class DependencyCheck method getMessage.
@Override
public Message getMessage(Integer version) throws IOException {
DataOutputBuffer dob = new DataOutputBuffer();
serializer_.serialize(this, dob, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.DEPENDENCY_CHECK, Arrays.copyOf(dob.getData(), dob.getLength()), version);
}
use of org.apache.cassandra.io.util.DataOutputBuffer in project eiger by wlloyd.
the class CounterColumn method updateDigest.
/*
* We have to special case digest creation for counter column because
* we don't want to include the information about which shard of the
* context is a delta or not, since this information differs from node to
* node.
*/
@Override
public void updateDigest(MessageDigest digest) {
digest.update(name.duplicate());
// We don't take the deltas into account in a digest
contextManager.updateDigest(digest, value);
DataOutputBuffer buffer = new DataOutputBuffer();
try {
buffer.writeLong(timestamp);
buffer.writeByte(serializationFlags());
buffer.writeLong(timestampOfLastDelete);
} catch (IOException e) {
throw new RuntimeException(e);
}
digest.update(buffer.getData(), 0, buffer.getLength());
}
Aggregations