use of org.apache.ratis.protocol.RoutingTable in project incubator-ratis by apache.
the class DataStreamTestUtils method getRoutingTableChainTopology.
static RoutingTable getRoutingTableChainTopology(Iterable<RaftPeerId> peers, RaftPeerId primary) {
final RoutingTable.Builder builder = RoutingTable.newBuilder();
RaftPeerId previous = primary;
for (RaftPeerId peer : peers) {
if (peer.equals(primary)) {
continue;
}
builder.addSuccessor(previous, peer);
previous = peer;
}
return builder.build();
}
use of org.apache.ratis.protocol.RoutingTable in project incubator-ratis by apache.
the class DataStream method operation.
@Override
protected void operation(List<FileStoreClient> clients) throws IOException, ExecutionException, InterruptedException {
if (!checkParam()) {
stop(clients);
}
final ExecutorService executor = Executors.newFixedThreadPool(getNumThread());
List<String> paths = generateFiles(executor);
dropCache();
System.out.println("Starting DataStream write now ");
RoutingTable routingTable = getRoutingTable(Arrays.asList(getPeers()), getPrimary());
long startTime = System.currentTimeMillis();
long totalWrittenBytes = waitStreamFinish(streamWrite(paths, clients, routingTable, executor));
long endTime = System.currentTimeMillis();
System.out.println("Total files written: " + getNumFiles());
System.out.println("Each files size: " + getFileSizeInBytes());
System.out.println("Total data written: " + totalWrittenBytes + " bytes");
System.out.println("Total time taken: " + (endTime - startTime) + " millis");
stop(clients);
}
use of org.apache.ratis.protocol.RoutingTable in project incubator-ratis by apache.
the class FileStoreStreamingBaseTest method testFileStoreStreamSingleFile.
@Test
public void testFileStoreStreamSingleFile() throws Exception {
final CLUSTER cluster = newCluster(NUM_PEERS);
cluster.start();
RaftTestUtil.waitForLeader(cluster);
final RaftGroup raftGroup = cluster.getGroup();
final Collection<RaftPeer> peers = raftGroup.getPeers();
Assert.assertEquals(NUM_PEERS, peers.size());
RaftPeer primary = peers.iterator().next();
final CheckedSupplier<FileStoreClient, IOException> newClient = () -> new FileStoreClient(cluster.getGroup(), getProperties(), primary);
RoutingTable routingTable = DataStreamTestUtils.getRoutingTableChainTopology(peers, primary);
testSingleFile("foo", SizeInBytes.valueOf("2M"), 10_000, newClient, routingTable);
testSingleFile("bar", SizeInBytes.valueOf("2M"), 1000, newClient, routingTable);
testSingleFile("sar", SizeInBytes.valueOf("20M"), 100_000, newClient, routingTable);
cluster.shutdown();
}
use of org.apache.ratis.protocol.RoutingTable in project incubator-ratis by apache.
the class SubCommandBase method getRoutingTable.
public RoutingTable getRoutingTable(Collection<RaftPeer> raftPeers, RaftPeer primary) {
RoutingTable.Builder builder = RoutingTable.newBuilder();
RaftPeer previous = primary;
for (RaftPeer peer : raftPeers) {
if (peer.equals(primary)) {
continue;
}
builder.addSuccessor(previous.getId(), peer.getId());
previous = peer;
}
return builder.build();
}
use of org.apache.ratis.protocol.RoutingTable in project incubator-ratis by apache.
the class FileStoreStreamingBaseTest method testFileStoreStreamMultipleFiles.
@Test
public void testFileStoreStreamMultipleFiles() throws Exception {
final CLUSTER cluster = newCluster(NUM_PEERS);
cluster.start();
RaftTestUtil.waitForLeader(cluster);
final RaftGroup raftGroup = cluster.getGroup();
final Collection<RaftPeer> peers = raftGroup.getPeers();
Assert.assertEquals(NUM_PEERS, peers.size());
RaftPeer primary = peers.iterator().next();
final CheckedSupplier<FileStoreClient, IOException> newClient = () -> new FileStoreClient(cluster.getGroup(), getProperties(), primary);
RoutingTable routingTable = DataStreamTestUtils.getRoutingTableChainTopology(peers, primary);
testMultipleFiles("foo", 5, SizeInBytes.valueOf("2M"), 10_000, newClient, routingTable);
testMultipleFiles("bar", 10, SizeInBytes.valueOf("2M"), 1000, newClient, routingTable);
cluster.shutdown();
}
Aggregations