Search in sources :

Example 1 with RouteToAllStrategy

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

the class GetAllConfigureNodesTest method testConfigureNodes.

@Test
public void testConfigureNodes() throws Exception {
    RoutingStrategy routingStrategy = new RouteToAllStrategy(cluster.getNodesShuffled());
    GetAllPipelineData pipelineData = new GetAllPipelineData();
    List<ByteArray> keys = new ArrayList<ByteArray>();
    for (int i = 0; i < 10; i++) keys.add(TestUtils.toByteArray("key-" + i));
    int preferred = cluster.getNumberOfNodes() - 1;
    GetAllConfigureNodes action = new GetAllConfigureNodes(pipelineData, Event.COMPLETED, failureDetector, preferred, preferred - 1, routingStrategy, keys, null, null, null);
    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();
    for (ByteArray key : keys) {
        List<Node> allNodesList = routingStrategy.routeRequest(key.get());
        assertEquals(cluster.getNumberOfNodes(), allNodesList.size());
        List<Node> extraNodes = pipelineData.getKeyToExtraNodesMap().get(key);
        assertEquals(cluster.getNumberOfNodes() - preferred, extraNodes.size());
        Node expectedExtraNode = allNodesList.get(preferred);
        Node actualExtraNode = extraNodes.get(0);
        assertEquals(expectedExtraNode, actualExtraNode);
        List<Node> preferredNodes = allNodesList.subList(0, preferred);
        assertEquals(preferred, preferredNodes.size());
        for (Node node : preferredNodes) {
            List<ByteArray> nodeKeys = pipelineData.getNodeToKeysMap().get(node);
            if (!nodeKeys.contains(key))
                fail();
        }
    }
}
Also used : RouteToAllStrategy(voldemort.routing.RouteToAllStrategy) GetAllPipelineData(voldemort.store.routed.GetAllPipelineData) Node(voldemort.cluster.Node) RoutingStrategy(voldemort.routing.RoutingStrategy) ArrayList(java.util.ArrayList) ByteArray(voldemort.utils.ByteArray) Pipeline(voldemort.store.routed.Pipeline) Test(org.junit.Test)

Example 2 with RouteToAllStrategy

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

the class MetadataStore method createRoutingStrategyMap.

private HashMap<String, RoutingStrategy> createRoutingStrategyMap(Cluster cluster, HashMap<String, StoreDefinition> storeDefs) {
    HashMap<String, RoutingStrategy> map = new HashMap<String, RoutingStrategy>();
    for (StoreDefinition store : storeDefs.values()) {
        map.put(store.getName(), routingFactory.updateRoutingStrategy(store, cluster));
    }
    // add metadata Store route to ALL routing strategy.
    map.put(METADATA_STORE_NAME, new RouteToAllStrategy(getCluster().getNodesShuffled()));
    return map;
}
Also used : RouteToAllStrategy(voldemort.routing.RouteToAllStrategy) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoreDefinition(voldemort.store.StoreDefinition) RoutingStrategy(voldemort.routing.RoutingStrategy)

Example 3 with RouteToAllStrategy

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

the class GetAllConfigureNodesTest method testConfigureNodesNotEnoughNodes.

@Test(expected = InsufficientOperationalNodesException.class)
public void testConfigureNodesNotEnoughNodes() throws Exception {
    for (Node node : cluster.getNodes()) failureDetector.recordException(node, 0, new UnreachableStoreException("Test for " + getClass().getName()));
    RoutingStrategy routingStrategy = new RouteToAllStrategy(cluster.getNodesShuffled());
    GetAllPipelineData pipelineData = new GetAllPipelineData();
    GetAllConfigureNodes action = new GetAllConfigureNodes(pipelineData, Event.COMPLETED, failureDetector, 1, 1, routingStrategy, Arrays.asList(aKey), null, null, null);
    Pipeline pipeline = new Pipeline(Operation.GET, 10000, TimeUnit.MILLISECONDS);
    pipeline.addEventAction(Event.STARTED, action);
    pipeline.addEvent(Event.STARTED);
    pipeline.execute();
    throw pipelineData.getFatalError();
}
Also used : RouteToAllStrategy(voldemort.routing.RouteToAllStrategy) GetAllPipelineData(voldemort.store.routed.GetAllPipelineData) Node(voldemort.cluster.Node) RoutingStrategy(voldemort.routing.RoutingStrategy) UnreachableStoreException(voldemort.store.UnreachableStoreException) Pipeline(voldemort.store.routed.Pipeline) Test(org.junit.Test)

Example 4 with RouteToAllStrategy

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

the class ConfigureNodesTest method testConfigureNodes.

@Test
public void testConfigureNodes() throws Exception {
    RoutingStrategy routingStrategy = new RouteToAllStrategy(cluster.getNodesShuffled());
    BasicPipelineData<byte[]> pipelineData = new BasicPipelineData<byte[]>();
    ConfigureNodes<byte[], BasicPipelineData<byte[]>> action = new ConfigureNodes<byte[], BasicPipelineData<byte[]>>(pipelineData, Event.COMPLETED, failureDetector, 1, routingStrategy, aKey, null);
    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());
}
Also used : BasicPipelineData(voldemort.store.routed.BasicPipelineData) RouteToAllStrategy(voldemort.routing.RouteToAllStrategy) RoutingStrategy(voldemort.routing.RoutingStrategy) ZoneRoutingStrategy(voldemort.routing.ZoneRoutingStrategy) Pipeline(voldemort.store.routed.Pipeline) Test(org.junit.Test)

Example 5 with RouteToAllStrategy

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

the class ConfigureNodesTest method testConfigureNodesNotEnoughNodes.

@Test(expected = InsufficientOperationalNodesException.class)
public void testConfigureNodesNotEnoughNodes() throws Exception {
    RoutingStrategy routingStrategy = new RouteToAllStrategy(cluster.getNodesShuffled());
    BasicPipelineData<byte[]> pipelineData = new BasicPipelineData<byte[]>();
    ConfigureNodes<byte[], BasicPipelineData<byte[]>> action = new ConfigureNodes<byte[], BasicPipelineData<byte[]>>(pipelineData, Event.COMPLETED, failureDetector, cluster.getNodes().size() + 1, routingStrategy, aKey, null);
    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();
    else
        fail();
}
Also used : BasicPipelineData(voldemort.store.routed.BasicPipelineData) RouteToAllStrategy(voldemort.routing.RouteToAllStrategy) RoutingStrategy(voldemort.routing.RoutingStrategy) ZoneRoutingStrategy(voldemort.routing.ZoneRoutingStrategy) Pipeline(voldemort.store.routed.Pipeline) Test(org.junit.Test)

Aggregations

RouteToAllStrategy (voldemort.routing.RouteToAllStrategy)5 RoutingStrategy (voldemort.routing.RoutingStrategy)5 Test (org.junit.Test)4 Pipeline (voldemort.store.routed.Pipeline)4 Node (voldemort.cluster.Node)2 ZoneRoutingStrategy (voldemort.routing.ZoneRoutingStrategy)2 BasicPipelineData (voldemort.store.routed.BasicPipelineData)2 GetAllPipelineData (voldemort.store.routed.GetAllPipelineData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 StoreDefinition (voldemort.store.StoreDefinition)1 UnreachableStoreException (voldemort.store.UnreachableStoreException)1 ByteArray (voldemort.utils.ByteArray)1