Search in sources :

Example 1 with RouteToAllLocalPrefStrategy

use of voldemort.routing.RouteToAllLocalPrefStrategy in project voldemort by voldemort.

the class ConfigureNodesLocalHostTest method testConfigureNodesLocalHost.

/*
     * Checks to see that the local host is obtained as the first node in the
     * list returned by ConfigureNodesLocalHost
     */
@Test
public void testConfigureNodesLocalHost() throws Exception {
    List<Node> nodes = getTestNodes();
    Cluster cluster = new Cluster("test-route-all-local-pref-cluster", nodes);
    FailureDetector failureDetector = new ThresholdFailureDetector(new FailureDetectorConfig().setCluster(cluster));
    RoutingStrategy routingStrategy = new RouteToAllLocalPrefStrategy(cluster.getNodesShuffled());
    BasicPipelineData<byte[]> pipelineData = new BasicPipelineData<byte[]>();
    ConfigureNodesLocalHost<byte[], BasicPipelineData<byte[]>> action = new ConfigureNodesLocalHost<byte[], BasicPipelineData<byte[]>>(pipelineData, Event.COMPLETED, failureDetector, 1, routingStrategy, aKey);
    Pipeline pipeline = new Pipeline(Operation.GET, 10000, TimeUnit.MILLISECONDS);
    pipeline.addEventAction(Event.STARTED, action);
    pipeline.addEvent(Event.STARTED);
    pipeline.execute();
    if (pipelineData.getFatalError() != null)
        throw pipelineData.getFatalError();
    assertEquals(cluster.getNodes().size(), pipelineData.getNodes().size());
    assertEquals(cluster.getNodesShuffled().size(), pipelineData.getNodes().size());
    assertEquals(pipelineData.getNodes().get(0).getHost(), currentHost);
}
Also used : ThresholdFailureDetector(voldemort.cluster.failuredetector.ThresholdFailureDetector) Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) Pipeline(voldemort.store.routed.Pipeline) BasicPipelineData(voldemort.store.routed.BasicPipelineData) ThresholdFailureDetector(voldemort.cluster.failuredetector.ThresholdFailureDetector) FailureDetector(voldemort.cluster.failuredetector.FailureDetector) FailureDetectorConfig(voldemort.cluster.failuredetector.FailureDetectorConfig) RoutingStrategy(voldemort.routing.RoutingStrategy) RouteToAllLocalPrefStrategy(voldemort.routing.RouteToAllLocalPrefStrategy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Cluster (voldemort.cluster.Cluster)1 Node (voldemort.cluster.Node)1 FailureDetector (voldemort.cluster.failuredetector.FailureDetector)1 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)1 ThresholdFailureDetector (voldemort.cluster.failuredetector.ThresholdFailureDetector)1 RouteToAllLocalPrefStrategy (voldemort.routing.RouteToAllLocalPrefStrategy)1 RoutingStrategy (voldemort.routing.RoutingStrategy)1 BasicPipelineData (voldemort.store.routed.BasicPipelineData)1 Pipeline (voldemort.store.routed.Pipeline)1