Search in sources :

Example 11 with SlopStorageEngine

use of voldemort.store.slop.SlopStorageEngine in project voldemort by voldemort.

the class DataCleanupJobTest method setUp.

@Before
public void setUp() throws Exception {
    time = new MockTime();
    storeDir = TestUtils.createTempDir();
    FileDeleteStrategy.FORCE.delete(storeDir);
    // lets use all the default values.
    Props props = new Props();
    props.put("node.id", 1);
    props.put("voldemort.home", "test/common/voldemort/config");
    VoldemortConfig voldemortConfig = new VoldemortConfig(props);
    voldemortConfig.setBdbCacheSize(1024 * 1024);
    voldemortConfig.setBdbOneEnvPerStore(true);
    voldemortConfig.setBdbDataDirectory(storeDir.toURI().getPath());
    voldemortConfig.setBdbPrefixKeysWithPartitionId(prefixPartitionId);
    bdbStorage = new BdbStorageConfiguration(voldemortConfig);
    StoreDefinition storeDef = getStoreDef(START_RETENTION);
    engine = bdbStorage.getStore(storeDef, TestUtils.makeSingleNodeRoutingStrategy());
    List<Node> nodes = Lists.newArrayList();
    nodes.add(new Node(0, "test-host", 1234, 1235, 1236, Arrays.asList(0)));
    Cluster cluster = new Cluster("cluster", nodes);
    StoreRepository repo = new StoreRepository();
    repo.setSlopStore(new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>("slop"), cluster));
    repo.addNodeStore(0, engine);
    metadataStore = ServerTestUtils.createMetadataStore(cluster, Arrays.asList(storeDef));
}
Also used : InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinition(voldemort.store.StoreDefinition) Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) StoreRepository(voldemort.server.StoreRepository) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) Props(voldemort.utils.Props) BdbStorageConfiguration(voldemort.store.bdb.BdbStorageConfiguration) MockTime(voldemort.MockTime) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Example 12 with SlopStorageEngine

use of voldemort.store.slop.SlopStorageEngine 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)

Example 13 with SlopStorageEngine

use of voldemort.store.slop.SlopStorageEngine in project voldemort by voldemort.

the class StreamingSlopPusherTest method testFailedServer.

@Test
public void testFailedServer() throws IOException, InterruptedException {
    startServers(0, 2);
    // Put into slop store 0
    StorageEngine<ByteArray, Slop, byte[]> slopStoreNode0 = getVoldemortServer(0).getStoreRepository().getSlopStore().asSlopStore();
    // Generate slops for 1
    final List<Versioned<Slop>> entrySet1 = ServerTestUtils.createRandomSlops(1, 50, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
    // Generate slops for 2
    final List<Versioned<Slop>> entrySet2 = ServerTestUtils.createRandomSlops(2, 50, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
    populateSlops(0, slopStoreNode0, entrySet1, entrySet2);
    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 = entrySet2.listIterator();
    while (entryIterator.hasNext()) {
        Versioned<Slop> versionedSlop = entryIterator.next();
        Slop nextSlop = versionedSlop.getValue();
        StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(2).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());
    }
    entryIterator = entrySet1.listIterator();
    while (entryIterator.hasNext()) {
        Versioned<Slop> versionedSlop = entryIterator.next();
        Slop nextSlop = versionedSlop.getValue();
        // did it get deleted correctly
        assertNotSame("slop should be there", 0, slopStoreNode0.get(nextSlop.makeKey(), null).size());
    }
    // Check counts
    SlopStorageEngine slopEngine = getVoldemortServer(0).getStoreRepository().getSlopStore();
    assertEquals(slopEngine.getOutstandingTotal(), 50);
    assertEquals(slopEngine.getOutstandingByNode().get(1), new Long(50));
    assertEquals(slopEngine.getOutstandingByNode().get(2), new Long(0));
    stopServers(0, 2);
}
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

SlopStorageEngine (voldemort.store.slop.SlopStorageEngine)13 ByteArray (voldemort.utils.ByteArray)11 Slop (voldemort.store.slop.Slop)9 Versioned (voldemort.versioning.Versioned)8 StreamingSlopPusherJob (voldemort.server.scheduler.slop.StreamingSlopPusherJob)6 ScanPermitWrapper (voldemort.server.storage.ScanPermitWrapper)6 Test (org.junit.Test)5 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)5 Cluster (voldemort.cluster.Cluster)4 Node (voldemort.cluster.Node)4 BannagePeriodFailureDetector (voldemort.cluster.failuredetector.BannagePeriodFailureDetector)4 ServerStoreConnectionVerifier (voldemort.cluster.failuredetector.ServerStoreConnectionVerifier)4 Date (java.util.Date)3 UnreachableStoreException (voldemort.store.UnreachableStoreException)3 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)3 VoldemortException (voldemort.VoldemortException)2 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)2 StoreRepository (voldemort.server.StoreRepository)2 VoldemortConfig (voldemort.server.VoldemortConfig)2 BlockingSlopPusherJob (voldemort.server.scheduler.slop.BlockingSlopPusherJob)2