use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestQueryString 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.STRING);
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, valuePrefix + i);
client.put(null, key, bin);
}
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestReplace method replaceOnly.
@Test
public void replaceOnly() {
Key key = new Key(args.namespace, args.set, "replaceonlykey");
Bin bin = new Bin("bin", "value");
// Delete record if it already exists.
client.delete(null, key);
try {
WritePolicy policy = new WritePolicy();
policy.recordExistsAction = RecordExistsAction.REPLACE_ONLY;
client.put(policy, key, bin);
fail("Failure. This command should have resulted in an error.");
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.KEY_NOT_FOUND_ERROR) {
throw ae;
}
}
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestIndex method createDrop.
@Test
public void createDrop() {
Policy policy = new Policy();
policy.setTimeout(0);
IndexTask task;
// Drop index if it already exists.
try {
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.INDEX_NOTFOUND) {
throw ae;
}
}
task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
task.waitTillComplete();
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
task.waitTillComplete();
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestQueryCollection method prepare.
@BeforeClass
public static void prepare() {
RegisterTask rtask = client.register(null, TestQueryCollection.class.getClassLoader(), "udf/record_example.lua", "record_example.lua", Language.LUA);
rtask.waitTillComplete();
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.STRING, IndexCollectionType.MAPKEYS);
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);
HashMap<String, String> map = new HashMap<String, String>();
map.put(mapKeyPrefix + 1, mapValuePrefix + i);
if (i % 2 == 0) {
map.put(mapKeyPrefix + 2, mapValuePrefix + i);
}
if (i % 3 == 0) {
map.put(mapKeyPrefix + 3, mapValuePrefix + i);
}
Bin bin = new Bin(binName, map);
client.put(null, key, bin);
}
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestQueryFilter method prepare.
@BeforeClass
public static void prepare() {
RegisterTask rtask = client.register(null, TestQueryFilter.class.getClassLoader(), "udf/filter_example.lua", "filter_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.STRING);
itask.waitTillComplete();
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
throw ae;
}
}
writeRecord(keyPrefix + 1, "Charlie", "cpass");
writeRecord(keyPrefix + 2, "Bill", "hknfpkj");
writeRecord(keyPrefix + 3, "Doug", "dj6554");
}
Aggregations