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