Search in sources :

Example 86 with Bin

use of com.aerospike.client.Bin 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 Bin

use of com.aerospike.client.Bin 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 Bin

use of com.aerospike.client.Bin 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 89 with Bin

use of com.aerospike.client.Bin in project XRTB by benmfaul.

the class RedissonClient method hmset.

/**
 * Do a mhset with expire (No op on cache2k, expiry already set globally
 * @param id String. The key name.
 * @param m Map. The value to set.
 * @param expire int. The number of seconds before expiry.
 * @throws Exception on Cache2k or aerospike errors.
 */
public void hmset(String id, Map m, int expire) throws Exception {
    if (ae == null) {
        cache.put(id, m);
        return;
    }
    WritePolicy policy = new WritePolicy();
    policy.expiration = expire;
    Key key = new Key("test", "cache", id);
    Bin bin1 = new Bin("value", m);
    ae.getClient().put(policy, key, bin1);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key) WritePolicy(com.aerospike.client.policy.WritePolicy)

Example 90 with Bin

use of com.aerospike.client.Bin in project XRTB by benmfaul.

the class RedissonClient method expire.

/**
 * Expire a key (no op on Cache2k, expirt is set globally for it).
 * @param id String. The key to expire.
 * @param expire int. The number of seconds before expiration.
 * @throws Exception on cache2k or Aerorpike errors.
 */
public void expire(String id, int expire) throws Exception {
    if (cache != null) {
        return;
    }
    Key key = new Key("test", "cache", id);
    Record record = null;
    record = ae.getClient().get(null, key);
    if (record == null) {
        return;
    }
    Bin bin = new Bin("value", record.bins.get("value"));
    WritePolicy policy = new WritePolicy();
    policy.expiration = expire;
    ae.getClient().put(policy, key, bin);
}
Also used : Bin(com.aerospike.client.Bin) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key) WritePolicy(com.aerospike.client.policy.WritePolicy)

Aggregations

Bin (com.aerospike.client.Bin)151 Key (com.aerospike.client.Key)129 Record (com.aerospike.client.Record)70 Test (org.junit.Test)54 AerospikeException (com.aerospike.client.AerospikeException)34 ArrayList (java.util.ArrayList)31 WritePolicy (com.aerospike.client.policy.WritePolicy)27 HashMap (java.util.HashMap)22 Value (com.aerospike.client.Value)20 List (java.util.List)15 BeforeClass (org.junit.BeforeClass)14 Map (java.util.Map)13 Policy (com.aerospike.client.policy.Policy)12 IndexTask (com.aerospike.client.task.IndexTask)11 WriteListener (com.aerospike.client.listener.WriteListener)5 RegisterTask (com.aerospike.client.task.RegisterTask)5 AbstractMap (java.util.AbstractMap)4 TreeMap (java.util.TreeMap)4 CTX (com.aerospike.client.cdt.CTX)3 BitPolicy (com.aerospike.client.operation.BitPolicy)3