Search in sources :

Example 21 with AerospikeException

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

the class QuerySum 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 22 with AerospikeException

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

the class StoreKey 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) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 23 with AerospikeException

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

the class TestAsyncQuery method initialize.

@BeforeClass
public static void initialize() {
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, args.namespace, args.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) BeforeClass(org.junit.BeforeClass)

Example 24 with AerospikeException

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

the class TestQueryAverage method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQueryAverage.class.getClassLoader(), "udf/average_example.lua", "average_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("l1", i);
        client.put(null, key, bin, new Bin("l2", 1));
    }
}
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 25 with AerospikeException

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

the class TestQueryInteger method prepare.

@BeforeClass
public static void prepare() {
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
        task.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) Key(com.aerospike.client.Key) BeforeClass(org.junit.BeforeClass)

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