Search in sources :

Example 86 with AerospikeException

use of com.aerospike.client.AerospikeException in project apex-malhar by apache.

the class AbstractAerospikeTransactionalPutOperator method processBatch.

@Override
public void processBatch(Collection<T> tuples) {
    Key key;
    Bin[] binsArray;
    try {
        for (T tuple : tuples) {
            key = getUpdatedBins(tuple, bins);
            binsArray = new Bin[bins.size()];
            binsArray = bins.toArray(binsArray);
            store.getClient().put(null, key, binsArray);
            bins.clear();
        }
    } catch (AerospikeException e) {
        throw new RuntimeException(e);
    }
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 87 with AerospikeException

use of com.aerospike.client.AerospikeException in project apex-malhar by apache.

the class AerospikeTransactionalStore method storeCommittedWindowId.

@Override
public void storeCommittedWindowId(String appId, int operatorId, long windowId) {
    try {
        String keyString = appId + String.valueOf(operatorId);
        Key key = new Key(namespace, metaSet, keyString.hashCode());
        Bin bin1 = new Bin(metaTableAppIdColumn, appId);
        Bin bin2 = new Bin(metaTableOperatorIdColumn, operatorId);
        Bin bin3 = new Bin(metaTableWindowColumn, windowId);
        client.put(null, key, bin1, bin2, bin3);
    } catch (AerospikeException e) {
        throw new RuntimeException(e);
    }
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 88 with AerospikeException

use of com.aerospike.client.AerospikeException in project apex-malhar by apache.

the class AerospikeTransactionalStore method createIndexes.

private void createIndexes() {
    IndexTask task;
    try {
        task = client.createIndex(null, namespace, metaSet, "operatorIdIndex", metaTableOperatorIdColumn, IndexType.NUMERIC);
        task.waitTillComplete();
        task = client.createIndex(null, namespace, metaSet, "appIdIndex", metaTableAppIdColumn, IndexType.STRING);
        task.waitTillComplete();
    } catch (AerospikeException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 89 with AerospikeException

use of com.aerospike.client.AerospikeException in project apex-malhar by apache.

the class AbstractAerospikeNonTransactionalPutOperator method processTuple.

@Override
public void processTuple(T tuple) {
    Key key;
    Bin[] binsArray;
    try {
        key = getUpdatedBins(tuple, bins);
        binsArray = new Bin[bins.size()];
        binsArray = bins.toArray(binsArray);
        store.getClient().put(null, key, binsArray);
        bins.clear();
    } catch (AerospikeException e) {
        throw new RuntimeException(e);
    }
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 90 with AerospikeException

use of com.aerospike.client.AerospikeException in project YCSB by brianfrankcooper.

the class AerospikeClient method write.

private Status write(String table, String key, WritePolicy writePolicy, Map<String, ByteIterator> values) {
    Bin[] bins = new Bin[values.size()];
    int index = 0;
    for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
        bins[index] = new Bin(entry.getKey(), entry.getValue().toArray());
        ++index;
    }
    Key keyObj = new Key(namespace, table, key);
    try {
        client.put(writePolicy, keyObj, bins);
        return Status.OK;
    } catch (AerospikeException e) {
        System.err.println("Error while writing key " + key + ": " + e);
        return Status.ERROR;
    }
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) ByteIterator(site.ycsb.ByteIterator) ByteArrayByteIterator(site.ycsb.ByteArrayByteIterator) Bin(com.aerospike.client.Bin) HashMap(java.util.HashMap) Map(java.util.Map) Key(com.aerospike.client.Key)

Aggregations

AerospikeException (com.aerospike.client.AerospikeException)175 Record (com.aerospike.client.Record)58 Test (org.junit.Test)58 Policy (com.aerospike.client.policy.Policy)57 Key (com.aerospike.client.Key)56 WritePolicy (com.aerospike.client.policy.WritePolicy)42 ThrowingRunnable (org.junit.function.ThrowingRunnable)41 Bin (com.aerospike.client.Bin)32 IndexTask (com.aerospike.client.task.IndexTask)29 BatchPolicy (com.aerospike.client.policy.BatchPolicy)28 BeforeClass (org.junit.BeforeClass)14 IOException (java.io.IOException)12 Node (com.aerospike.client.cluster.Node)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)8 RegisterTask (com.aerospike.client.task.RegisterTask)7 Expression (com.aerospike.client.exp.Expression)6 SocketTimeoutException (java.net.SocketTimeoutException)6 AerospikeClient (com.aerospike.client.AerospikeClient)5 Value (com.aerospike.client.Value)5