use of voldemort.versioning.ObsoleteVersionException in project voldemort by voldemort.
the class ClientTrafficVerifier method run.
@SuppressWarnings("serial")
@Override
public void run() {
Random r = new Random(System.currentTimeMillis());
while (!shouldStop) {
String k = keys.get(r.nextInt(KV_POOL_SIZE));
try {
switch(r.nextInt(3)) {
case // update
0:
if ((operationMode & MODE_ALLOW_PUT) == 0) {
break;
}
int newCount = kvUpdateCount.get(k) + 1;
client.put(k, kvMap.get(k) + "_" + newCount);
kvUpdateCount.put(k, newCount);
requestCount.put("PUT", requestCount.get("PUT") + 1);
break;
case // get
1:
if ((operationMode & MODE_ALLOW_GET) == 0) {
break;
}
Versioned<String> value = client.get(k);
verifyValue(k, value);
requestCount.put("GET", requestCount.get("GET") + 1);
break;
case // get all
2:
if ((operationMode & MODE_ALLOW_GETALL) == 0) {
break;
}
String k2 = keys.get(r.nextInt(KV_POOL_SIZE));
Map<String, Versioned<String>> result = client.getAll(Arrays.asList(k, k2));
verifyValue(k, result.get(k));
verifyValue(k2, result.get(k2));
requestCount.put("GETALL", requestCount.get("GETALL") + 1);
break;
}
} catch (ObsoleteVersionException e) {
// Theoretically, each thread works with its own set of keys the
// ObsoleteVersionException should not happen. But partitions
// are moving around nodes and because of the way we
// acknowledge writes before all nodes are complete and using
// async writes they can be out of sync and the exceptions can
// still happen. Did not try digging deeper on this one
// as it is irrelevant for the refactoring I am doing.
} catch (Exception e) {
logger.info("CLIENT EXCEPTION FAILURE on key [" + k + "]", e);
String exceptionName = "Key " + k + " " + e.getClass().toString();
if (exceptionCount.containsKey(exceptionName)) {
exceptionCount.put(exceptionName, exceptionCount.get(exceptionName) + 1);
} else {
exceptionCount.put(exceptionName, 1);
}
}
}
}
use of voldemort.versioning.ObsoleteVersionException in project voldemort by voldemort.
the class RedirectingStoreTest method testProxyPuts.
@Test
public void testProxyPuts() {
List<ByteArray> testPrimaryKeys = new ArrayList<ByteArray>(this.proxyPutTestPrimaryEntries.keySet());
List<ByteArray> testSecondaryKeys = new ArrayList<ByteArray>(this.proxyPutTestSecondaryEntries.keySet());
final RedirectingStore redirectingStoreNode2 = getRedirectingStore(2, servers[2].getMetadataStore(), "test");
final RedirectingStore redirectingStoreNode0 = getRedirectingStore(0, servers[0].getMetadataStore(), "test");
final Store<ByteArray, byte[], byte[]> socketStoreNode2 = redirectingStoreNode2.getRedirectingSocketStore("test", 2);
final Store<ByteArray, byte[], byte[]> socketStoreNode0 = redirectingStoreNode0.getRedirectingSocketStore("test", 0);
// 1. Make sure the vector clocks make sense.. Read through Node 2 and
// proxy getting from Node 0 and issue a write based off that,
// incrementing the clock for Node 2 and make sure there is no
// ObsoleteVersionException at both Node 0 and
// Node 2.
ByteArray secondaryKey = testSecondaryKeys.get(0);
VectorClock clock1 = ((VectorClock) redirectingStoreNode2.getVersions(secondaryKey).get(0)).incremented(2, System.currentTimeMillis());
try {
redirectingStoreNode2.put(secondaryKey, Versioned.value("write-through".getBytes("UTF-8"), clock1), null);
} catch (Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
waitForProxyPutsToDrain(redirectingStoreNode2);
assertTrue("Unexpected failures in proxy put", redirectingStoreNode2.getProxyPutStats().getNumProxyPutFailures() == 0);
assertEquals("Unexpected value in Node 2", "write-through", new String(socketStoreNode2.get(secondaryKey, null).get(0).getValue()));
assertTrue("Proxy write not seen on proxy node 0", "write-through".equals(new String(socketStoreNode0.get(secondaryKey, null).get(0).getValue())));
// Also test that if put fails locally, proxy put is not attempted.
try {
redirectingStoreNode2.put(secondaryKey, Versioned.value("write-through-updated".getBytes("UTF-8"), clock1), null);
fail("Should have thrown OVE");
} catch (ObsoleteVersionException ove) {
// Expected
} catch (Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
waitForProxyPutsToDrain(redirectingStoreNode2);
assertFalse("Proxy write not seen on proxy node 0", "write-through-updated".equals(new String(socketStoreNode0.get(secondaryKey, null).get(0).getValue())));
// 2. Make sure if the proxy node is still a replica, we don't issue
// proxy puts. Node 2 -> Node 0 on partition 0, for which Node 0 is
// still a replica
ByteArray primaryKey = testPrimaryKeys.get(0);
VectorClock clock2 = ((VectorClock) redirectingStoreNode2.getVersions(primaryKey).get(0)).incremented(2, System.currentTimeMillis());
try {
redirectingStoreNode2.put(primaryKey, Versioned.value("write-through".getBytes("UTF-8"), clock2), null);
} catch (Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
waitForProxyPutsToDrain(redirectingStoreNode2);
assertEquals("Unexpected value in Node 2", "write-through", new String(socketStoreNode2.get(primaryKey, null).get(0).getValue()));
assertFalse("Proxy write seen on proxy node which is a replica", "write-through".equals(new String(socketStoreNode0.get(primaryKey, null).get(0).getValue())));
// generate OVE.
try {
redirectingStoreNode2.put(primaryKey, Versioned.value("write-through".getBytes("UTF-8"), clock2), null);
fail("Should have thrown OVE");
} catch (ObsoleteVersionException ove) {
// Expected
} catch (Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
}
use of voldemort.versioning.ObsoleteVersionException in project voldemort by voldemort.
the class BdbStorageEngineTest method testConcurrentReadAndPut.
@Test
public void testConcurrentReadAndPut() throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(10);
final CountDownLatch latch = new CountDownLatch(10);
final AtomicBoolean returnedEmpty = new AtomicBoolean(false);
final byte[] keyBytes = "foo".getBytes();
final byte[] valueBytes = "bar".getBytes();
store.put(new ByteArray(keyBytes), new Versioned<byte[]>(valueBytes), null);
for (int i = 0; i < 10; i++) {
executor.submit(new Runnable() {
public void run() {
try {
for (int j = 0; j < 1000 && !returnedEmpty.get(); j++) {
List<Versioned<byte[]>> vals = store.get(new ByteArray(keyBytes), null);
if (vals.size() == 0 && j > 1)
returnedEmpty.set(true);
else {
VectorClock v = (VectorClock) vals.get(0).getVersion();
v.incrementVersion(0, System.currentTimeMillis());
try {
store.put(new ByteArray(keyBytes), new Versioned<byte[]>(valueBytes, v), null);
} catch (ObsoleteVersionException e) {
// Ignore these
}
}
}
} finally {
latch.countDown();
}
}
});
}
latch.await();
assertFalse("Should not have seen any empty results", returnedEmpty.get());
}
use of voldemort.versioning.ObsoleteVersionException in project voldemort by voldemort.
the class MetadataStoreTest method testObsoletePut.
@Test
public void testObsoletePut() {
for (int i = 0; i <= TEST_RUNS; i++) {
ByteArray key = getValidKey();
VectorClock clock = (VectorClock) metadataStore.get(key, null).get(0).getVersion();
Versioned<byte[]> value = new Versioned<byte[]>(getValidValue(key), clock.incremented(0, 1));
try {
metadataStore.put(key, value, null);
assertTrue(true);
metadataStore.put(key, value, null);
fail();
} catch (ObsoleteVersionException e) {
// expected ObsoleteVersionException
}
}
}
use of voldemort.versioning.ObsoleteVersionException in project voldemort by voldemort.
the class PerformParallelDeleteRequests method handleException.
/**
*
* @param response
* @param pipeline
* @param isParallel
* @return true if it is a terminal error, false otherwise
*/
private boolean handleException(Response<ByteArray, Object> response, Pipeline pipeline) {
Node node = response.getNode();
Exception ex = null;
if (!(response.getValue() instanceof Exception)) {
return false;
}
ex = (Exception) response.getValue();
if (enableHintedHandoff) {
if (ex instanceof UnreachableStoreException || ex instanceof QuotaExceededException) {
Slop slop = new Slop(pipelineData.getStoreName(), Slop.Operation.DELETE, key, null, null, node.getId(), new Date());
if (isOperationCompleted.get() == false) {
hintedHandoffAction.rememberSlopForLaterEvent(node, slop);
} else if (isDeleteSuccessful.get() == true) {
hintedHandoff.sendHintParallel(node, version, slop);
}
}
}
if (ex instanceof ObsoleteVersionException) {
// able to write on this node and should be termed as clean success.
return false;
} else if (ex instanceof QuotaExceededException) {
// QuotaException silently as well
return false;
}
// responses below.
if (ex instanceof InvalidMetadataException && isOperationCompleted.get()) {
pipelineData.reportException(ex);
if (logger.isInfoEnabled()) {
logger.info("Received invalid metadata problem after a successful " + pipeline.getOperation().getSimpleName() + " call on node " + node.getId() + ", store '" + pipelineData.getStoreName() + "'");
}
} else {
return handleResponseError(response, pipeline, failureDetector);
}
return false;
}
Aggregations