use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestAsyncBatch method asyncBatchExistsSequence.
@Test
public void asyncBatchExistsSequence() throws Exception {
client.exists(eventLoop, new ExistsSequenceListener() {
public void onExists(Key key, boolean exists) {
assertEquals(true, exists);
}
public void onSuccess() {
notifyComplete();
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, sendKeys);
waitTillComplete();
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestAsyncOperate method asyncOperateList.
@Test
public void asyncOperateList() {
final Key key = new Key(args.namespace, args.set, "aoplkey1");
client.delete(eventLoop, new DeleteListener() {
public void onSuccess(Key key, boolean existed) {
List<Value> itemList = new ArrayList<Value>();
itemList.add(Value.get(55));
itemList.add(Value.get(77));
client.operate(eventLoop, new ReadHandler(), null, key, ListOperation.appendItems(binName, itemList), ListOperation.pop(binName, -1), ListOperation.size(binName));
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, key);
waitTillComplete();
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestAsyncOperate method asyncOperateMap.
@Test
public void asyncOperateMap() {
final Key key = new Key(args.namespace, args.set, "aopmkey1");
client.delete(eventLoop, new DeleteListener() {
public void onSuccess(Key key, boolean existed) {
Map<Value, Value> map = new HashMap<Value, Value>();
map.put(Value.get("a"), Value.get(1));
map.put(Value.get("b"), Value.get(2));
map.put(Value.get("c"), Value.get(3));
client.operate(eventLoop, new MapHandler(), null, key, MapOperation.putItems(MapPolicy.Default, binName, map), MapOperation.getByRankRange(binName, -1, 1, MapReturnType.KEY_VALUE));
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, key);
waitTillComplete();
}
use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class TestAsyncPutGet method asyncPutGetInline.
@Test
public void asyncPutGetInline() {
final Key key = new Key(args.namespace, args.set, "putgetkey1");
final Bin bin = new Bin(binName, "value");
client.put(eventLoop, new WriteListener() {
public void onSuccess(final Key key) {
try {
// Write succeeded. Now call read.
client.get(eventLoop, new RecordListener() {
public void onSuccess(final Key key, final Record record) {
assertBinEqual(key, record, bin);
notifyComplete();
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, key);
} catch (Exception e) {
setError(e);
notifyComplete();
}
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, key, bin);
waitTillComplete();
}
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;
}
}
}
Aggregations