Search in sources :

Example 1 with DeleteListener

use of com.aerospike.client.listener.DeleteListener 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();
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Value(com.aerospike.client.Value) DeleteListener(com.aerospike.client.listener.DeleteListener) ArrayList(java.util.ArrayList) List(java.util.List) Key(com.aerospike.client.Key) Test(org.junit.Test)

Example 2 with DeleteListener

use of com.aerospike.client.listener.DeleteListener 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();
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Value(com.aerospike.client.Value) DeleteListener(com.aerospike.client.listener.DeleteListener) HashMap(java.util.HashMap) Map(java.util.Map) Key(com.aerospike.client.Key) Test(org.junit.Test)

Aggregations

AerospikeException (com.aerospike.client.AerospikeException)2 Key (com.aerospike.client.Key)2 Value (com.aerospike.client.Value)2 DeleteListener (com.aerospike.client.listener.DeleteListener)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1