Search in sources :

Example 41 with UnreachableStoreException

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

the class HttpStore method getAll.

@Override
public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys, Map<ByteArray, byte[]> transforms) throws VoldemortException {
    StoreUtils.assertValidKeys(keys);
    DataInputStream input = null;
    try {
        HttpPost method = new HttpPost(this.storeUrl);
        ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
        requestFormat.writeGetAllRequest(new DataOutputStream(outputBytes), getName(), keys, transforms, reroute);
        input = executeRequest(method, outputBytes);
        return requestFormat.readGetAllResponse(input);
    } catch (IOException e) {
        throw new UnreachableStoreException("Could not connect to " + storeUrl + " for " + getName(), e);
    } finally {
        IOUtils.closeQuietly(input);
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) UnreachableStoreException(voldemort.store.UnreachableStoreException) DataInputStream(java.io.DataInputStream)

Example 42 with UnreachableStoreException

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

the class HttpStore method put.

@Override
public void put(ByteArray key, Versioned<byte[]> versioned, byte[] transforms) throws VoldemortException {
    StoreUtils.assertValidKey(key);
    DataInputStream input = null;
    try {
        HttpPost method = new HttpPost(this.storeUrl);
        ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
        requestFormat.writePutRequest(new DataOutputStream(outputBytes), getName(), key, versioned.getValue(), transforms, (VectorClock) versioned.getVersion(), reroute);
        input = executeRequest(method, outputBytes);
        requestFormat.readPutResponse(input);
    } catch (IOException e) {
        throw new UnreachableStoreException("Could not connect to " + storeUrl + " for " + getName(), e);
    } finally {
        IOUtils.closeQuietly(input);
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) UnreachableStoreException(voldemort.store.UnreachableStoreException) DataInputStream(java.io.DataInputStream)

Example 43 with UnreachableStoreException

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

the class HintedHandoffFailureTest method customSetup.

/**
     * Setup a cluster with 3 nodes, with the following characteristics:
     * 
     * If FAILURE_MODE is FAIL_FIRST_REPLICA_NODE set the first replica store to
     * a sleepy force failing store
     * 
     * If FAILURE_MODE is FAIL_ALL_REPLICAS: set all replicas to sleepy force
     * failing store
     * 
     * Pseudo master : Standard In-memory store (wrapped by Logging store)
     * 
     * In memory slop stores
     * 
     * @param key The ByteArray representation of the key
     * @param failureMode The Failure mode for the replicas
     * 
     * @throws Exception
     */
public List<Integer> customSetup(ByteArray key, FAILURE_MODE failureMode, ReplicaFactor replicaFactor, long sleepTime, long hintDelayTimeMs) throws Exception {
    cluster = getThreeNodeCluster();
    storeDef = getStoreDef(STORE_NAME, replicaFactor, RoutingStrategyType.CONSISTENT_STRATEGY);
    strategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
    InMemoryStorageEngine<ByteArray, byte[], byte[]> inMemoryStorageEngine = new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME);
    LoggingStore<ByteArray, byte[], byte[]> loggingStore = new LoggingStore<ByteArray, byte[], byte[]>(inMemoryStorageEngine);
    VoldemortException e = new UnreachableStoreException("Node down");
    ForceFailStore<ByteArray, byte[], byte[]> failureStore = new ForceFailStore<ByteArray, byte[], byte[]>(loggingStore, e);
    SleepyStore<ByteArray, byte[], byte[]> sleepyFailureStore = new SleepyStore<ByteArray, byte[], byte[]>(sleepTime, failureStore);
    failureStore.setFail(true);
    List<Integer> failingNodeIdList = Lists.newArrayList();
    List<Node> replicaList = strategy.routeRequest(key.get());
    switch(failureMode) {
        case FAIL_FIRST_REPLICA_NODE:
            failingNodeIdList.add(replicaList.get(1).getId());
            break;
        case FAIL_ALL_REPLICAS:
            for (int nodeId = 1; nodeId < replicaList.size(); nodeId++) {
                failingNodeIdList.add(nodeId);
            }
            break;
    }
    subStores.clear();
    for (int i = 0; i < NUM_NODES_TOTAL; i++) {
        if (failingNodeIdList.contains(i)) {
            subStores.put(i, sleepyFailureStore);
        } else {
            subStores.put(i, loggingStore);
        }
    }
    setFailureDetector(subStores);
    routedStoreThreadPool = Executors.newFixedThreadPool(NUM_THREADS);
    routedStoreFactory = new RoutedStoreFactory(routedStoreThreadPool);
    Map<Integer, NonblockingStore> nonblockingSlopStores = Maps.newHashMap();
    for (Node node : cluster.getNodes()) {
        int nodeId = node.getId();
        SlopStorageEngine slopStorageEngine = new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>(SLOP_STORE_NAME), cluster);
        StorageEngine<ByteArray, Slop, byte[]> storageEngine = slopStorageEngine.asSlopStore();
        nonblockingSlopStores.put(nodeId, routedStoreFactory.toNonblockingStore(slopStorageEngine));
        slopStores.put(nodeId, storageEngine);
    }
    Map<Integer, NonblockingStore> nonblockingStores = Maps.newHashMap();
    for (Map.Entry<Integer, Store<ByteArray, byte[], byte[]>> entry : subStores.entrySet()) nonblockingStores.put(entry.getKey(), routedStoreFactory.toNonblockingStore(entry.getValue()));
    store = new DelayedPutPipelineRoutedStore(subStores, nonblockingStores, slopStores, nonblockingSlopStores, cluster, storeDef, failureDetector, hintDelayTimeMs);
    return failingNodeIdList;
}
Also used : RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) Node(voldemort.cluster.Node) Store(voldemort.store.Store) SleepyStore(voldemort.store.SleepyStore) LoggingStore(voldemort.store.logging.LoggingStore) ForceFailStore(voldemort.store.ForceFailStore) NonblockingStore(voldemort.store.nonblockingstore.NonblockingStore) VoldemortException(voldemort.VoldemortException) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) ByteArray(voldemort.utils.ByteArray) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) UnreachableStoreException(voldemort.store.UnreachableStoreException) ForceFailStore(voldemort.store.ForceFailStore) NonblockingStore(voldemort.store.nonblockingstore.NonblockingStore) SleepyStore(voldemort.store.SleepyStore) LoggingStore(voldemort.store.logging.LoggingStore) Slop(voldemort.store.slop.Slop) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 44 with UnreachableStoreException

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

