use of voldemort.cluster.failuredetector.AdminSlopStreamingVerifier 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);
}
Aggregations