Skip to content
Snippets Groups Projects
Commit 4aede920 authored by Sean Busbey's avatar Sean Busbey
Browse files

Merge pull request #414 from tlopatic/aerospike-cleanup

[aerospike] Bring Aerospike adapter in line with adapter policy

* ! Aerospike client no longer retries over errors
* ! Aerospike client no longer backs off during cluster overload
parents 1eadd68c 7233d37b
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ import com.aerospike.client.AerospikeException;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import com.aerospike.client.ResultCode;
import com.aerospike.client.policy.ClientPolicy;
import com.aerospike.client.policy.Policy;
import com.aerospike.client.policy.RecordExistsAction;
......@@ -38,8 +37,6 @@ import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DBException;
public class AerospikeClient extends com.yahoo.ycsb.DB {
private static final boolean DEBUG = false;
private static final String DEFAULT_HOST = "localhost";
private static final String DEFAULT_PORT = "3000";
private static final String DEFAULT_TIMEOUT = "10000";
......@@ -48,9 +45,6 @@ public class AerospikeClient extends com.yahoo.ycsb.DB {
private static final int RESULT_OK = 0;
private static final int RESULT_ERROR = -1;
private static final int WRITE_OVERLOAD_DELAY = 5;
private static final int WRITE_OVERLOAD_TRIES = 3;
private String namespace = null;
private com.aerospike.client.AerospikeClient client = null;
......@@ -116,10 +110,7 @@ public class AerospikeClient extends com.yahoo.ycsb.DB {
}
if (record == null) {
if (DEBUG) {
System.err.println("Record key " + key + " not found (read)");
}
System.err.println("Record key " + key + " not found (read)");
return RESULT_ERROR;
}
......@@ -152,36 +143,15 @@ public class AerospikeClient extends com.yahoo.ycsb.DB {
++index;
}
int delay = WRITE_OVERLOAD_DELAY;
Key keyObj = new Key(namespace, table, key);
for (int tries = 0; tries < WRITE_OVERLOAD_TRIES; ++tries) {
try {
client.put(writePolicy, keyObj, bins);
return RESULT_OK;
} catch (AerospikeException e) {
if (e.getResultCode() != ResultCode.DEVICE_OVERLOAD) {
System.err.println("Error while writing key " + key + ": " + e);
return RESULT_ERROR;
}
try {
Thread.sleep(delay);
} catch (InterruptedException e2) {
if (DEBUG) {
System.err.println("Interrupted: " + e2);
}
}
delay *= 2;
}
}
if (DEBUG) {
System.err.println("Device overload");
try {
client.put(writePolicy, keyObj, bins);
return RESULT_OK;
} catch (AerospikeException e) {
System.err.println("Error while writing key " + key + ": " + e);
return RESULT_ERROR;
}
return RESULT_ERROR;
}
@Override
......@@ -200,10 +170,7 @@ public class AerospikeClient extends com.yahoo.ycsb.DB {
public int delete(String table, String key) {
try {
if (!client.delete(deletePolicy, new Key(namespace, table, key))) {
if (DEBUG) {
System.err.println("Record key " + key + " not found (delete)");
}
System.err.println("Record key " + key + " not found (delete)");
return RESULT_ERROR;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment