Search in sources :

Example 36 with UnreachableStoreException

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

the class ClientRequestExecutorPoolTest method testNonBlockingCheckoutConnectionFailure.

private void testNonBlockingCheckoutConnectionFailure(ClientRequestExecutorPool execPool, SocketDestination dest, Class<?> expectedExceptionClass) throws Exception {
    try {
        ClientRequestExecutor resource = execPool.internalGetQueuedPool().internalNonBlockingGet(dest);
        // operation and returns null most likely.
        if (resource == null) {
            Thread.sleep(execPool.getFactory().getTimeout() + 5);
            execPool.internalGetQueuedPool().internalNonBlockingGet(dest);
        }
        fail("should have thrown an connection exception");
    } catch (UnreachableStoreException e) {
        assertEquals("inner exception should be of type connect exception", expectedExceptionClass, e.getCause().getClass());
    }
}
Also used : ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) UnreachableStoreException(voldemort.store.UnreachableStoreException)

Example 37 with UnreachableStoreException

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

the class VoldemortBuildAndPushJob method verifyOrAddStore.

/**
     * For each node, checks if the store exists and then verifies that the remote schema
     * matches the new one. If the remote store doesn't exist, it creates it.
     */
private void verifyOrAddStore(String clusterURL, String keySchema, String valueSchema) {
    String newStoreDefXml = VoldemortUtils.getStoreDefXml(storeName, props.getInt(BUILD_REPLICATION_FACTOR, 2), props.getInt(BUILD_REQUIRED_READS, 1), props.getInt(BUILD_REQUIRED_WRITES, 1), props.getNullableInt(BUILD_PREFERRED_READS), props.getNullableInt(BUILD_PREFERRED_WRITES), props.getString(PUSH_FORCE_SCHEMA_KEY, keySchema), props.getString(PUSH_FORCE_SCHEMA_VALUE, valueSchema), description, owners);
    log.info("Verifying store against cluster URL: " + clusterURL + "\n" + newStoreDefXml.toString());
    StoreDefinition newStoreDef = VoldemortUtils.getStoreDef(newStoreDefXml);
    try {
        adminClientPerCluster.get(clusterURL).storeMgmtOps.verifyOrAddStore(newStoreDef, "BnP config/data", enableStoreCreation, this.storeVerificationExecutorService);
    } catch (UnreachableStoreException e) {
        log.info("verifyOrAddStore() failed on some nodes for clusterURL: " + clusterURL + " (this is harmless).", e);
    // When we can't reach some node, we just skip it and won't create the store on it.
    // Next time BnP is run while the node is up, it will get the store created.
    }
    // Other exceptions need to bubble up!
    storeDef = newStoreDef;
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) UnreachableStoreException(voldemort.store.UnreachableStoreException)

Example 38 with UnreachableStoreException

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

the class ThresholdFailureDetector method recordSuccess.

@Override
public void recordSuccess(Node node, long requestTime) {
    checkArgs(node, requestTime);
    boolean isSuccess = true;
    UnreachableStoreException e = null;
    if (requestTime > getConfig().getRequestLengthThreshold()) {
        // Consider slow requests as "soft" errors that are counted against
        // us in our success threshold.
        e = new UnreachableStoreException("Node " + node.getId() + " recording success, but request time (" + requestTime + ") exceeded threshold (" + getConfig().getRequestLengthThreshold() + ")");
        isSuccess = false;
    }
    update(node, isSuccess, e);
}
Also used : UnreachableStoreException(voldemort.store.UnreachableStoreException)

Example 39 with UnreachableStoreException

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

the class HttpStore method executeRequest.

private DataInputStream executeRequest(HttpPost method, ByteArrayOutputStream output) {
    HttpResponse response = null;
    try {
        method.setEntity(new ByteArrayEntity(output.toByteArray()));
        response = httpClient.execute(method);
        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpURLConnection.HTTP_OK) {
            String message = response.getStatusLine().getReasonPhrase();
            VoldemortIOUtils.closeQuietly(response);
            throw new UnreachableStoreException("HTTP request to store " + getName() + " returned status code " + statusCode + " " + message);
        }
        return new DataInputStream(response.getEntity().getContent());
    } catch (IOException e) {
        VoldemortIOUtils.closeQuietly(response);
        throw new UnreachableStoreException("Could not connect to " + storeUrl + " for " + getName(), e);
    }
}
Also used : ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) HttpResponse(org.apache.http.HttpResponse) UnreachableStoreException(voldemort.store.UnreachableStoreException) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 40 with UnreachableStoreException

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

the class HttpStore method get.

@Override
public List<Versioned<byte[]>> get(ByteArray key, byte[] transforms) throws VoldemortException {
    StoreUtils.assertValidKey(key);
    DataInputStream input = null;
    try {
        HttpPost method = new HttpPost(this.storeUrl);
        ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
        requestFormat.writeGetRequest(new DataOutputStream(outputBytes), getName(), key, transforms, reroute);
        input = executeRequest(method, outputBytes);
        return requestFormat.readGetResponse(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)

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