Search in sources :

Example 1 with FailingStore

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

the class RoutedStoreTest method getStore.

private RoutedStore getStore(Cluster cluster, int reads, int writes, int threads, int failing, int sleepy, String strategy, VoldemortException e) throws Exception {
    Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
    int count = 0;
    for (Node n : cluster.getNodes()) {
        if (count >= cluster.getNumberOfNodes())
            throw new IllegalArgumentException(failing + " failing nodes, " + sleepy + " sleepy nodes, but only " + cluster.getNumberOfNodes() + " nodes in the cluster.");
        Store<ByteArray, byte[], byte[]> subStore = null;
        if (count < failing)
            subStore = new FailingStore<ByteArray, byte[], byte[]>("test", e);
        else if (count < failing + sleepy)
            subStore = new SleepyStore<ByteArray, byte[], byte[]>(Long.MAX_VALUE, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
        else
            subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
        subStores.put(n.getId(), subStore);
        count += 1;
    }
    setFailureDetector(subStores);
    this.storeDef = ServerTestUtils.getStoreDef("test", reads + writes, reads, reads, writes, writes, strategy);
    routedStoreThreadPool = Executors.newFixedThreadPool(threads);
    RoutedStoreFactory routedStoreFactory = createFactory();
    return routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(BANNAGE_PERIOD));
}
Also used : 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) FailingStore(voldemort.store.FailingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) ByteArray(voldemort.utils.ByteArray)

Example 2 with FailingStore

use of voldemort.store.FailingStore 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 3 with FailingStore

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

FailingReadsStore (voldemort.store.FailingReadsStore)3 FailingStore (voldemort.store.FailingStore)3 SleepyStore (voldemort.store.SleepyStore)3 Store (voldemort.store.Store)3 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)3 StatTrackingStore (voldemort.store.stats.StatTrackingStore)3 InconsistencyResolvingStore (voldemort.store.versioned.InconsistencyResolvingStore)3 ByteArray (voldemort.utils.ByteArray)3 Node (voldemort.cluster.Node)2 Test (org.junit.Test)1 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)1 StoreDefinition (voldemort.store.StoreDefinition)1