Search in sources :

Example 21 with InMemoryStorageEngine

use of voldemort.store.memory.InMemoryStorageEngine in project voldemort by voldemort.

the class RoutedStoreTest method testTardyResponsesNotIncludedInResult.

@Test
public void testTardyResponsesNotIncludedInResult() throws Exception {
    cluster = VoldemortTestConstants.getThreeNodeCluster();
    StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 3, 3, 2, 3, 1, RoutingStrategyType.CONSISTENT_STRATEGY);
    int sleepTimeMs = 500;
    Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
    for (Node node : cluster.getNodes()) {
        Store<ByteArray, byte[], byte[]> store = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
        if (subStores.isEmpty()) {
            store = new SleepyStore<ByteArray, byte[], byte[]>(sleepTimeMs, store);
        }
        subStores.put(node.getId(), store);
    }
    setFailureDetector(subStores);
    routedStoreThreadPool = Executors.newFixedThreadPool(cluster.getNumberOfNodes());
    RoutedStoreFactory routedStoreFactory = createFactory();
    RoutedStore routedStore = routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(10000L));
    routedStore.put(aKey, Versioned.value(aValue), null);
    routedStoreFactory = createFactory();
    routedStore = routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(sleepTimeMs / 2));
    List<Versioned<byte[]>> versioneds = routedStore.get(aKey, null);
    assertEquals(2, versioneds.size());
    // Let's make sure that if the response *does* come in late, that it
    // doesn't alter the return value.
    Thread.sleep(sleepTimeMs * 2);
    assertEquals(2, versioneds.size());
}
Also used : Versioned(voldemort.versioning.Versioned) Node(voldemort.cluster.Node) Store(voldemort.store.Store) SleepyStore(voldemort.store.SleepyStore) StatTrackingStore(voldemort.store.stats.StatTrackingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) FailingStore(voldemort.store.FailingStore) FailingReadsStore(voldemort.store.FailingReadsStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 22 with InMemoryStorageEngine

use of voldemort.store.memory.InMemoryStorageEngine in project voldemort by voldemort.

the class RoutedStoreTest method testPutWithOneNodeDownAndOneNodeSlow.

/**
     * See issue #134: RoutedStore put() doesn't wait for enough attempts to
     * succeed
     * 
     * This issue would only happen with one node down and another that was slow
     * to respond.
     */
@Test
public void testPutWithOneNodeDownAndOneNodeSlow() throws Exception {
    cluster = VoldemortTestConstants.getThreeNodeCluster();
    StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 3, 2, 2, 2, 2, RoutingStrategyType.CONSISTENT_STRATEGY);
    /* The key used causes the nodes selected for writing to be [2, 0, 1] */
    Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
    int id1 = Iterables.get(cluster.getNodes(), 0).getId();
    int id2 = Iterables.get(cluster.getNodes(), 1).getId();
    int id3 = Iterables.get(cluster.getNodes(), 2).getId();
    subStores.put(id3, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
    subStores.put(id1, new FailingStore<ByteArray, byte[], byte[]>("test"));
    /*
         * The bug would only show itself if the second successful required
         * write was slow (but still within the timeout).
         */
    subStores.put(id2, new SleepyStore<ByteArray, byte[], byte[]>(100, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test")));
    setFailureDetector(subStores);
    routedStoreThreadPool = Executors.newFixedThreadPool(1);
    RoutedStoreFactory routedStoreFactory = createFactory();
    RoutedStore routedStore = routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(BANNAGE_PERIOD));
    Store<ByteArray, byte[], byte[]> store = new InconsistencyResolvingStore<ByteArray, byte[], byte[]>(routedStore, new VectorClockInconsistencyResolver<byte[]>());
    store.put(aKey, new Versioned<byte[]>(aValue), aTransform);
}
Also used : Store(voldemort.store.Store) SleepyStore(voldemort.store.SleepyStore) StatTrackingStore(voldemort.store.stats.StatTrackingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) FailingStore(voldemort.store.FailingStore) FailingReadsStore(voldemort.store.FailingReadsStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 23 with InMemoryStorageEngine

use of voldemort.store.memory.InMemoryStorageEngine in project voldemort by voldemort.

the class NioSelectorManagerTest method setUp.

@Before
public void setUp() throws IOException {
    this.port = ServerTestUtils.findFreePort();
    StoreRepository repository = new StoreRepository();
    sleepyStore = new SleepyStore<ByteArray, byte[], byte[]>(Long.MAX_VALUE, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
    repository.addLocalStore(sleepyStore);
    repository.addRoutedStore(sleepyStore);
    this.pool = new ClientRequestExecutorPool(50, 300, 250, 32 * 1024);
    this.dest1 = new SocketDestination("localhost", port, RequestFormatType.VOLDEMORT_V1);
    final Store<ByteArray, byte[], byte[]> socketStore = pool.create(STORE_NAME, "localhost", port, RequestFormatType.VOLDEMORT_V1, RequestRoutingType.NORMAL);
    factory = ServerTestUtils.getSocketRequestHandlerFactory(repository);
    socketService = ServerTestUtils.getSocketService(true, factory, port, numSelectors, 10, 1000, MAX_HEART_BEAT_MS);
    socketService.start();
}
Also used : InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) SocketDestination(voldemort.store.socket.SocketDestination) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) ByteArray(voldemort.utils.ByteArray) StoreRepository(voldemort.server.StoreRepository) Before(org.junit.Before)

Aggregations

InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)23 ByteArray (voldemort.utils.ByteArray)16 Store (voldemort.store.Store)12 StoreDefinition (voldemort.store.StoreDefinition)10 Node (voldemort.cluster.Node)9 SleepyStore (voldemort.store.SleepyStore)9 InconsistencyResolvingStore (voldemort.store.versioned.InconsistencyResolvingStore)9 StatTrackingStore (voldemort.store.stats.StatTrackingStore)8 Test (org.junit.Test)7 FailingReadsStore (voldemort.store.FailingReadsStore)7 FailingStore (voldemort.store.FailingStore)7 StoreRepository (voldemort.server.StoreRepository)6 Versioned (voldemort.versioning.Versioned)6 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)6 Cluster (voldemort.cluster.Cluster)4 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)4 ClusterMapper (voldemort.xml.ClusterMapper)4 StringReader (java.io.StringReader)3 Before (org.junit.Before)3 File (java.io.File)2