Search in sources :

Example 81 with Statement

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

the class AerospikeTestUtils method cleanMetaTable.

// removes all records from set AerospikeTransactionalStore.DEFAULT_META_SET (used to store
// committed window ids) in namespace NAMESPACE
// 
static void cleanMetaTable() {
    AerospikeClient client = null;
    try {
        client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(AerospikeTransactionalStore.DEFAULT_META_SET);
        RecordSet rs = client.query(null, stmnt);
        while (rs.next()) {
            client.delete(null, rs.getKey());
        }
    } catch (AerospikeException e) {
        LOG.error("cleanMetaTable failed: {}", e);
        throw e;
    } finally {
        if (null != client) {
            client.close();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) AerospikeException(com.aerospike.client.AerospikeException) Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet)

Example 82 with Statement

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

the class AerospikeTestUtils method getNumOfEventsInStore.

// returns the number of records in set SET_NAME in namespace NAMESPACE
static long getNumOfEventsInStore() {
    AerospikeClient client = null;
    try {
        long count = 0;
        client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(SET_NAME);
        RecordSet rs = client.query(null, stmnt);
        while (rs.next()) {
            count++;
        }
        return count;
    } catch (AerospikeException e) {
        LOG.error("getNumOfEventsInStore failed: {}", e);
        throw e;
    } finally {
        if (null != client) {
            client.close();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) AerospikeException(com.aerospike.client.AerospikeException) Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet)

Aggregations

Statement (com.aerospike.client.query.Statement)82 RecordSet (com.aerospike.client.query.RecordSet)63 Test (org.junit.Test)53 QueryPolicy (com.aerospike.client.policy.QueryPolicy)28 Record (com.aerospike.client.Record)23 Key (com.aerospike.client.Key)10 ResultSet (com.aerospike.client.query.ResultSet)9 Node (com.aerospike.client.cluster.Node)8 ExecuteTask (com.aerospike.client.task.ExecuteTask)8 AerospikeException (com.aerospike.client.AerospikeException)7 Map (java.util.Map)6 AerospikeClient (com.aerospike.client.AerospikeClient)4 Ignore (org.junit.Ignore)4 Bin (com.aerospike.client.Bin)3 GregorianCalendar (java.util.GregorianCalendar)3 RecordSequenceListener (com.aerospike.client.listener.RecordSequenceListener)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2