Search in sources :

Example 1 with FailingReadsStore

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

the class RoutedStoreTest method testGetAllWithFailingStoreZZZ.

/**
     * Test to ensure that get all works in a 3 zone cluster with 2 nodes per
     * zone and 1 node down in each zone.
     */
@Test
public void testGetAllWithFailingStoreZZZ() throws Exception {
    cluster = VoldemortTestConstants.getSixNodeClusterWith3Zones();
    HashMap<Integer, Integer> zoneReplicationFactor = Maps.newHashMap();
    zoneReplicationFactor.put(0, cluster.getNumberOfNodesInZone(0));
    zoneReplicationFactor.put(1, cluster.getNumberOfNodesInZone(0));
    zoneReplicationFactor.put(2, cluster.getNumberOfNodesInZone(0));
    // PR = RR = 3
    // PW = RW = 6
    // Zone Reads = 2
    // Zone Writes = 2
    StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 3, 3, 6, 6, 2, 2, zoneReplicationFactor, HintedHandoffStrategyType.PROXIMITY_STRATEGY, RoutingStrategyType.ZONE_STRATEGY);
    Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
    for (int id = 0; id < 6; id++) {
        // other is normal
        if (id % 2 == 0) {
            subStores.put(id, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
        } else {
            subStores.put(id, new FailingReadsStore<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[]>());
    Map<ByteArray, byte[]> expectedValues = Maps.newHashMap();
    for (byte i = 1; i < 11; ++i) {
        ByteArray key = new ByteArray(new byte[] { i });
        byte[] value = new byte[] { (byte) (i + 50) };
        store.put(key, Versioned.value(value), null);
        expectedValues.put(key, value);
    }
    Map<ByteArray, List<Versioned<byte[]>>> all = store.getAll(expectedValues.keySet(), null);
    assertEquals(expectedValues.size(), all.size());
    for (Map.Entry<ByteArray, List<Versioned<byte[]>>> mapEntry : all.entrySet()) {
        byte[] value = expectedValues.get(mapEntry.getKey());
        assertEquals(new ByteArray(value), new ByteArray(mapEntry.getValue().get(0).getValue()));
    }
}
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) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) HashMap(java.util.HashMap) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 2 with FailingReadsStore

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

the class RoutedStoreTest method testGetAllWithFailingStore.

@Test
public void testGetAllWithFailingStore() throws Exception {
    cluster = VoldemortTestConstants.getTwoNodeCluster();
    StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 2, 1, 1, 2, 2, RoutingStrategyType.CONSISTENT_STRATEGY);
    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();
    subStores.put(id1, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
    subStores.put(id2, new FailingReadsStore<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[]>());
    Map<ByteArray, byte[]> expectedValues = Maps.newHashMap();
    for (byte i = 1; i < 11; ++i) {
        ByteArray key = new ByteArray(new byte[] { i });
        byte[] value = new byte[] { (byte) (i + 50) };
        store.put(key, Versioned.value(value), null);
        expectedValues.put(key, value);
    }
    Map<ByteArray, List<Versioned<byte[]>>> all = store.getAll(expectedValues.keySet(), null);
    assertEquals(expectedValues.size(), all.size());
    for (Map.Entry<ByteArray, List<Versioned<byte[]>>> mapEntry : all.entrySet()) {
        byte[] value = expectedValues.get(mapEntry.getKey());
        assertEquals(new ByteArray(value), new ByteArray(mapEntry.getValue().get(0).getValue()));
    }
}
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) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) HashMap(java.util.HashMap) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)2 FailingReadsStore (voldemort.store.FailingReadsStore)2 FailingStore (voldemort.store.FailingStore)2 SleepyStore (voldemort.store.SleepyStore)2 Store (voldemort.store.Store)2 StoreDefinition (voldemort.store.StoreDefinition)2 StatTrackingStore (voldemort.store.stats.StatTrackingStore)2 InconsistencyResolvingStore (voldemort.store.versioned.InconsistencyResolvingStore)2 ByteArray (voldemort.utils.ByteArray)2