use of org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testGossipDigestRead.
@Test
public void testGossipDigestRead() throws IOException {
if (EXECUTE_WRITES)
testGossipDigestWrite();
int count = 0;
DataInputStreamPlus 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.DataInputPlus.DataInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testSyncRequestRead.
@Test
public void testSyncRequestRead() throws IOException {
if (EXECUTE_WRITES)
testSyncRequestWrite();
InetAddress local = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 });
InetAddress src = InetAddress.getByAddress(new byte[] { 127, 0, 0, 2 });
InetAddress dest = InetAddress.getByAddress(new byte[] { 127, 0, 0, 3 });
try (DataInputStreamPlus in = getInput("service.SyncRequest.bin")) {
RepairMessage message = RepairMessage.serializer.deserialize(in, getVersion());
assert message.messageType == RepairMessage.Type.SYNC_REQUEST;
assert DESC.equals(message.desc);
assert local.equals(((SyncRequest) message).initiator);
assert src.equals(((SyncRequest) message).src);
assert dest.equals(((SyncRequest) message).dst);
assert ((SyncRequest) message).ranges.size() == 1 && ((SyncRequest) message).ranges.contains(FULL_RANGE);
assert MessageIn.read(in, getVersion(), -1) != null;
}
}
use of org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testValidationCompleteRead.
@Test
public void testValidationCompleteRead() throws IOException {
if (EXECUTE_WRITES)
testValidationCompleteWrite();
try (DataInputStreamPlus in = getInput("service.ValidationComplete.bin")) {
// empty validation
RepairMessage message = RepairMessage.serializer.deserialize(in, getVersion());
assert message.messageType == RepairMessage.Type.VALIDATION_COMPLETE;
assert DESC.equals(message.desc);
assert ((ValidationComplete) message).success();
assert ((ValidationComplete) message).trees != null;
// validation with a tree
message = RepairMessage.serializer.deserialize(in, getVersion());
assert message.messageType == RepairMessage.Type.VALIDATION_COMPLETE;
assert DESC.equals(message.desc);
assert ((ValidationComplete) message).success();
assert ((ValidationComplete) message).trees != null;
// failed validation
message = RepairMessage.serializer.deserialize(in, getVersion());
assert message.messageType == RepairMessage.Type.VALIDATION_COMPLETE;
assert DESC.equals(message.desc);
assert !((ValidationComplete) message).success();
assert ((ValidationComplete) message).trees == null;
// MessageOuts
for (int i = 0; i < 3; i++) assert MessageIn.read(in, getVersion(), -1) != null;
}
}
use of org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testEstimatedHistogramRead.
@Test
public void testEstimatedHistogramRead() throws IOException {
if (EXECUTE_WRITES)
testEstimatedHistogramWrite();
try (DataInputStreamPlus 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.DataInputPlus.DataInputStreamPlus in project cassandra by apache.
the class IncomingStreamingConnection method run.
@Override
// Not closing constructed DataInputPlus's as the stream needs to remain open.
@SuppressWarnings("resource")
public void run() {
try {
// we can't do anything with a wrong-version stream connection, so drop it.
if (version != StreamMessage.CURRENT_VERSION)
throw new IOException(String.format("Received stream using protocol version %d (my version %d). Terminating connection", version, StreamMessage.CURRENT_VERSION));
DataInputPlus input = new DataInputStreamPlus(socket.getInputStream());
StreamInitMessage init = StreamInitMessage.serializer.deserialize(input, version);
//Set SO_TIMEOUT on follower side
if (!init.isForOutgoing)
socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
// The initiator makes two connections, one for incoming and one for outgoing.
// The receiving side distinguish two connections by looking at StreamInitMessage#isForOutgoing.
// Note: we cannot use the same socket for incoming and outgoing streams because we want to
// parallelize said streams and the socket is blocking, so we might deadlock.
StreamResultFuture.initReceivingSide(init.sessionIndex, init.planId, init.description, init.from, this, init.isForOutgoing, version, init.keepSSTableLevel, init.isIncremental, init.pendingRepair);
} catch (Throwable t) {
logger.error("Error while reading from socket from {}.", socket.getRemoteSocketAddress(), t);
close();
}
}
Aggregations