Search in sources :

Example 11 with SleepyStore

use of voldemort.store.SleepyStore in project voldemort by voldemort.

the class RoutedStoreTest method testSlowStoreDowngradesFromPreferredToRequired.

@Test
public void testSlowStoreDowngradesFromPreferredToRequired() 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());
}
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 12 with SleepyStore

use of voldemort.store.SleepyStore in project voldemort by voldemort.

the class RoutedStoreTest method testOperationSpecificTimeouts.

@Test
public void testOperationSpecificTimeouts() throws Exception {
    StoreDefinition definition = new StoreDefinitionBuilder().setName("test").setType("foo").setKeySerializer(new SerializerDefinition("test")).setValueSerializer(new SerializerDefinition("test")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(3).setPreferredReads(3).setRequiredReads(3).setPreferredWrites(3).setRequiredWrites(3).build();
    Map<Integer, Store<ByteArray, byte[], byte[]>> stores = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
    List<Node> nodes = new ArrayList<Node>();
    for (int i = 0; i < 3; i++) {
        Store<ByteArray, byte[], byte[]> store = new SleepyStore<ByteArray, byte[], byte[]>(200, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
        stores.put(i, store);
        List<Integer> partitions = Arrays.asList(i);
        nodes.add(new Node(i, "none", 0, 0, 0, partitions));
    }
    setFailureDetector(stores);
    routedStoreThreadPool = Executors.newFixedThreadPool(3);
    // with a 500ms general timeout and a 100ms get timeout, only get should
    // fail
    TimeoutConfig timeoutConfig = new TimeoutConfig(1500, false);
    timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_OP_CODE, 100);
    RoutedStoreFactory routedStoreFactory = createFactory();
    RoutedStore routedStore = routedStoreFactory.create(new Cluster("test", nodes), definition, stores, failureDetector, createConfig(timeoutConfig));
    try {
        routedStore.put(new ByteArray("test".getBytes()), new Versioned<byte[]>(new byte[] { 1 }), null);
    } catch (InsufficientOperationalNodesException e) {
        fail("Should not have failed");
    }
    try {
        routedStore.get(new ByteArray("test".getBytes()), null);
        fail("Should have thrown");
    } catch (InsufficientOperationalNodesException e) {
    }
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) TimeoutConfig(voldemort.client.TimeoutConfig) HashMap(java.util.HashMap) Node(voldemort.cluster.Node) ArrayList(java.util.ArrayList) 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) VoldemortTestConstants.getNineNodeCluster(voldemort.VoldemortTestConstants.getNineNodeCluster) Cluster(voldemort.cluster.Cluster) SleepyStore(voldemort.store.SleepyStore) StoreDefinition(voldemort.store.StoreDefinition) InsufficientOperationalNodesException(voldemort.store.InsufficientOperationalNodesException) ByteArray(voldemort.utils.ByteArray) SerializerDefinition(voldemort.serialization.SerializerDefinition) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 13 with SleepyStore

use of voldemort.store.SleepyStore in project voldemort by voldemort.

the class RoutedStoreTest method getStore.

private RoutedStore getStore(Cluster cluster, int reads, int writes, int zonereads, int zonewrites, int threads, Set<Integer> failing, Set<Integer> sleepy, HashMap<Integer, Integer> zoneReplicationFactor, String strategy, long sleepMs, long timeOutMs, VoldemortException e) throws Exception {
    Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
    for (Node n : cluster.getNodes()) {
        Store<ByteArray, byte[], byte[]> subStore = null;
        if (failing != null && failing.contains(n.getId()))
            subStore = new FailingStore<ByteArray, byte[], byte[]>("test", e);
        else if (sleepy != null && sleepy.contains(n.getId()))
            subStore = new SleepyStore<ByteArray, byte[], byte[]>(sleepMs, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
        else
            subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
        subStores.put(n.getId(), subStore);
    }
    setFailureDetector(subStores);
    this.storeDef = ServerTestUtils.getStoreDef("test", reads, reads, writes, writes, zonereads, zonewrites, zoneReplicationFactor, HintedHandoffStrategyType.PROXIMITY_STRATEGY, strategy);
    routedStoreThreadPool = Executors.newFixedThreadPool(threads);
    RoutedStoreFactory routedStoreFactory = createFactory();
    return routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(timeOutMs));
}
Also used : FailingStore(voldemort.store.FailingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) 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) ByteArray(voldemort.utils.ByteArray)

Example 14 with SleepyStore

use of voldemort.store.SleepyStore 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 15 with SleepyStore

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

Aggregations

SleepyStore (voldemort.store.SleepyStore)15 ByteArray (voldemort.utils.ByteArray)15 Store (voldemort.store.Store)14 Node (voldemort.cluster.Node)13 FailingReadsStore (voldemort.store.FailingReadsStore)12 FailingStore (voldemort.store.FailingStore)12 StatTrackingStore (voldemort.store.stats.StatTrackingStore)12 InconsistencyResolvingStore (voldemort.store.versioned.InconsistencyResolvingStore)12 StoreDefinition (voldemort.store.StoreDefinition)11 Test (org.junit.Test)10 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)10 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)8 HashMap (java.util.HashMap)7 Cluster (voldemort.cluster.Cluster)7 ArrayList (java.util.ArrayList)6 VoldemortTestConstants.getNineNodeCluster (voldemort.VoldemortTestConstants.getNineNodeCluster)6 SerializerDefinition (voldemort.serialization.SerializerDefinition)6 InsufficientOperationalNodesException (voldemort.store.InsufficientOperationalNodesException)6 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)6 VoldemortException (voldemort.VoldemortException)4