use of org.apache.ratis.client.impl.DataStreamClientImpl.DataStreamOutputImpl in project incubator-ratis by apache.
the class DataStreamBaseTest method runTestMockCluster.
void runTestMockCluster(ClientId clientId, int bufferSize, int bufferNum, Exception expectedException, Exception headerException) throws IOException {
try (final RaftClient client = newRaftClientForDataStream(clientId)) {
final DataStreamOutputImpl out = (DataStreamOutputImpl) client.getDataStreamApi().stream(null, DataStreamTestUtils.getRoutingTableChainTopology(peers, getPrimaryServer().getPeer()));
if (headerException != null) {
final DataStreamReply headerReply = out.getHeaderFuture().join();
Assert.assertFalse(headerReply.isSuccess());
final RaftClientReply clientReply = ClientProtoUtils.toRaftClientReply(((DataStreamReplyByteBuffer) headerReply).slice());
Assert.assertTrue(clientReply.getException().getMessage().contains(headerException.getMessage()));
return;
}
final RaftClientReply clientReply = DataStreamTestUtils.writeAndCloseAndAssertReplies(CollectionUtils.as(servers, Server::getRaftServer), null, out, bufferSize, bufferNum, getPrimaryClientId(), client.getId(), false).join();
if (expectedException != null) {
Assert.assertFalse(clientReply.isSuccess());
Assert.assertTrue(clientReply.getException().getMessage().contains(expectedException.getMessage()));
} else {
Assert.assertTrue(clientReply.isSuccess());
}
}
}
Aggregations