use of com.aerospike.client.AerospikeException in project aerospike-client-java by aerospike.
the class RWTask method doWrite.
/**
* Write the key at the given index
*/
protected void doWrite(RandomShift random, long keyIdx, boolean multiBin, WritePolicy writePolicy) {
Key key = new Key(args.namespace, args.setName, keyStart + keyIdx);
// Use predictable value for 0th bin same as key value
Bin[] bins = args.getBins(random, multiBin, keyStart + keyIdx);
try {
put(writePolicy, key, bins);
} catch (AerospikeException ae) {
writeFailure(ae);
runNextCommand();
} catch (Exception e) {
writeFailure(e);
runNextCommand();
}
}
use of com.aerospike.client.AerospikeException in project apex-malhar by apache.
the class AerospikeStore method connect.
/**
* Create connection with database.
*/
@Override
public void connect() {
try {
client = new AerospikeClient(node, port);
logger.debug("Aerospike connection Success");
} catch (AerospikeException ex) {
throw new RuntimeException("closing database resource", ex);
} catch (Throwable t) {
DTThrowable.rethrow(t);
}
}
use of com.aerospike.client.AerospikeException in project apex-malhar by apache.
the class AerospikeTestUtils method checkEvents.
static boolean checkEvents() {
long count = 0;
AerospikeClient client = null;
try {
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()) {
Record record = rs.getRecord();
Key key = rs.getKey();
if (!TestPOJO.check(key, record)) {
return false;
}
count++;
}
} catch (AerospikeException e) {
throw new RuntimeException("Error fetching records: ", e);
} finally {
if (null != client) {
client.close();
}
}
return NUM_TUPLES == count;
}
use of com.aerospike.client.AerospikeException in project apex-malhar by apache.
the class AerospikeTransactionalStore method getCommittedWindowId.
@Override
public long getCommittedWindowId(String appId, int operatorId) {
try {
lastWindowFetchCommand.setFilters(Filter.equal(metaTableOperatorIdColumn, operatorId));
lastWindowFetchCommand.setFilters(Filter.equal(metaTableAppIdColumn, appId));
long lastWindow = -1;
RecordSet recordSet = client.query(null, lastWindowFetchCommand);
while (recordSet.next()) {
lastWindow = Long.parseLong(recordSet.getRecord().getValue(metaTableWindowColumn).toString());
}
return lastWindow;
} catch (AerospikeException ex) {
throw new RuntimeException(ex);
}
}
use of com.aerospike.client.AerospikeException in project apex-malhar by apache.
the class AerospikeTransactionalStore method removeCommittedWindowId.
@Override
public void removeCommittedWindowId(String appId, int operatorId) {
try {
String keyString = appId + String.valueOf(operatorId);
Key key = new Key(namespace, metaSet, keyString.hashCode());
client.delete(null, key);
} catch (AerospikeException e) {
throw new RuntimeException(e);
}
}
Aggregations