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);
}
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();
}
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;
}
}
}
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;
}
}
}
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);
}
Aggregations