use of voldemort.store.UnreachableStoreException in project voldemort by voldemort.
the class HttpStore method getAll.
@Override
public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys, Map<ByteArray, byte[]> transforms) throws VoldemortException {
StoreUtils.assertValidKeys(keys);
DataInputStream input = null;
try {
HttpPost method = new HttpPost(this.storeUrl);
ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
requestFormat.writeGetAllRequest(new DataOutputStream(outputBytes), getName(), keys, transforms, reroute);
input = executeRequest(method, outputBytes);
return requestFormat.readGetAllResponse(input);
} catch (IOException e) {
throw new UnreachableStoreException("Could not connect to " + storeUrl + " for " + getName(), e);
} finally {
IOUtils.closeQuietly(input);
}
}
use of voldemort.store.UnreachableStoreException in project voldemort by voldemort.
the class HttpStore method put.
@Override
public void put(ByteArray key, Versioned<byte[]> versioned, byte[] transforms) throws VoldemortException {
StoreUtils.assertValidKey(key);
DataInputStream input = null;
try {
HttpPost method = new HttpPost(this.storeUrl);
ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
requestFormat.writePutRequest(new DataOutputStream(outputBytes), getName(), key, versioned.getValue(), transforms, (VectorClock) versioned.getVersion(), reroute);
input = executeRequest(method, outputBytes);
requestFormat.readPutResponse(input);
} catch (IOException e) {
throw new UnreachableStoreException("Could not connect to " + storeUrl + " for " + getName(), e);
} finally {
IOUtils.closeQuietly(input);
}
}
use of voldemort.store.UnreachableStoreException in project voldemort by voldemort.
the class HintedHandoffFailureTest method customSetup.
/**
* Setup a cluster with 3 nodes, with the following characteristics:
*
* If FAILURE_MODE is FAIL_FIRST_REPLICA_NODE set the first replica store to
* a sleepy force failing store
*
* If FAILURE_MODE is FAIL_ALL_REPLICAS: set all replicas to sleepy force
* failing store
*
* Pseudo master : Standard In-memory store (wrapped by Logging store)
*
* In memory slop stores
*
* @param key The ByteArray representation of the key
* @param failureMode The Failure mode for the replicas
*
* @throws Exception
*/
public List<Integer> customSetup(ByteArray key, FAILURE_MODE failureMode, ReplicaFactor replicaFactor, long sleepTime, long hintDelayTimeMs) throws Exception {
cluster = getThreeNodeCluster();
storeDef = getStoreDef(STORE_NAME, replicaFactor, RoutingStrategyType.CONSISTENT_STRATEGY);
strategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
InMemoryStorageEngine<ByteArray, byte[], byte[]> inMemoryStorageEngine = new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME);
LoggingStore<ByteArray, byte[], byte[]> loggingStore = new LoggingStore<ByteArray, byte[], byte[]>(inMemoryStorageEngine);
VoldemortException e = new UnreachableStoreException("Node down");
ForceFailStore<ByteArray, byte[], byte[]> failureStore = new ForceFailStore<ByteArray, byte[], byte[]>(loggingStore, e);
SleepyStore<ByteArray, byte[], byte[]> sleepyFailureStore = new SleepyStore<ByteArray, byte[], byte[]>(sleepTime, failureStore);
failureStore.setFail(true);
List<Integer> failingNodeIdList = Lists.newArrayList();
List<Node> replicaList = strategy.routeRequest(key.get());
switch(failureMode) {
case FAIL_FIRST_REPLICA_NODE:
failingNodeIdList.add(replicaList.get(1).getId());
break;
case FAIL_ALL_REPLICAS:
for (int nodeId = 1; nodeId < replicaList.size(); nodeId++) {
failingNodeIdList.add(nodeId);
}
break;
}
subStores.clear();
for (int i = 0; i < NUM_NODES_TOTAL; i++) {
if (failingNodeIdList.contains(i)) {
subStores.put(i, sleepyFailureStore);
} else {
subStores.put(i, loggingStore);
}
}
setFailureDetector(subStores);
routedStoreThreadPool = Executors.newFixedThreadPool(NUM_THREADS);
routedStoreFactory = new RoutedStoreFactory(routedStoreThreadPool);
Map<Integer, NonblockingStore> nonblockingSlopStores = Maps.newHashMap();
for (Node node : cluster.getNodes()) {
int nodeId = node.getId();
SlopStorageEngine slopStorageEngine = new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>(SLOP_STORE_NAME), cluster);
StorageEngine<ByteArray, Slop, byte[]> storageEngine = slopStorageEngine.asSlopStore();
nonblockingSlopStores.put(nodeId, routedStoreFactory.toNonblockingStore(slopStorageEngine));
slopStores.put(nodeId, storageEngine);
}
Map<Integer, NonblockingStore> nonblockingStores = Maps.newHashMap();
for (Map.Entry<Integer, Store<ByteArray, byte[], byte[]>> entry : subStores.entrySet()) nonblockingStores.put(entry.getKey(), routedStoreFactory.toNonblockingStore(entry.getValue()));
store = new DelayedPutPipelineRoutedStore(subStores, nonblockingStores, slopStores, nonblockingSlopStores, cluster, storeDef, failureDetector, hintDelayTimeMs);
return failingNodeIdList;
}
use of voldemort.store.UnreachableStoreException in project voldemort by voldemort.
the class RoutedStoreTest method testOnlyNodeFailuresDisableNode.
@Test
public void testOnlyNodeFailuresDisableNode() throws Exception {
// test put
cluster = getNineNodeCluster();
Store<ByteArray, byte[], byte[]> s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
try {
s1.put(aKey, new Versioned<byte[]>(aValue), aTransform);
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(9);
cluster = getNineNodeCluster();
Store<ByteArray, byte[], byte[]> s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
try {
s2.put(aKey, new Versioned<byte[]>(aValue), aTransform);
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(0);
// test get
cluster = getNineNodeCluster();
s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
try {
s1.get(aKey, aTransform);
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(9);
cluster = getNineNodeCluster();
s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
try {
s2.get(aKey, aTransform);
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(0);
// test delete
cluster = getNineNodeCluster();
s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
try {
s1.delete(aKey, new VectorClock());
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(9);
cluster = getNineNodeCluster();
s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
try {
s2.delete(aKey, new VectorClock());
fail("Failure is expected");
} catch (InsufficientOperationalNodesException e) {
/* expected */
}
assertOperationalNodes(0);
}
use of voldemort.store.UnreachableStoreException in project voldemort by voldemort.
the class FailureDetectorTestUtils method recordException.
public static void recordException(FailureDetector failureDetector, Node node, long requestTime, UnreachableStoreException e) {
((MutableStoreConnectionVerifier) failureDetector.getConfig().getConnectionVerifier()).setErrorStore(node, new UnreachableStoreException("junit injected test error"));
failureDetector.recordException(node, requestTime, e);
}
Aggregations