use of com.aerospike.client.Key in project aerospike-client-java by aerospike.
the class TestAsyncBatch method asyncBatchGetHeaders.
@Test
public void asyncBatchGetHeaders() throws Exception {
client.getHeader(eventLoop, new RecordArrayListener() {
public void onSuccess(Key[] keys, Record[] records) {
if (assertEquals(size, records.length)) {
for (int i = 0; i < records.length; i++) {
Record record = records[i];
if (!assertRecordFound(keys[i], record)) {
break;
}
if (!assertGreaterThanZero(record.generation)) {
break;
}
if (!assertGreaterThanZero(record.expiration)) {
break;
}
}
}
notifyComplete();
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, sendKeys);
waitTillComplete();
}
use of com.aerospike.client.Key in project aerospike-client-java by aerospike.
the class TestAsyncPutGet method asyncPutGetWithRetry.
@Test
public void asyncPutGetWithRetry() {
final Key key = new Key(args.namespace, args.set, "putgetkey2");
final Bin bin = new Bin(binName, "value");
client.put(eventLoop, new WriteHandler(client, null, key, bin), null, key, bin);
waitTillComplete();
}
use of com.aerospike.client.Key in project aerospike-client-java by aerospike.
the class TestAsyncBatch method asyncBatchExistsArray.
@Test
public void asyncBatchExistsArray() {
client.exists(eventLoop, new ExistsArrayListener() {
public void onSuccess(Key[] keys, boolean[] existsArray) {
for (int i = 0; i < existsArray.length; i++) {
if (!assertEquals(true, existsArray[i])) {
break;
}
}
notifyComplete();
}
public void onFailure(AerospikeException e) {
setError(e);
notifyComplete();
}
}, null, sendKeys);
waitTillComplete();
}
use of com.aerospike.client.Key in project aerospike-client-java by aerospike.
the class LargeMap method runExample.
/**
* Perform operations on a Large Map within a single bin.
*/
@Override
public void runExample(AerospikeClient client, Parameters params) throws Exception {
if (!params.hasLargeDataTypes) {
console.info("Large Map functions are not supported by the connected Aerospike server.");
return;
}
Key key = new Key(params.namespace, params.set, "setkey");
String binName = params.getBinName("setbin");
// Delete record if it already exists.
client.delete(params.writePolicy, key);
// Initialize Large Map operator.
com.aerospike.client.large.LargeMap lmap = client.getLargeMap(params.writePolicy, key, binName, null);
// Write values.
lmap.put(Value.get("lmapName1"), Value.get("lmapValue1"));
lmap.put(Value.get("lmapName2"), Value.get("lmapValue2"));
lmap.put(Value.get("lmapName3"), Value.get("lmapValue3"));
// Verify large set was created with default configuration.
Map<?, ?> map = lmap.getConfig();
for (Entry<?, ?> entry : map.entrySet()) {
console.info(entry.getKey().toString() + ',' + entry.getValue());
}
// Remove last value.
lmap.remove(Value.get("lmapName3"));
int size = lmap.size();
if (size != 2) {
throw new Exception("Size mismatch. Expected 2 Received " + size);
}
Map<?, ?> mapReceived = lmap.get(Value.get("lmapName2"));
String expected = "lmapValue2";
String stringReceived = (String) mapReceived.get("lmapName2");
if (stringReceived != null && stringReceived.equals(expected)) {
console.info("Data matched: namespace=%s set=%s key=%s value=%s", key.namespace, key.setName, key.userKey, stringReceived);
} else {
console.error("Data mismatch: Expected %s. Received %s.", expected, stringReceived);
}
}
use of com.aerospike.client.Key in project aerospike-client-java by aerospike.
the class AsyncMultiCommand method parseGroup.
final boolean parseGroup(int receiveSize) {
// Parse each message response and add it to the result array
dataOffset = 0;
while (dataOffset < receiveSize) {
resultCode = dataBuffer[dataOffset + 5] & 0xFF;
if (resultCode != 0) {
if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
if (stopOnNotFound) {
return true;
}
} else {
throw new AerospikeException(resultCode);
}
}
// If this is the end marker of the response, do not proceed further
if ((dataBuffer[dataOffset + 3] & Command.INFO3_LAST) != 0) {
return true;
}
generation = Buffer.bytesToInt(dataBuffer, dataOffset + 6);
expiration = Buffer.bytesToInt(dataBuffer, dataOffset + 10);
batchIndex = Buffer.bytesToInt(dataBuffer, dataOffset + 14);
fieldCount = Buffer.bytesToShort(dataBuffer, dataOffset + 18);
opCount = Buffer.bytesToShort(dataBuffer, dataOffset + 20);
dataOffset += Command.MSG_REMAINING_HEADER_SIZE;
Key key = parseKey();
parseRow(key);
}
return false;
}
Aggregations