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);
}
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);
}
Aggregations