use of voldemort.client.TimeoutConfig in project voldemort by voldemort.
the class GetallNodeReachTest method makeStore.
private void makeStore() {
subStores = Maps.newHashMap();
for (Node n : cluster.getNodes()) {
Store<ByteArray, byte[], byte[]> subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
subStores.put(n.getId(), subStore);
}
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(Executors.newFixedThreadPool(2));
store = routedStoreFactory.create(cluster, storeDef, subStores, new NoopFailureDetector(), new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1000L)));
}
use of voldemort.client.TimeoutConfig in project voldemort by voldemort.
the class HintedHandoffSendHintTest method setUp.
@Before
public void setUp() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Test Started: replication[" + REPLICATION_FACTOR + "], preferredW[" + P_WRITES + "], requiredW[" + R_WRITES + "]");
}
cluster = getNineNodeCluster();
storeDef = getStoreDef();
// create voldemort servers
for (Integer nodeId = 0; nodeId < NUM_NODES_TOTAL; nodeId++) {
SocketStoreFactory socketStoreFactory;
socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
stores.add(storeDef);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
config.setNioAdminConnectorSelectors(1);
config.setNioConnectorSelectors(2);
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
VoldemortService vsrv = vs.getService(ServiceType.STORAGE);
StorageService ss = (StorageService) vsrv;
voldemortServers.put(nodeId, vs);
slopStorageEngines.put(nodeId, ss.getStoreRepository().getSlopStore());
slopStores.put(nodeId, SerializingStore.wrap(ss.getStoreRepository().getSlopStore(), new ByteArraySerializer(), new SlopSerializer(), new IdentitySerializer()));
// wrap original store with force fail store
Store<ByteArray, byte[], byte[]> store = ss.getStoreRepository().removeLocalStore(STORE_NAME);
UnreachableStoreException exception = new UnreachableStoreException("Force failed");
ForceFailStore<ByteArray, byte[], byte[]> forceFailStore = new ForceFailStore<ByteArray, byte[], byte[]>(store, exception);
forceFailStores.put(nodeId, forceFailStore);
ss.getStoreRepository().addLocalStore(forceFailStore);
}
strategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
// create client socket stores and slop stores
SocketStoreClientFactoryForTest clientSocketStoreFactory = new SocketStoreClientFactoryForTest(STORE_NAME, SLOP_STORE_NAME);
Serializer<ByteArray> slopKeySerializer = new ByteArraySerializer();
Serializer<Slop> slopValueSerializer = new SlopSerializer();
Map<Integer, Store<ByteArray, byte[], byte[]>> testStores = subStores;
Map<Integer, Store<ByteArray, Slop, byte[]>> slopStores = new HashMap<Integer, Store<ByteArray, Slop, byte[]>>();
for (Node node : cluster.getNodes()) {
// test store
SocketStore socketTestStore = clientSocketStoreFactory.getSocketTestStoreByNode(node);
socketTestStores.put(node.getId(), socketTestStore);
testStores.put(node.getId(), socketTestStore);
// slop store
SocketStore socketSlopStore = clientSocketStoreFactory.getSocketSlopStoreByNode(node);
Store<ByteArray, Slop, byte[]> slopStore = SerializingStore.wrap(socketSlopStore, slopKeySerializer, slopValueSerializer, new IdentitySerializer());
socketSlopStores.put(node.getId(), socketSlopStore);
slopStores.put(node.getId(), slopStore);
}
// set failure detector
if (failureDetector != null)
failureDetector.destroy();
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig();
failureDetectorConfig.setImplementationClassName(failureDetectorCls.getName());
failureDetectorConfig.setThreshold(50);
failureDetectorConfig.setCluster(cluster);
failureDetectorConfig.setConnectionVerifier(MutableStoreConnectionVerifier.create(subStores));
failureDetector = FailureDetectorUtils.create(failureDetectorConfig, false);
// make routedStore
RoutedStoreFactory factory = new RoutedStoreFactory();
routedStore = factory.create(cluster, storeDef, testStores, socketTestStores, slopStores, socketSlopStores, failureDetector, new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1500L, false)));
// generate the keys
for (int i = 0; i < 5; i++) {
Set<Integer> nodesCovered = Sets.newHashSet();
while (nodesCovered.size() < NUM_NODES_TOTAL) {
ByteArray randomKey = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
byte[] randomValue = TestUtils.randomBytes(VALUE_LENGTH);
if (randomKey.length() > 0 && randomValue.length > 0) {
if (!keyList.contains(randomKey)) {
for (Node node : strategy.routeRequest(randomKey.get())) {
keysToNodes.put(randomKey, node.getId());
nodesCovered.add(node.getId());
}
logger.info("Inserting key [" + randomKey + "] to key list as id:" + keyList.size());
keyList.add(randomKey);
keyValues.put(randomKey, new ByteArray(randomValue));
}
}
}
}
}
use of voldemort.client.TimeoutConfig in project voldemort by voldemort.
the class ReadRepairerTest method testMissingKeysAreAddedToNodeWhenDoingReadRepair.
/**
* See Issue 150: Missing keys are not added to node when performing
* read-repair
*/
@Test
public void testMissingKeysAreAddedToNodeWhenDoingReadRepair() throws Exception {
ByteArray key = TestUtils.toByteArray("key");
byte[] value = "foo".getBytes();
Cluster cluster = VoldemortTestConstants.getThreeNodeCluster();
StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 3, 3, 3, 2, 2, RoutingStrategyType.CONSISTENT_STRATEGY);
Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
for (int a = 0; a < 3; a++) {
int id = Iterables.get(cluster.getNodes(), a).getId();
InMemoryStorageEngine<ByteArray, byte[], byte[]> subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
subStores.put(id, subStore);
}
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig().setImplementationClassName(failureDetectorClass.getName()).setBannagePeriod(1000).setCluster(cluster).setConnectionVerifier(create(subStores)).setTime(time);
failureDetector = create(failureDetectorConfig, false);
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(routedStoreThreadPool);
RoutedStore store = routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1000L, false)));
recordException(failureDetector, Iterables.get(cluster.getNodes(), 0));
store.put(key, new Versioned<byte[]>(value), null);
recordSuccess(failureDetector, Iterables.get(cluster.getNodes(), 0));
time.sleep(2000);
assertEquals(2, store.get(key, null).size());
// Last get should have repaired the missing key from node 0 so all
// stores should now return a value
assertEquals(3, store.get(key, null).size());
ByteArray anotherKey = TestUtils.toByteArray("anotherKey");
// Try again, now use getAll to read repair
recordException(failureDetector, Iterables.get(cluster.getNodes(), 0));
store.put(anotherKey, new Versioned<byte[]>(value), null);
recordSuccess(failureDetector, Iterables.get(cluster.getNodes(), 0));
assertEquals(2, store.getAll(Arrays.asList(anotherKey), null).get(anotherKey).size());
assertEquals(3, store.get(anotherKey, null).size());
}
use of voldemort.client.TimeoutConfig 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) {
}
}
Aggregations