diff --git a/aerospike/src/main/java/com/yahoo/ycsb/db/AerospikeClient.java b/aerospike/src/main/java/com/yahoo/ycsb/db/AerospikeClient.java index 361545ee9fc274b006c43094d03bf46f724b1f54..73ccd3866e02edec03deb82d5bf51f19cb4da221 100644 --- a/aerospike/src/main/java/com/yahoo/ycsb/db/AerospikeClient.java +++ b/aerospike/src/main/java/com/yahoo/ycsb/db/AerospikeClient.java @@ -37,7 +37,6 @@ public class AerospikeClient extends com.yahoo.ycsb.DB { private String namespace = null; private com.aerospike.client.AerospikeClient client = null; - private int writeOverloadTries = WRITE_OVERLOAD_TRIES; private Policy readPolicy = new Policy(); private WritePolicy insertPolicy = new WritePolicy(); @@ -128,10 +127,6 @@ public class AerospikeClient extends com.yahoo.ycsb.DB { private int write(String table, String key, WritePolicy writePolicy, HashMap<String, ByteIterator> values) { - if (writeOverloadTries == 0) { - return RESULT_ERROR; - } - Bin[] bins = new Bin[values.size()]; int index = 0; @@ -143,10 +138,9 @@ public class AerospikeClient extends com.yahoo.ycsb.DB { int delay = WRITE_OVERLOAD_DELAY; Key keyObj = new Key(namespace, table, key); - while (true) { + for (int tries = 0; tries < WRITE_OVERLOAD_TRIES; ++tries) { try { client.put(writePolicy, keyObj, bins); - writeOverloadTries = WRITE_OVERLOAD_TRIES; return RESULT_OK; } catch (AerospikeException e) { if (e.getResultCode() != ResultCode.DEVICE_OVERLOAD) { @@ -154,14 +148,6 @@ public class AerospikeClient extends com.yahoo.ycsb.DB { return RESULT_ERROR; } - if (--writeOverloadTries == 0) { - if (DEBUG) { - System.err.println("Device overload: " + e); - } - - return RESULT_ERROR; - } - try { Thread.sleep(delay); } catch (InterruptedException e2) { @@ -173,6 +159,12 @@ public class AerospikeClient extends com.yahoo.ycsb.DB { delay *= 2; } } + + if (DEBUG) { + System.err.println("Device overload"); + } + + return RESULT_ERROR; } @Override