Search in sources :

Example 21 with Slop

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;
}
Also used : Slop(voldemort.store.slop.Slop)

Example 22 with Slop

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");
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) Slop(voldemort.store.slop.Slop) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortException(voldemort.VoldemortException) Test(org.junit.Test)

Example 23 with Slop

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");
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) Slop(voldemort.store.slop.Slop) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortException(voldemort.VoldemortException) Test(org.junit.Test)

Example 24 with Slop

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.");
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) Slop(voldemort.store.slop.Slop) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortException(voldemort.VoldemortException) Test(org.junit.Test)

Example 25 with Slop

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");
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) Slop(voldemort.store.slop.Slop) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortException(voldemort.VoldemortException) Test(org.junit.Test)

Aggregations

Slop (voldemort.store.slop.Slop)36 ByteArray (voldemort.utils.ByteArray)29 Versioned (voldemort.versioning.Versioned)22 Test (org.junit.Test)15 Date (java.util.Date)11 Node (voldemort.cluster.Node)11 UnreachableStoreException (voldemort.store.UnreachableStoreException)11 VoldemortException (voldemort.VoldemortException)9 SlopStorageEngine (voldemort.store.slop.SlopStorageEngine)9 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)7 StreamingSlopPusherJob (voldemort.server.scheduler.slop.StreamingSlopPusherJob)6 ScanPermitWrapper (voldemort.server.storage.ScanPermitWrapper)6 ArrayList (java.util.ArrayList)5 BannagePeriodFailureDetector (voldemort.cluster.failuredetector.BannagePeriodFailureDetector)5 ServerStoreConnectionVerifier (voldemort.cluster.failuredetector.ServerStoreConnectionVerifier)5 VectorClock (voldemort.versioning.VectorClock)5 IOException (java.io.IOException)4 Map (java.util.Map)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 SlopSerializer (voldemort.serialization.SlopSerializer)4