Search in sources :

Example 51 with AerospikeException

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

the class NioCommand method onServerTimeout.

protected final void onServerTimeout() {
    if (state == AsyncCommand.COMPLETE) {
        return;
    }
    conn.unregister();
    node.putAsyncConnection(conn, eventLoop.index);
    AerospikeException ae = new AerospikeException.Timeout(command.policy, false);
    retry(ae, false);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) HashedWheelTimeout(com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)

Example 52 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.policy, true);
    if (state == AsyncCommand.DELAY_QUEUE) {
        // Command timed out in delay queue.
        closeFromDelayQueue();
        notifyFailure(ae);
        return;
    }
    // Recover connection when possible.
    recoverConnection();
    // Perform timeout.
    close();
    notifyFailure(ae);
    eventLoop.tryDelayQueue();
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) HashedWheelTimeout(com.aerospike.client.async.HashedWheelTimer.HashedWheelTimeout)

Example 53 with AerospikeException

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

the class QueryAverage method createIndex.

private void createIndex(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
    console.info("Create index: ns=%s set=%s index=%s bin=%s", params.namespace, params.set, indexName, binName);
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 54 with AerospikeException

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

the class AsyncQuery method createIndex.

private void createIndex(AerospikeClient client, String indexName, String binName) {
    console.info("Create index: ns=%s set=%s index=%s bin=%s", params.namespace, params.set, indexName, binName);
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 55 with AerospikeException

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

the class AsyncScanPage method runScan.

private void runScan(AerospikeClient client, EventLoop eventLoop) {
    int pageSize = 30;
    console.info("Scan max " + pageSize + " records.");
    ScanPolicy policy = new ScanPolicy();
    policy.maxRecords = pageSize;
    PartitionFilter filter = PartitionFilter.all();
    RecordSequenceListener listener = new RecordSequenceListener() {

        private int count = 0;

        @Override
        public void onRecord(Key key, Record record) throws AerospikeException {
            count++;
        }

        @Override
        public void onSuccess() {
            console.info("Records returned: " + count);
            notifyComplete();
        }

        @Override
        public void onFailure(AerospikeException e) {
            console.error("Scan failed: " + Util.getErrorMessage(e));
            notifyComplete();
        }
    };
    client.scanPartitions(eventLoop, listener, policy, filter, params.namespace, setName);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) PartitionFilter(com.aerospike.client.query.PartitionFilter) RecordSequenceListener(com.aerospike.client.listener.RecordSequenceListener) ScanPolicy(com.aerospike.client.policy.ScanPolicy) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key)

Aggregations

AerospikeException (com.aerospike.client.AerospikeException)175 Record (com.aerospike.client.Record)58 Test (org.junit.Test)58 Policy (com.aerospike.client.policy.Policy)57 Key (com.aerospike.client.Key)56 WritePolicy (com.aerospike.client.policy.WritePolicy)42 ThrowingRunnable (org.junit.function.ThrowingRunnable)41 Bin (com.aerospike.client.Bin)32 IndexTask (com.aerospike.client.task.IndexTask)29 BatchPolicy (com.aerospike.client.policy.BatchPolicy)28 BeforeClass (org.junit.BeforeClass)14 IOException (java.io.IOException)12 Node (com.aerospike.client.cluster.Node)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)8 RegisterTask (com.aerospike.client.task.RegisterTask)7 Expression (com.aerospike.client.exp.Expression)6 SocketTimeoutException (java.net.SocketTimeoutException)6 AerospikeClient (com.aerospike.client.AerospikeClient)5 Value (com.aerospike.client.Value)5