Search in sources :

Example 1 with RoutingTable

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();
}
Also used : RoutingTable(org.apache.ratis.protocol.RoutingTable) RaftPeerId(org.apache.ratis.protocol.RaftPeerId)

Example 2 with RoutingTable

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);
}
Also used : RoutingTable(org.apache.ratis.protocol.RoutingTable) ExecutorService(java.util.concurrent.ExecutorService)

Example 3 with RoutingTable

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();
}
Also used : RoutingTable(org.apache.ratis.protocol.RoutingTable) RaftGroup(org.apache.ratis.protocol.RaftGroup) IOException(java.io.IOException) RaftPeer(org.apache.ratis.protocol.RaftPeer) Test(org.junit.Test) BaseTest(org.apache.ratis.BaseTest)

Example 4 with RoutingTable

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();
}
Also used : RoutingTable(org.apache.ratis.protocol.RoutingTable) RaftPeer(org.apache.ratis.protocol.RaftPeer)

Example 5 with RoutingTable

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();
}
Also used : RoutingTable(org.apache.ratis.protocol.RoutingTable) RaftGroup(org.apache.ratis.protocol.RaftGroup) IOException(java.io.IOException) RaftPeer(org.apache.ratis.protocol.RaftPeer) Test(org.junit.Test) BaseTest(org.apache.ratis.BaseTest)

Aggregations

RoutingTable (org.apache.ratis.protocol.RoutingTable)5 RaftPeer (org.apache.ratis.protocol.RaftPeer)3 IOException (java.io.IOException)2 BaseTest (org.apache.ratis.BaseTest)2 RaftGroup (org.apache.ratis.protocol.RaftGroup)2 Test (org.junit.Test)2 ExecutorService (java.util.concurrent.ExecutorService)1 RaftPeerId (org.apache.ratis.protocol.RaftPeerId)1