use of voldemort.store.slop.Slop in project voldemort by voldemort.
the class StreamingSlopPusherJob method slopSize.
/**
* Returns the approximate size of slop to help in throttling
*
* @param slopVersioned The versioned slop whose size we want
* @return Size in bytes
*/
private int slopSize(Versioned<Slop> slopVersioned) {
int nBytes = 0;
Slop slop = slopVersioned.getValue();
nBytes += slop.getKey().length();
nBytes += ((VectorClock) slopVersioned.getVersion()).sizeInBytes();
switch(slop.getOperation()) {
case PUT:
{
nBytes += slop.getValue().length;
break;
}
case DELETE:
{
break;
}
default:
logger.error("Unknown slop operation: " + slop.getOperation());
}
return nBytes;
}
use of voldemort.store.slop.Slop in project voldemort by voldemort.
the class HintedHandoffFailureTest method testSlopViaSerialHint_3_2_2.
/**
* Test to ensure that when an asynchronous put completes (with a failure)
* after the pipeline completes, a slop is still registered (via a serial
* hint).
*
* This is for the 3-2-2 configuration
*/
@Test
public void testSlopViaSerialHint_3_2_2() {
String key = "testSlopViaSerialHint_3_2_2";
String val = "xyz";
Versioned<byte[]> versionedVal = new Versioned<byte[]>(val.getBytes());
ByteArray keyByteArray = new ByteArray(key.getBytes());
List<Integer> failingNodeIdList = null;
try {
failingNodeIdList = customSetup(keyByteArray, get322Replica(), 0);
} catch (Exception e) {
logger.info(e.getMessage());
fail("Error in setup.");
}
this.store.put(keyByteArray, versionedVal, null);
// Give enough time for the serial hint to work.
try {
logger.info("Sleeping for 5 seconds to wait for the serial hint to finish");
Thread.sleep(1000);
} catch (Exception e) {
}
// Check the slop stores
Set<ByteArray> failedKeys = Sets.newHashSet();
failedKeys.add(keyByteArray);
Set<ByteArray> slopKeys = makeSlopKeys(keyByteArray, failingNodeIdList);
Set<Slop> registeredSlops = getAllSlops(slopKeys);
if (registeredSlops.size() == 0) {
fail("Should have seen some slops. But could not find any.");
} else if (registeredSlops.size() != 1) {
fail("Number of slops registered != 1");
}
}
use of voldemort.store.slop.Slop in project voldemort by voldemort.
the class HintedHandoffFailureTest method testSlopOnDelayedFailingAsyncPut_2_1_1.
/**
* Test to ensure that when an asynchronous put completes (with a failure)
* after PerformParallelPut has finished processing the responses and before
* the hinted handoff actually begins, a slop is still registered for the
* same.
*
* This is for the 2-1-1 configuration.
*/
@Test
public void testSlopOnDelayedFailingAsyncPut_2_1_1() throws Exception {
String key = "testSlopOnDelayedFailingAsyncPut_2_1_1";
String val = "xyz";
Versioned<byte[]> versionedVal = new Versioned<byte[]>(val.getBytes());
ByteArray keyByteArray = new ByteArray(key.getBytes());
List<Integer> failingNodeIdList = null;
try {
failingNodeIdList = customSetup(keyByteArray, get211Replica(), HINT_DELAY_TIME_MS);
} catch (Exception e) {
logger.info(e.getMessage());
fail("Error in setup.");
}
this.store.put(keyByteArray, versionedVal, null);
Thread.sleep(HINT_DELAY_TIME_MS + 100);
// Check the slop stores
Set<ByteArray> failedKeys = Sets.newHashSet();
failedKeys.add(keyByteArray);
Set<ByteArray> slopKeys = makeSlopKeys(keyByteArray, failingNodeIdList);
Set<Slop> registeredSlops = getAllSlops(slopKeys);
if (registeredSlops.size() == 0) {
fail("Should have seen some slops. But could not find any.");
} else if (registeredSlops.size() != 1) {
fail("Number of slops registered != 1");
}
}
use of voldemort.store.slop.Slop in project voldemort by voldemort.
the class HintedHandoffFailureTest method testNoSlopsOnAllReplicaFailures.
/**
* Test to do a put with a 3-2-2 config such that both the replica nodes do
* not respond at all. This test is to make sure that the main thread
* returns with an error and that no slops are registered.
*/
@Test
public void testNoSlopsOnAllReplicaFailures() throws Exception {
String key = "testNoSlopsOnAllReplicaFailures";
String val = "xyz";
final Versioned<byte[]> versionedVal = new Versioned<byte[]>(val.getBytes());
final ByteArray keyByteArray = new ByteArray(key.getBytes());
List<Integer> failingNodeIdList = null;
long sleepTime = ROUTING_TIMEOUT_MS + 100;
failingNodeIdList = customSetup(keyByteArray, FAILURE_MODE.FAIL_ALL_REPLICAS, get322Replica(), sleepTime, 0);
PerformAsyncPut asyncPutThread = new PerformAsyncPut(this.store, keyByteArray, versionedVal);
Executors.newFixedThreadPool(1).submit(asyncPutThread);
// Sleep for the routing timeout with some headroom
try {
Thread.sleep(sleepTime + 100);
} catch (Exception e) {
fail("Unknown error while doing a put: " + e);
}
// Check the slop stores
Set<ByteArray> failedKeys = Sets.newHashSet();
failedKeys.add(keyByteArray);
Set<ByteArray> slopKeys = makeSlopKeys(keyByteArray, failingNodeIdList);
Set<Slop> registeredSlops = getAllSlops(slopKeys);
if (registeredSlops.size() != 0) {
fail("Should not have seen any slops.");
}
}
use of voldemort.store.slop.Slop in project voldemort by voldemort.
the class HintedHandoffFailureTest method testSlopOnDelayedFailingAsyncPut_3_2_2.
/**
* Test to ensure that when an asynchronous put completes (with a failure)
* after PerformParallelPut has finished processing the responses and before
* the hinted handoff actually begins, a slop is still registered for the
* same.
*
* This is for the 3-2-2 configuration.
*/
@Test
public void testSlopOnDelayedFailingAsyncPut_3_2_2() throws Exception {
String key = "testSlopOnDelayedFailingAsyncPut_3_2_2";
String val = "xyz";
Versioned<byte[]> versionedVal = new Versioned<byte[]>(val.getBytes());
ByteArray keyByteArray = new ByteArray(key.getBytes());
List<Integer> failingNodeIdList = null;
try {
failingNodeIdList = customSetup(keyByteArray, get322Replica(), HINT_DELAY_TIME_MS);
} catch (Exception e) {
logger.info(e.getMessage());
fail("Error in setup.");
}
this.store.put(keyByteArray, versionedVal, null);
Thread.sleep(HINT_DELAY_TIME_MS + 100);
// Check the slop stores
Set<ByteArray> failedKeys = Sets.newHashSet();
failedKeys.add(keyByteArray);
Set<ByteArray> slopKeys = makeSlopKeys(keyByteArray, failingNodeIdList);
Set<Slop> registeredSlops = getAllSlops(slopKeys);
if (registeredSlops.size() == 0) {
fail("Should have seen some slops. But could not find any.");
} else if (registeredSlops.size() != 1) {
fail("Number of slops registered != 1");
}
}
Aggregations