Search in sources :

Example 26 with InsufficientOperationalNodesException

use of voldemort.store.InsufficientOperationalNodesException in project voldemort by voldemort.

the class LongHintedHandoffTest method testHintedHandoff.

@Test
public void testHintedHandoff() throws InterruptedException {
    Set<Integer> nodeIds = new HashSet<Integer>();
    long startMs = System.currentTimeMillis();
    long endMs = startMs + MAX_TOTAL_TIME_MS;
    long totalPuts = 0;
    long numRejectedPuts = 0;
    long numAssertPuts = 0;
    StoreClient<byte[], byte[]> client = testEnv.makeClient();
    while (true) {
        if (System.currentTimeMillis() > endMs) {
            break;
        }
        // generate key
        ByteArray key = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
        byte[] value = TestUtils.randomBytes(VALUE_LENGTH);
        // put to nodes
        try {
            client.put(key.get(), value);
            // if put does not throw exception
            List<Node> routes = testEnv.routeRequest(key.get());
            for (Node node : routes) {
                numAssertPuts++;
                nodeIds.add(node.getId());
                Store<ByteArray, byte[], byte[]> realStore = testEnv.getRealStore(node.getId());
                if (realStore instanceof InMemoryPutAssertionStorageEngine) {
                    ((InMemoryPutAssertionStorageEngine<ByteArray, byte[], byte[]>) realStore).assertPut(key);
                } else {
                    fail("realStore is not InMemoryPutAssertionStorageEngine. Test setup is wrong");
                }
            }
        } catch (InsufficientOperationalNodesException e) {
            numRejectedPuts++;
            if (logger.isDebugEnabled()) {
                logger.debug("Key " + key + " is rejected for InsufficientOperationalNodes");
            }
        } finally {
            totalPuts++;
        }
    }
    // bring all servers up
    testEnv.warpUp();
    // check
    long numFailedAssertions = 0;
    for (Integer nodeId : nodeIds) {
        Store<ByteArray, byte[], byte[]> realStore = testEnv.getRealStore(nodeId);
        if (realStore instanceof InMemoryPutAssertionStorageEngine) {
            Set<ByteArray> keys = ((InMemoryPutAssertionStorageEngine<ByteArray, byte[], byte[]>) realStore).getFailedAssertions();
            for (ByteArray key : keys) {
                logger.error("key [" + key + "] is asserted but not recorded on node [" + nodeId + "]");
            }
            numFailedAssertions += keys.size();
        } else {
            fail("realStore is not InMemoryPutAssertionStorageEngine");
        }
    }
    logger.info("Total Client Puts Rejected (InsufficientOperationalNodes): " + numRejectedPuts);
    logger.info("Total Client Put Operations: " + totalPuts);
    logger.info("Total Server Put Assertions: " + numAssertPuts);
    logger.info("Total Server Put Lost: " + numFailedAssertions);
    assertEquals(numFailedAssertions + " server puts are lost: " + numFailedAssertions, 0L, numFailedAssertions);
}
Also used : Node(voldemort.cluster.Node) InsufficientOperationalNodesException(voldemort.store.InsufficientOperationalNodesException) ByteArray(voldemort.utils.ByteArray) InMemoryPutAssertionStorageEngine(voldemort.store.memory.InMemoryPutAssertionStorageEngine) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

InsufficientOperationalNodesException (voldemort.store.InsufficientOperationalNodesException)26 Node (voldemort.cluster.Node)17 ByteArray (voldemort.utils.ByteArray)16 Test (org.junit.Test)10 VoldemortException (voldemort.VoldemortException)9 UnreachableStoreException (voldemort.store.UnreachableStoreException)7 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 ExecutionException (java.util.concurrent.ExecutionException)5 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)5 InsufficientZoneResponsesException (voldemort.store.InsufficientZoneResponsesException)5 VectorClock (voldemort.versioning.VectorClock)5 Versioned (voldemort.versioning.Versioned)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 VoldemortApplicationException (voldemort.VoldemortApplicationException)4 VoldemortTestConstants.getNineNodeCluster (voldemort.VoldemortTestConstants.getNineNodeCluster)4 Cluster (voldemort.cluster.Cluster)4 SerializerDefinition (voldemort.serialization.SerializerDefinition)4 FailingReadsStore (voldemort.store.FailingReadsStore)4