Skip to content

Commit

Permalink
retry append if add fails
Browse files Browse the repository at this point in the history
  • Loading branch information
smadappa committed Jul 16, 2016
1 parent c519f83 commit 0ec708a
Showing 1 changed file with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,30 @@ public void receivedStatus(OperationStatus val) {
+ "; Message : " + val.getMessage() + "; Elapsed Time - " + (System.currentTimeMillis() - operationDuration.getDuration()));
rv.set(val.isSuccess(), val);
if(val.isSuccess()) {
appendSuccess = true;
EVCacheMetricsFactory.getCounter(appName + "-" + serverGroup.getName() + "-AoA-AddCall-SUCCESS").increment();
} else {
EVCacheMetricsFactory.getCounter(appName + "-" + serverGroup.getName() + "-AoA-AddCall-FAIL").increment();
Operation op = opFact.cat(ConcatenationType.append, 0, key, co.getData(),
new OperationCallback() {
public void receivedStatus(OperationStatus val) {
if (val.getStatusCode().equals(StatusCode.SUCCESS)) {
if (log.isDebugEnabled()) log.debug("AddOrAppend Retry append Key (Append Operation): " + key + "; Status : " + val.getStatusCode().name()
+ "; Message : " + val.getMessage() + "; Elapsed Time - " + (System.currentTimeMillis() - operationDuration.getDuration()));

EVCacheMetricsFactory.getCounter(appName + "-" + serverGroup.getName() + "-AoA-RetryAppendCall-SUCCESS").increment();
rv.set(val.isSuccess(), val);
} else {
EVCacheMetricsFactory.getCounter(appName + "-" + serverGroup.getName() + "-AoA-Retry-AppendCall-FAIL").increment();
}
}
public void complete() {
latch.countDown();
rv.signalComplete();
}
});
rv.setOperation(op);
mconn.enqueueOperation(key, op);
}
}

Expand All @@ -342,10 +363,12 @@ public void gotData(String key, long cas) {

@Override
public void complete() {
latch.countDown();
rv.signalComplete();
if(appendSuccess) {
latch.countDown();
rv.signalComplete();
}
}
});
});
rv.setOperation(op);
mconn.enqueueOperation(key, op);
}
Expand Down

0 comments on commit 0ec708a

Please sign in to comment.