Search in sources :

Example 1 with ThresholdFailureDetector

use of voldemort.cluster.failuredetector.ThresholdFailureDetector in project voldemort by voldemort.

the class StreamingSlopPusherTest method testPushForHostSwap.

/**
     * 
     * Procedure: 1. bring up 2-node cluster; 2. set up slop pusher job with the
     * cluster info; 3. replace node 1 by simply changing its port-ids, update
     * the cluster metadata to whole cluster; 4. run slop pusher job and it has
     * to fail; 5. setCluster in FD and the slop pusher job has to succeed
     * 
     * @throws InterruptedException
     * @throws IOException
     */
@Test
public void testPushForHostSwap() throws InterruptedException, IOException {
    startServers(0, 1);
    // Put into slop store 0
    StorageEngine<ByteArray, Slop, byte[]> slopStoreNode0 = getVoldemortServer(0).getStoreRepository().getSlopStore().asSlopStore();
    // Generate slops for 1
    final List<Versioned<Slop>> entrySet = ServerTestUtils.createRandomSlops(1, 100, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
    populateSlops(0, slopStoreNode0, entrySet);
    // replace node 1 and update metadata on all nodes
    replaceOneNode(1);
    Cluster oldCluster = cluster;
    // test if node 1 is down
    stopServersWithoutRemovingVoldemortHome(1);
    // slop should fail here
    new StreamingSlopPusherJob(getVoldemortServer(0).getStoreRepository(), getVoldemortServer(0).getMetadataStore(), new ThresholdFailureDetector(new FailureDetectorConfig().setCluster(oldCluster).setConnectionVerifier(new AdminSlopStreamingVerifier(oldCluster))), configs[0], new ScanPermitWrapper(1)).run();
    Thread.sleep(2000);
    assertFalse(verifySlopPushResult(entrySet, slopStoreNode0, 1));
    // test if node 1 is up
    startServers(1);
    // slop push should fail
    new StreamingSlopPusherJob(getVoldemortServer(0).getStoreRepository(), getVoldemortServer(0).getMetadataStore(), new ThresholdFailureDetector(new FailureDetectorConfig().setCluster(oldCluster).setConnectionVerifier(new AdminSlopStreamingVerifier(oldCluster))), configs[0], new ScanPermitWrapper(1)).run();
    Thread.sleep(2000);
    Assert.assertTrue(verifySlopPushResult(entrySet, slopStoreNode0, 1));
    // Check counts
    SlopStorageEngine slopEngine = getVoldemortServer(0).getStoreRepository().getSlopStore();
    assertEquals(slopEngine.getOutstandingTotal(), 0);
    assertEquals(slopEngine.getOutstandingByNode().get(1), new Long(0));
    assertEquals(slopEngine.getOutstandingByNode().get(2), new Long(0));
    stopServers(0, 1);
}
Also used : ThresholdFailureDetector(voldemort.cluster.failuredetector.ThresholdFailureDetector) Versioned(voldemort.versioning.Versioned) ScanPermitWrapper(voldemort.server.storage.ScanPermitWrapper) Cluster(voldemort.cluster.Cluster) StreamingSlopPusherJob(voldemort.server.scheduler.slop.StreamingSlopPusherJob) AdminSlopStreamingVerifier(voldemort.cluster.failuredetector.AdminSlopStreamingVerifier) FailureDetectorConfig(voldemort.cluster.failuredetector.FailureDetectorConfig) ByteArray(voldemort.utils.ByteArray) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) Slop(voldemort.store.slop.Slop) Test(org.junit.Test)

Example 2 with ThresholdFailureDetector

use of voldemort.cluster.failuredetector.ThresholdFailureDetector 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)2 Cluster (voldemort.cluster.Cluster)2 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)2 ThresholdFailureDetector (voldemort.cluster.failuredetector.ThresholdFailureDetector)2 Node (voldemort.cluster.Node)1 AdminSlopStreamingVerifier (voldemort.cluster.failuredetector.AdminSlopStreamingVerifier)1 FailureDetector (voldemort.cluster.failuredetector.FailureDetector)1 RouteToAllLocalPrefStrategy (voldemort.routing.RouteToAllLocalPrefStrategy)1 RoutingStrategy (voldemort.routing.RoutingStrategy)1 StreamingSlopPusherJob (voldemort.server.scheduler.slop.StreamingSlopPusherJob)1 ScanPermitWrapper (voldemort.server.storage.ScanPermitWrapper)1 BasicPipelineData (voldemort.store.routed.BasicPipelineData)1 Pipeline (voldemort.store.routed.Pipeline)1 Slop (voldemort.store.slop.Slop)1 SlopStorageEngine (voldemort.store.slop.SlopStorageEngine)1 ByteArray (voldemort.utils.ByteArray)1 Versioned (voldemort.versioning.Versioned)1