Search in sources :

Example 1 with Pipeline

use of voldemort.store.routed.Pipeline 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)

Example 2 with Pipeline

use of voldemort.store.routed.Pipeline in project voldemort by voldemort.

the class ConfigureNodesTest method testConfigureNodesWithZones.

@Test
public void testConfigureNodesWithZones() throws Exception {
    RoutingStrategy routingStrategy = new ZoneRoutingStrategy(clusterWithZones, storeDef.getZoneReplicationFactor(), storeDef.getReplicationFactor());
    BasicPipelineData<byte[]> pipelineData = new BasicPipelineData<byte[]>();
    Pipeline pipeline = new Pipeline(Operation.PUT, 10000, TimeUnit.MILLISECONDS);
    // PUT with changing zone id
    for (int clusterZoneId = 0; clusterZoneId < clusterWithZones.getNumberOfZones(); clusterZoneId++) {
        pipelineData.setZonesRequired(storeDef.getZoneCountWrites());
        pipeline.addEventAction(Event.STARTED, new ConfigureNodes<byte[], BasicPipelineData<byte[]>>(pipelineData, Event.COMPLETED, failureDetectorWithZones, storeDef.getRequiredReads(), routingStrategy, aKey, clusterWithZones.getZoneById(clusterZoneId)));
        pipeline.addEvent(Event.STARTED);
        pipeline.execute();
        List<Node> pipelineNodes = pipelineData.getNodes();
        int pipelineNodesIndex = 0;
        List<Integer> proximityList = clusterWithZones.getZoneById(clusterZoneId).getProximityList();
        // Check if returned list is as per the proximity list
        assertEquals(pipelineNodes.get(pipelineNodesIndex++).getZoneId(), clusterZoneId);
        for (; pipelineNodesIndex < pipelineNodes.size(); pipelineNodesIndex++) {
            assertEquals(proximityList.get(pipelineNodesIndex - 1), new Integer(pipelineNodes.get(pipelineNodesIndex).getZoneId()));
        }
    }
    // GET with changing zone requirements
    for (int zoneReq = 0; zoneReq < clusterWithZones.getNumberOfZones(); zoneReq++) {
        pipelineData = new BasicPipelineData<byte[]>();
        pipeline = new Pipeline(Operation.GET, 10000, TimeUnit.MILLISECONDS);
        pipelineData.setZonesRequired(zoneReq);
        pipeline.addEventAction(Event.STARTED, new ConfigureNodes<byte[], BasicPipelineData<byte[]>>(pipelineData, Event.COMPLETED, failureDetectorWithZones, storeDef.getRequiredReads(), routingStrategy, aKey, clusterWithZones.getZoneById(0)));
        pipeline.addEvent(Event.STARTED);
        pipeline.execute();
        // Check the first few nodes which are from different zones
        int zoneId = 1;
        for (int index = 0; index < zoneReq; index++) {
            assertEquals(pipelineData.getNodes().get(index).getZoneId(), zoneId++);
        }
    }
}
Also used : BasicPipelineData(voldemort.store.routed.BasicPipelineData) Node(voldemort.cluster.Node) RoutingStrategy(voldemort.routing.RoutingStrategy) ZoneRoutingStrategy(voldemort.routing.ZoneRoutingStrategy) ZoneRoutingStrategy(voldemort.routing.ZoneRoutingStrategy) Pipeline(voldemort.store.routed.Pipeline) Test(org.junit.Test)

Example 3 with Pipeline

use of voldemort.store.routed.Pipeline 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 4 with Pipeline

use of voldemort.store.routed.Pipeline 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)

Example 5 with Pipeline

use of voldemort.store.routed.Pipeline 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)

Aggregations

Test (org.junit.Test)6 RoutingStrategy (voldemort.routing.RoutingStrategy)6 Pipeline (voldemort.store.routed.Pipeline)6 Node (voldemort.cluster.Node)4 RouteToAllStrategy (voldemort.routing.RouteToAllStrategy)4 BasicPipelineData (voldemort.store.routed.BasicPipelineData)4 ZoneRoutingStrategy (voldemort.routing.ZoneRoutingStrategy)3 GetAllPipelineData (voldemort.store.routed.GetAllPipelineData)2 ArrayList (java.util.ArrayList)1 Cluster (voldemort.cluster.Cluster)1 FailureDetector (voldemort.cluster.failuredetector.FailureDetector)1 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)1 ThresholdFailureDetector (voldemort.cluster.failuredetector.ThresholdFailureDetector)1 RouteToAllLocalPrefStrategy (voldemort.routing.RouteToAllLocalPrefStrategy)1 UnreachableStoreException (voldemort.store.UnreachableStoreException)1 ByteArray (voldemort.utils.ByteArray)1