use of voldemort.store.InsufficientZoneResponsesException in project voldemort by voldemort.
the class RoutedStoreTest method testBasicOperationsFailureZZZMultiThreadedWithDelays.
/**
* Test to ensure that the basic operations fail, in the presence of some
* sleepy nodes and zone count reads and writes = 2 in a 3 zone cluster.
*
* @throws Exception
*/
@Test
public void testBasicOperationsFailureZZZMultiThreadedWithDelays() throws Exception {
cluster = VoldemortTestConstants.getNineNodeClusterWith3Zones();
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 = #nodes in a zone - 1
// PW = RW = #nodes in a zone - 1
// Zone Reads = # Zones - 1
// Zone Writes = # Zones - 1
// Sleepy nodes = 1 from each zone
// Threads = 4
RoutedStore routedStore = getStore(cluster, cluster.getNumberOfNodesInZone(0) - 1, cluster.getNumberOfNodesInZone(0) - 1, cluster.getNumberOfZones() - 1, cluster.getNumberOfZones() - 1, 4, null, Sets.newHashSet(2, 4, 8), zoneReplicationFactor, RoutingStrategyType.ZONE_STRATEGY, SLEEPY_TIME, OPERATION_TIMEOUT, new VoldemortException());
try {
testBasicOperations(cluster.getNumberOfNodes(), cluster.getNumberOfNodes(), 3, 0, routedStore, 1000);
fail("Too few successful zone responses. Should've failed.");
} catch (InsufficientZoneResponsesException ize) {
// Expected
}
}
use of voldemort.store.InsufficientZoneResponsesException in project voldemort by voldemort.
the class PerformSerialRequests method execute.
public void execute(Pipeline pipeline) {
List<Node> nodes = pipelineData.getNodes();
// reads to make up for these.
while (pipelineData.getSuccesses() < preferred && pipelineData.getNodeIndex() < nodes.size()) {
Node node = nodes.get(pipelineData.getNodeIndex());
long start = System.nanoTime();
try {
Store<ByteArray, byte[], byte[]> store = stores.get(node.getId());
V result = storeRequest.request(store);
Response<ByteArray, V> response = new Response<ByteArray, V>(node, key, result, ((System.nanoTime() - start) / Time.NS_PER_MS));
if (logger.isDebugEnabled())
logger.debug(pipeline.getOperation().getSimpleName() + " for key " + ByteUtils.toHexString(key.get()) + " successes: " + pipelineData.getSuccesses() + " preferred: " + preferred + " required: " + required + " new " + pipeline.getOperation().getSimpleName() + " success on node " + node.getId());
pipelineData.incrementSuccesses();
pipelineData.getResponses().add(response);
failureDetector.recordSuccess(response.getNode(), response.getRequestTime());
pipelineData.getZoneResponses().add(node.getZoneId());
} catch (Exception e) {
long requestTime = (System.nanoTime() - start) / Time.NS_PER_MS;
if (handleResponseError(e, node, requestTime, pipeline, failureDetector))
return;
}
// break out if we have satisfied everything
if (isSatisfied())
break;
pipelineData.incrementNodeIndex();
}
if (pipelineData.getSuccesses() < required) {
if (insufficientSuccessesEvent != null) {
pipeline.addEvent(insufficientSuccessesEvent);
} else {
pipelineData.setFatalError(new InsufficientOperationalNodesException(required + " " + pipeline.getOperation().getSimpleName() + "s required, but only " + pipelineData.getSuccesses() + " succeeded", pipelineData.getReplicationSet(), pipelineData.getNodes(), pipelineData.getFailedNodes(), pipelineData.getFailures()));
pipeline.abort();
}
} else {
if (pipelineData.getZonesRequired() != null) {
int zonesSatisfied = pipelineData.getZoneResponses().size();
if (zonesSatisfied >= (pipelineData.getZonesRequired() + 1)) {
pipeline.addEvent(completeEvent);
} else {
// if you run with zoneCountReads > 0, we could frequently
// run into this exception since our preference list for
// zone routing is laid out thus : <a node from each of
// 'zoneCountReads' zones>, <nodes from local zone>, <nodes
// from remote zone1>, <nodes from remote zone2>,...
// #preferred number of reads may not be able to satisfy
// zoneCountReads, if the original read to a remote node
// fails in the parallel stage
pipelineData.setFatalError(new InsufficientZoneResponsesException((pipelineData.getZonesRequired() + 1) + " " + pipeline.getOperation().getSimpleName() + "s required zone, but only " + zonesSatisfied + " succeeded"));
pipeline.abort();
}
} else {
pipeline.addEvent(completeEvent);
}
}
}
use of voldemort.store.InsufficientZoneResponsesException in project voldemort by voldemort.
the class RoutedStoreTest method testZoneRouting.
@Test
public void testZoneRouting() throws Exception {
cluster = VoldemortTestConstants.getEightNodeClusterWithZones();
HashMap<Integer, Integer> zoneReplicationFactor = Maps.newHashMap();
zoneReplicationFactor.put(0, 2);
zoneReplicationFactor.put(1, 2);
long start;
Versioned<byte[]> versioned = new Versioned<byte[]>(new byte[] { 1 });
// Basic put with zone read = 0, zone write = 0 and timeout < cross-zone
// latency
Store<ByteArray, byte[], byte[]> s1 = getStore(cluster, 1, 1, 0, 0, 8, null, Sets.newHashSet(4, 5, 6, 7), zoneReplicationFactor, RoutingStrategyType.ZONE_STRATEGY, SLEEPY_TIME, OPERATION_TIMEOUT, new VoldemortException());
start = System.nanoTime();
try {
s1.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// Putting extra key to test getAll
s1.put(new ByteArray("test2".getBytes()), versioned, null);
start = System.nanoTime();
try {
s1.get(new ByteArray("test".getBytes()), null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
start = System.nanoTime();
try {
List<Version> versions = s1.getVersions(new ByteArray("test".getBytes()));
for (Version version : versions) {
assertEquals(version.compare(versioned.getVersion()), Occurred.BEFORE);
}
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
start = System.nanoTime();
try {
s1.delete(new ByteArray("test".getBytes()), versioned.getVersion());
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// make sure sleepy stores processed the delete before checking,
// otherwise, we might be bailing
// out of the test too early for the delete to be processed.
Thread.sleep(SLEEPY_TIME * 2);
List<ByteArray> keys = Lists.newArrayList(new ByteArray("test".getBytes()), new ByteArray("test2".getBytes()));
Map<ByteArray, List<Versioned<byte[]>>> values = s1.getAll(keys, null);
assertFalse("'test' did not get deleted.", values.containsKey(new ByteArray("test".getBytes())));
ByteUtils.compare(values.get(new ByteArray("test2".getBytes())).get(0).getValue(), new byte[] { 1 });
// Basic put with zone read = 1, zone write = 1
Store<ByteArray, byte[], byte[]> s2 = getStore(cluster, 1, 1, 1, 1, 8, null, Sets.newHashSet(4, 5, 6, 7), zoneReplicationFactor, RoutingStrategyType.ZONE_STRATEGY, SLEEPY_TIME, BANNAGE_PERIOD, new VoldemortException());
start = System.nanoTime();
try {
s2.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " > " + SLEEPY_TIME, elapsed >= SLEEPY_TIME);
}
s2.put(new ByteArray("test2".getBytes()), versioned, null);
try {
s2.get(new ByteArray("test".getBytes()), null);
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* Why would you want responses from two zones and wait for only one
* response...
*/
}
try {
s2.getVersions(new ByteArray("test".getBytes()));
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* Why would you want responses from two zones and wait for only one
* response...
*/
}
try {
s2.delete(new ByteArray("test".getBytes()), null);
} catch (InsufficientZoneResponsesException e) {
/*
* Why would you want responses from two zones and wait for only one
* response...
*/
}
values = s2.getAll(keys, null);
assertFalse("'test' did not get deleted.", values.containsKey(new ByteArray("test".getBytes())));
ByteUtils.compare(values.get(new ByteArray("test2".getBytes())).get(0).getValue(), new byte[] { 1 });
// Basic put with zone read = 0, zone write = 0 and failures in other
// dc, but should still work
Store<ByteArray, byte[], byte[]> s3 = getStore(cluster, 1, 1, 0, 0, 8, Sets.newHashSet(4, 5, 6, 7), null, zoneReplicationFactor, RoutingStrategyType.ZONE_STRATEGY, SLEEPY_TIME, BANNAGE_PERIOD, new VoldemortException());
start = System.nanoTime();
try {
s3.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// Putting extra key to test getAll
s3.put(new ByteArray("test2".getBytes()), versioned, null);
start = System.nanoTime();
try {
List<Version> versions = s3.getVersions(new ByteArray("test".getBytes()));
for (Version version : versions) {
assertEquals(version.compare(versioned.getVersion()), Occurred.BEFORE);
}
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
start = System.nanoTime();
try {
s3.get(new ByteArray("test".getBytes()), null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
start = System.nanoTime();
try {
s3.delete(new ByteArray("test".getBytes()), versioned.getVersion());
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// Basic put with zone read = 1, zone write = 1 and failures in other
// dc, should not work
Store<ByteArray, byte[], byte[]> s4 = getStore(cluster, 2, 2, 1, 1, 8, Sets.newHashSet(4, 5, 6, 7), null, zoneReplicationFactor, RoutingStrategyType.ZONE_STRATEGY, SLEEPY_TIME, BANNAGE_PERIOD, new VoldemortException());
try {
s4.put(new ByteArray("test".getBytes()), new Versioned<byte[]>(new byte[] { 1 }), null);
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* The other zone is down and you expect a result from both zones
*/
}
try {
s4.getVersions(new ByteArray("test".getBytes()));
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* The other zone is down and you expect a result from both zones
*/
}
try {
s4.get(new ByteArray("test".getBytes()), null);
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* The other zone is down and you expect a result from both zones
*/
}
try {
s4.delete(new ByteArray("test".getBytes()), versioned.getVersion());
fail("Should have shown exception");
} catch (InsufficientZoneResponsesException e) {
/*
* The other zone is down and you expect a result from both zones
*/
}
}
Aggregations