the class RoutedStoreTest method testOnlyNodeFailuresDisableNode.

@Test
public void testOnlyNodeFailuresDisableNode() throws Exception {
    // test put
    cluster = getNineNodeCluster();
    Store<ByteArray, byte[], byte[]> s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
    try {
        s1.put(aKey, new Versioned<byte[]>(aValue), aTransform);
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(9);
    cluster = getNineNodeCluster();
    Store<ByteArray, byte[], byte[]> s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
    try {
        s2.put(aKey, new Versioned<byte[]>(aValue), aTransform);
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(0);
    // test get
    cluster = getNineNodeCluster();
    s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
    try {
        s1.get(aKey, aTransform);
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(9);
    cluster = getNineNodeCluster();
    s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
    try {
        s2.get(aKey, aTransform);
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(0);
    // test delete
    cluster = getNineNodeCluster();
    s1 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new VoldemortException());
    try {
        s1.delete(aKey, new VectorClock());
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(9);
    cluster = getNineNodeCluster();
    s2 = getStore(cluster, 1, 9, 9, 9, 0, RoutingStrategyType.TO_ALL_STRATEGY, new UnreachableStoreException("no go"));
    try {
        s2.delete(aKey, new VectorClock());
        fail("Failure is expected");
    } catch (InsufficientOperationalNodesException e) {
    /* expected */
    }
    assertOperationalNodes(0);
}
Also used : InsufficientOperationalNodesException(voldemort.store.InsufficientOperationalNodesException) VectorClock(voldemort.versioning.VectorClock) ByteArray(voldemort.utils.ByteArray) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortException(voldemort.VoldemortException) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 45 with UnreachableStoreException

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

the class FailureDetectorTestUtils method recordException.

public static void recordException(FailureDetector failureDetector, Node node, long requestTime, UnreachableStoreException e) {
    ((MutableStoreConnectionVerifier) failureDetector.getConfig().getConnectionVerifier()).setErrorStore(node, new UnreachableStoreException("junit injected test error"));
    failureDetector.recordException(node, requestTime, e);
}
Also used : MutableStoreConnectionVerifier(voldemort.cluster.failuredetector.MutableStoreConnectionVerifier) UnreachableStoreException(voldemort.store.UnreachableStoreException)

Aggregations

UnreachableStoreException (voldemort.store.UnreachableStoreException)45 Node (voldemort.cluster.Node)19 ByteArray (voldemort.utils.ByteArray)13 Test (org.junit.Test)11 IOException (java.io.IOException)10 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)10 VoldemortException (voldemort.VoldemortException)7 InsufficientOperationalNodesException (voldemort.store.InsufficientOperationalNodesException)7 DataInputStream (java.io.DataInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 DataOutputStream (java.io.DataOutputStream)5 ConnectException (java.net.ConnectException)5 HttpPost (org.apache.http.client.methods.HttpPost)5 Versioned (voldemort.versioning.Versioned)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 VoldemortApplicationException (voldemort.VoldemortApplicationException)4 NonblockingStoreCallback (voldemort.store.nonblockingstore.NonblockingStoreCallback)4 UnknownHostException (java.net.UnknownHostException)3