Search in sources :

Example 1 with DataOutputStreamPlus

use of org.apache.cassandra.io.util.DataOutputStreamPlus in project cassandra by apache.

the class SerializationsTest method testGossipDigestWrite.

private void testGossipDigestWrite() throws IOException {
    Map<InetAddress, EndpointState> states = new HashMap<InetAddress, EndpointState>();
    states.put(InetAddress.getByName("127.0.0.1"), Statics.EndpointSt);
    states.put(InetAddress.getByName("127.0.0.2"), Statics.EndpointSt);
    GossipDigestAck ack = new GossipDigestAck(Statics.Digests, states);
    GossipDigestAck2 ack2 = new GossipDigestAck2(states);
    GossipDigestSyn syn = new GossipDigestSyn("Not a real cluster name", StorageService.instance.getTokenMetadata().partitioner.getClass().getCanonicalName(), Statics.Digests);
    DataOutputStreamPlus out = getOutput("gms.Gossip.bin");
    for (GossipDigest gd : Statics.Digests) GossipDigest.serializer.serialize(gd, out, getVersion());
    GossipDigestAck.serializer.serialize(ack, out, getVersion());
    GossipDigestAck2.serializer.serialize(ack2, out, getVersion());
    GossipDigestSyn.serializer.serialize(syn, out, getVersion());
    out.close();
    // test serializedSize
    for (GossipDigest gd : Statics.Digests) testSerializedSize(gd, GossipDigest.serializer);
    testSerializedSize(ack, GossipDigestAck.serializer);
    testSerializedSize(ack2, GossipDigestAck2.serializer);
    testSerializedSize(syn, GossipDigestSyn.serializer);
}
Also used : HashMap(java.util.HashMap) InetAddress(java.net.InetAddress) DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Example 2 with DataOutputStreamPlus

use of org.apache.cassandra.io.util.DataOutputStreamPlus in project cassandra by apache.

the class SerializationsTest method testEndpointStateWrite.

private void testEndpointStateWrite() throws IOException {
    DataOutputStreamPlus out = getOutput("gms.EndpointState.bin");
    HeartBeatState.serializer.serialize(Statics.HeartbeatSt, out, getVersion());
    EndpointState.serializer.serialize(Statics.EndpointSt, out, getVersion());
    VersionedValue.serializer.serialize(Statics.vv0, out, getVersion());
    VersionedValue.serializer.serialize(Statics.vv1, out, getVersion());
    out.close();
    // test serializedSize
    testSerializedSize(Statics.HeartbeatSt, HeartBeatState.serializer);
    testSerializedSize(Statics.EndpointSt, EndpointState.serializer);
    testSerializedSize(Statics.vv0, VersionedValue.serializer);
    testSerializedSize(Statics.vv1, VersionedValue.serializer);
}
Also used : DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Example 3 with DataOutputStreamPlus

use of org.apache.cassandra.io.util.DataOutputStreamPlus in project cassandra by apache.

the class MessagingServiceTest method addDCLatency.

private static void addDCLatency(long sentAt, long nowTime) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (DataOutputStreamPlus out = new WrappedDataOutputStreamPlus(baos)) {
        out.writeInt((int) sentAt);
    }
    DataInputStreamPlus in = new DataInputStreamPlus(new ByteArrayInputStream(baos.toByteArray()));
    MessageIn.readConstructionTime(InetAddress.getLocalHost(), in, nowTime);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStreamPlus(org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus) WrappedDataOutputStreamPlus(org.apache.cassandra.io.util.WrappedDataOutputStreamPlus) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WrappedDataOutputStreamPlus(org.apache.cassandra.io.util.WrappedDataOutputStreamPlus) DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Example 4 with DataOutputStreamPlus

use of org.apache.cassandra.io.util.DataOutputStreamPlus in project cassandra by apache.

the class BloomFilterTest method testHugeBFSerialization.

@Test
@Ignore
public void testHugeBFSerialization() throws IOException {
    ByteBuffer test = ByteBuffer.wrap(new byte[] { 0, 1 });
    File file = FileUtils.createTempFile("bloomFilterTest-", ".dat");
    BloomFilter filter = (BloomFilter) FilterFactory.getFilter(((long) Integer.MAX_VALUE / 8) + 1, 0.01d, true);
    filter.add(FilterTestHelper.wrap(test));
    DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(file));
    FilterFactory.serialize(filter, out);
    filter.bitset.serialize(out);
    out.close();
    filter.close();
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    BloomFilter filter2 = (BloomFilter) FilterFactory.deserialize(in, true);
    Assert.assertTrue(filter2.isPresent(FilterTestHelper.wrap(test)));
    FileUtils.closeQuietly(in);
    filter2.close();
}
Also used : BufferedDataOutputStreamPlus(org.apache.cassandra.io.util.BufferedDataOutputStreamPlus) ByteBuffer(java.nio.ByteBuffer) BufferedDataOutputStreamPlus(org.apache.cassandra.io.util.BufferedDataOutputStreamPlus) DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Example 5 with DataOutputStreamPlus

use of org.apache.cassandra.io.util.DataOutputStreamPlus in project cassandra by apache.

the class SerializationsTest method testRepairMessageWrite.

private void testRepairMessageWrite(String fileName, RepairMessage... messages) throws IOException {
    try (DataOutputStreamPlus out = getOutput(fileName)) {
        for (RepairMessage message : messages) {
            testSerializedSize(message, RepairMessage.serializer);
            RepairMessage.serializer.serialize(message, out, getVersion());
        }
        // also serialize MessageOut
        for (RepairMessage message : messages) message.createMessage().serialize(out, getVersion());
    }
}
Also used : DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Aggregations

DataOutputStreamPlus (org.apache.cassandra.io.util.DataOutputStreamPlus)7 BufferedDataOutputStreamPlus (org.apache.cassandra.io.util.BufferedDataOutputStreamPlus)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InetAddress (java.net.InetAddress)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 DataInputStreamPlus (org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus)1 WrappedDataOutputStreamPlus (org.apache.cassandra.io.util.WrappedDataOutputStreamPlus)1