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