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