Search in sources :

Example 56 with DataOutputBuffer

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();
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 57 with DataOutputBuffer

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());
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) IOException(java.io.IOException)

Example 58 with DataOutputBuffer

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);
}
Also used : Message(org.apache.cassandra.net.Message) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 59 with DataOutputBuffer

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);
}
Also used : Message(org.apache.cassandra.net.Message) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 60 with DataOutputBuffer

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());
}
Also used : DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) IOException(java.io.IOException)

Aggregations

DataOutputBuffer (org.apache.cassandra.io.util.DataOutputBuffer)68 Test (org.junit.Test)25 DataInputBuffer (org.apache.cassandra.io.util.DataInputBuffer)17 IOException (java.io.IOException)16 ByteBuffer (java.nio.ByteBuffer)15 ByteArrayInputStream (java.io.ByteArrayInputStream)10 DataInputStream (java.io.DataInputStream)10 DataInputPlus (org.apache.cassandra.io.util.DataInputPlus)8 File (java.io.File)6 CRC32 (java.util.zip.CRC32)5 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)3 DataOutputBufferFixed (org.apache.cassandra.io.util.DataOutputBufferFixed)3 SequentialWriter (org.apache.cassandra.io.util.SequentialWriter)3 Message (org.apache.cassandra.net.Message)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Mutation (org.apache.cassandra.db.Mutation)2