Search in sources :

Example 11 with FileInputStreamPlus

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

the class SerializationsTest method testEndpointStateRead.

@Test
public void testEndpointStateRead() throws IOException {
    if (EXECUTE_WRITES)
        testEndpointStateWrite();
    FileInputStreamPlus in = getInput("gms.EndpointState.bin");
    assert HeartBeatState.serializer.deserialize(in, getVersion()) != null;
    assert EndpointState.serializer.deserialize(in, getVersion()) != null;
    assert VersionedValue.serializer.deserialize(in, getVersion()) != null;
    assert VersionedValue.serializer.deserialize(in, getVersion()) != null;
    in.close();
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) Test(org.junit.Test)

Example 12 with FileInputStreamPlus

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

the class SerializationsTest method testGossipDigestRead.

@Test
public void testGossipDigestRead() throws IOException {
    if (EXECUTE_WRITES)
        testGossipDigestWrite();
    int count = 0;
    FileInputStreamPlus in = getInput("gms.Gossip.bin");
    while (count < Statics.Digests.size()) assert GossipDigestAck2.serializer.deserialize(in, getVersion()) != null;
    assert GossipDigestAck.serializer.deserialize(in, getVersion()) != null;
    assert GossipDigestAck2.serializer.deserialize(in, getVersion()) != null;
    assert GossipDigestSyn.serializer.deserialize(in, getVersion()) != null;
    in.close();
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) Test(org.junit.Test)

Example 13 with FileInputStreamPlus

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

the class SerializationsTest method testBloomFilterTable.

private static void testBloomFilterTable(String file, boolean oldBfFormat) throws Exception {
    Murmur3Partitioner partitioner = new Murmur3Partitioner();
    try (DataInputStream in = new DataInputStream(new FileInputStreamPlus(new File(file)));
        IFilter filter = BloomFilterSerializer.deserialize(in, oldBfFormat)) {
        for (int i = 1; i <= 10; i++) {
            DecoratedKey decoratedKey = partitioner.decorateKey(Int32Type.instance.decompose(i));
            boolean present = filter.isPresent(decoratedKey);
            Assert.assertTrue(present);
        }
        int positives = 0;
        for (int i = 11; i <= 1000010; i++) {
            DecoratedKey decoratedKey = partitioner.decorateKey(Int32Type.instance.decompose(i));
            boolean present = filter.isPresent(decoratedKey);
            if (present)
                positives++;
        }
        double fpr = positives;
        fpr /= 1000000;
        Assert.assertTrue(fpr <= 0.011d);
    }
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) DecoratedKey(org.apache.cassandra.db.DecoratedKey) Murmur3Partitioner(org.apache.cassandra.dht.Murmur3Partitioner) DataInputStream(java.io.DataInputStream) File(org.apache.cassandra.io.util.File)

Example 14 with FileInputStreamPlus

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

the class SerializationsTest method testEstimatedHistogramRead.

@Test
public void testEstimatedHistogramRead() throws IOException {
    if (EXECUTE_WRITES)
        testEstimatedHistogramWrite();
    try (FileInputStreamPlus in = getInput("utils.EstimatedHistogram.bin")) {
        Assert.assertNotNull(EstimatedHistogram.serializer.deserialize(in));
        Assert.assertNotNull(EstimatedHistogram.serializer.deserialize(in));
        Assert.assertNotNull(EstimatedHistogram.serializer.deserialize(in));
    }
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) Test(org.junit.Test)

Example 15 with FileInputStreamPlus

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

the class SerializationsTest method testSyncRequestRead.

@Test
public void testSyncRequestRead() throws IOException {
    if (EXECUTE_WRITES)
        testSyncRequestWrite();
    InetAddressAndPort local = InetAddressAndPort.getByNameOverrideDefaults("127.0.0.1", PORT);
    InetAddressAndPort src = InetAddressAndPort.getByNameOverrideDefaults("127.0.0.2", PORT);
    InetAddressAndPort dest = InetAddressAndPort.getByNameOverrideDefaults("127.0.0.3", PORT);
    try (FileInputStreamPlus in = getInput("service.SyncRequest.bin")) {
        SyncRequest message = SyncRequest.serializer.deserialize(in, getVersion());
        assert DESC.equals(message.desc);
        assert local.equals(message.initiator);
        assert src.equals(message.src);
        assert dest.equals(message.dst);
        assert message.ranges.size() == 1 && message.ranges.contains(FULL_RANGE);
        assert !message.asymmetric;
    }
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) Test(org.junit.Test)

Aggregations

FileInputStreamPlus (org.apache.cassandra.io.util.FileInputStreamPlus)16 Test (org.junit.Test)7 File (org.apache.cassandra.io.util.File)5 FileOutputStreamPlus (org.apache.cassandra.io.util.FileOutputStreamPlus)3 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)2 DataInputStream (java.io.DataInputStream)1 Properties (java.util.Properties)1 CRC32 (java.util.zip.CRC32)1 CheckedInputStream (java.util.zip.CheckedInputStream)1 DecoratedKey (org.apache.cassandra.db.DecoratedKey)1 CassandraOutgoingFile (org.apache.cassandra.db.streaming.CassandraOutgoingFile)1 Murmur3Partitioner (org.apache.cassandra.dht.Murmur3Partitioner)1 DataOutputStreamPlus (org.apache.cassandra.io.util.DataOutputStreamPlus)1 SyncNodePair (org.apache.cassandra.repair.SyncNodePair)1 TableId (org.apache.cassandra.schema.TableId)1 BloomFilter (org.apache.cassandra.utils.BloomFilter)1 BeforeClass (org.junit.BeforeClass)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1