Search in sources :

Example 6 with BannagePeriodFailureDetector

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

the class StreamingSlopPusherTest method testNormalPush.

@Test
public void testNormalPush() 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);
    StreamingSlopPusherJob pusher = new StreamingSlopPusherJob(getVoldemortServer(0).getStoreRepository(), getVoldemortServer(0).getMetadataStore(), new BannagePeriodFailureDetector(new FailureDetectorConfig().setCluster(cluster).setConnectionVerifier(new ServerStoreConnectionVerifier(socketStoreFactory, metadataStore, configs[0]))), configs[0], new ScanPermitWrapper(1));
    pusher.run();
    // Give some time for the slops to go over
    Thread.sleep(2000);
    // Now check if the slops went through and also got deleted
    Iterator<Versioned<Slop>> entryIterator = entrySet.listIterator();
    while (entryIterator.hasNext()) {
        Versioned<Slop> versionedSlop = entryIterator.next();
        Slop nextSlop = versionedSlop.getValue();
        StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(1).getStoreRepository().getStorageEngine(nextSlop.getStoreName());
        if (nextSlop.getOperation().equals(Slop.Operation.PUT)) {
            assertNotSame("entry should be present at store", 0, store.get(nextSlop.getKey(), null).size());
            assertEquals("entry value should match", new String(nextSlop.getValue()), new String(store.get(nextSlop.getKey(), null).get(0).getValue()));
        } else if (nextSlop.getOperation().equals(Slop.Operation.DELETE)) {
            assertEquals("entry value should match", 0, store.get(nextSlop.getKey(), null).size());
        }
        // did it get deleted correctly
        assertEquals("slop should have gone", 0, slopStoreNode0.get(nextSlop.makeKey(), null).size());
    }
    // 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 : Versioned(voldemort.versioning.Versioned) ScanPermitWrapper(voldemort.server.storage.ScanPermitWrapper) StreamingSlopPusherJob(voldemort.server.scheduler.slop.StreamingSlopPusherJob) FailureDetectorConfig(voldemort.cluster.failuredetector.FailureDetectorConfig) ByteArray(voldemort.utils.ByteArray) ServerStoreConnectionVerifier(voldemort.cluster.failuredetector.ServerStoreConnectionVerifier) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) Slop(voldemort.store.slop.Slop) BannagePeriodFailureDetector(voldemort.cluster.failuredetector.BannagePeriodFailureDetector) Test(org.junit.Test)

Aggregations

BannagePeriodFailureDetector (voldemort.cluster.failuredetector.BannagePeriodFailureDetector)6 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)6 Test (org.junit.Test)5 ServerStoreConnectionVerifier (voldemort.cluster.failuredetector.ServerStoreConnectionVerifier)5 StreamingSlopPusherJob (voldemort.server.scheduler.slop.StreamingSlopPusherJob)5 ScanPermitWrapper (voldemort.server.storage.ScanPermitWrapper)5 Slop (voldemort.store.slop.Slop)5 ByteArray (voldemort.utils.ByteArray)5 Versioned (voldemort.versioning.Versioned)5 SlopStorageEngine (voldemort.store.slop.SlopStorageEngine)4 StringReader (java.io.StringReader)1 Date (java.util.Date)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 VectorClock (voldemort.versioning.VectorClock)1 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)1