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());
}
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);
}
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();
}
Aggregations