Search in sources :

Example 31 with AerospikeException

use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.

the class NettyCommand method totalTimeout.

private final void totalTimeout() {
    AerospikeException ae = new AerospikeException.Timeout(command.node, command.policy, iteration, true);
    if (state == AsyncCommand.DELAY_QUEUE) {
        // Command timed out in delay queue.
        closeFromDelayQueue();
        notifyFailure(ae);
        return;
    }
    // Attempt timeout delay.
    if (command.policy.timeoutDelay > 0) {
        // Notify user of timeout, but allow transaction to continue in hope of reusing the socket.
        timeoutDelay = true;
        notifyFailure(ae);
        totalDeadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(command.policy.timeoutDelay);
        eventLoop.timer.restoreTimeout(timeoutTask, totalDeadline);
        return;
    }
    // Perform timeout.
    timeoutTask = null;
    fail();
    notifyFailure(ae);
    tryDelayQueue();
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) HashedWheelTimeout(com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)

Example 32 with AerospikeException

use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.

the class NioCommand method onServerTimeout.

protected final void onServerTimeout() {
    conn.unregister();
    command.node.putAsyncConnection(conn, eventLoop.index);
    if (command.isRead) {
        // Read commands shift to prole node on timeout.
        command.sequence++;
    }
    AerospikeException ae = new AerospikeException.Timeout(command.node, command.policy, iteration, false);
    retry(ae, false);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) HashedWheelTimeout(com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)

Example 33 with AerospikeException

use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.

the class NioCommand method totalTimeout.

private final void totalTimeout() {
    AerospikeException ae = new AerospikeException.Timeout(command.node, command.policy, iteration, true);
    if (state == AsyncCommand.DELAY_QUEUE) {
        // Command timed out in delay queue.
        closeFromDelayQueue();
        notifyFailure(ae);
        return;
    }
    // Attempt timeout delay.
    if (command.policy.timeoutDelay > 0) {
        // Notify user of timeout, but allow transaction to continue in hope of reusing the socket.
        timeoutDelay = true;
        notifyFailure(ae);
        totalDeadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(command.policy.timeoutDelay);
        eventLoop.timer.restoreTimeout(timeoutTask, totalDeadline);
        return;
    }
    // Perform timeout.
    timeoutTask = null;
    fail();
    notifyFailure(ae);
    tryDelayQueue();
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) HashedWheelTimeout(com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)

Example 34 with AerospikeException

use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.

the class TestQuerySum method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQuerySum.class.getClassLoader(), "udf/sum_example.lua", "sum_example.lua", Language.LUA);
    rtask.waitTillComplete();
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask itask = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
        itask.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        Bin bin = new Bin(binName, i);
        client.put(null, key, bin);
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) Bin(com.aerospike.client.Bin) IndexTask(com.aerospike.client.task.IndexTask) RegisterTask(com.aerospike.client.task.RegisterTask) Key(com.aerospike.client.Key) BeforeClass(org.junit.BeforeClass)

Example 35 with AerospikeException

use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.

the class Args method setServerSpecific.

/**
 * Some database calls need to know how the server is configured.
 */
public void setServerSpecific(AerospikeClient client) {
    Node node = client.getNodes()[0];
    String featuresFilter = "features";
    String namespaceFilter = "namespace/" + namespace;
    Map<String, String> tokens = Info.request(null, node, featuresFilter, namespaceFilter);
    String features = tokens.get(featuresFilter);
    hasUdf = false;
    hasMap = false;
    if (features != null) {
        String[] list = features.split(";");
        for (String s : list) {
            if (s.equals("udf")) {
                hasUdf = true;
                break;
            } else if (s.equals("cdt-map")) {
                hasMap = true;
                break;
            }
        }
    }
    String namespaceTokens = tokens.get(namespaceFilter);
    if (namespaceTokens == null) {
        throw new AerospikeException(String.format("Failed to get namespace info: host=%s port=%d namespace=%s", host, port, namespace));
    }
    singleBin = parseBoolean(namespaceTokens, "single-bin");
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Node(com.aerospike.client.cluster.Node)

Aggregations

AerospikeException (com.aerospike.client.AerospikeException)107 Key (com.aerospike.client.Key)46 Bin (com.aerospike.client.Bin)24 Policy (com.aerospike.client.policy.Policy)24 IndexTask (com.aerospike.client.task.IndexTask)24 Record (com.aerospike.client.Record)19 Test (org.junit.Test)16 Node (com.aerospike.client.cluster.Node)12 IOException (java.io.IOException)10 BeforeClass (org.junit.BeforeClass)10 WritePolicy (com.aerospike.client.policy.WritePolicy)7 HashMap (java.util.HashMap)7 Statement (com.aerospike.client.query.Statement)6 RegisterTask (com.aerospike.client.task.RegisterTask)6 ArrayList (java.util.ArrayList)6 AerospikeClient (com.aerospike.client.AerospikeClient)5 Value (com.aerospike.client.Value)5 RecordSequenceListener (com.aerospike.client.listener.RecordSequenceListener)5 RecordSet (com.aerospike.client.query.RecordSet)5 HashedWheelTimeout (com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)4