Search in sources :

Example 1 with HintedHandoffStrategy

use of voldemort.store.slop.strategy.HintedHandoffStrategy in project voldemort by voldemort.

the class HandoffToAnyStrategyTest method testRouteHint.

@Test
public void testRouteHint() {
    Cluster cluster = VoldemortTestConstants.getNineNodeCluster();
    HintedHandoffStrategy handoffStrategy = new HandoffToAnyStrategy(cluster, false, 0);
    for (Node origin : cluster.getNodes()) {
        List<Node> nodes = handoffStrategy.routeHint(origin);
        assertTrue("hint preflist is correctly sized", nodes.size() == cluster.getNumberOfNodes() - 1);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
    }
}
Also used : Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) HandoffToAnyStrategy(voldemort.store.slop.strategy.HandoffToAnyStrategy) HintedHandoffStrategy(voldemort.store.slop.strategy.HintedHandoffStrategy) Test(org.junit.Test)

Example 2 with HintedHandoffStrategy

use of voldemort.store.slop.strategy.HintedHandoffStrategy in project voldemort by voldemort.

the class HandoffToAnyStrategyTest method testRouteHintWithZones.

@Test
public void testRouteHintWithZones() {
    Cluster cluster = VoldemortTestConstants.getEightNodeClusterWithZones();
    HintedHandoffStrategy handoffStrategy0 = new HandoffToAnyStrategy(cluster, true, 0);
    HintedHandoffStrategy handoffStrategy1 = new HandoffToAnyStrategy(cluster, true, 1);
    List<Node> zone0Nodes = Lists.newArrayList();
    List<Node> zone1Nodes = Lists.newArrayList();
    for (int nodeId : ImmutableList.of(0, 1, 2, 3)) zone0Nodes.add(cluster.getNodeById(nodeId));
    for (int nodeId : ImmutableList.of(4, 5, 6, 7)) zone1Nodes.add(cluster.getNodeById(nodeId));
    for (Node origin : zone0Nodes) {
        List<Node> nodes = handoffStrategy0.routeHint(origin);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
        for (Node node : nodes) assertFalse("local hints not routed remotely", zone1Nodes.contains(node));
        nodes = handoffStrategy1.routeHint(origin);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
        for (Node node : nodes) assertTrue("remote hints routed locally", zone1Nodes.contains(node));
    }
    for (Node origin : zone1Nodes) {
        List<Node> nodes = handoffStrategy1.routeHint(origin);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
        for (Node node : nodes) assertFalse("local hints not routed remotely", zone0Nodes.contains(node));
        nodes = handoffStrategy0.routeHint(origin);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
        for (Node node : nodes) assertTrue("remote hints routed locally", zone0Nodes.contains(node));
    }
}
Also used : Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) HandoffToAnyStrategy(voldemort.store.slop.strategy.HandoffToAnyStrategy) HintedHandoffStrategy(voldemort.store.slop.strategy.HintedHandoffStrategy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Cluster (voldemort.cluster.Cluster)2 Node (voldemort.cluster.Node)2 HandoffToAnyStrategy (voldemort.store.slop.strategy.HandoffToAnyStrategy)2 HintedHandoffStrategy (voldemort.store.slop.strategy.HintedHandoffStrategy)2