Skip to content

Commit

Permalink
Added latency for AppendOrAdd operation
Browse files Browse the repository at this point in the history
  • Loading branch information
smadappa committed May 24, 2016
1 parent 34887c5 commit 76a389d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,7 @@ public <T> Future<Boolean> appendOrAdd(String key, CachedData value, int timeToL
if (!node.isActive()) {
if (log.isInfoEnabled()) log.info("Node : " + node + " is not active. Failing fast and dropping the write event.");
final ListenableFuture<Boolean, OperationCompletionListener> defaultFuture = (ListenableFuture<Boolean, OperationCompletionListener>) getDefaultFuture();
if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl) ((EVCacheLatchImpl) evcacheLatch)
.addFuture(defaultFuture);
if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl) ((EVCacheLatchImpl) evcacheLatch).addFuture(defaultFuture);
return defaultFuture;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,15 @@ public <T> OperationFuture<Boolean> asyncAppendOrAdd(final String key, int exp,

Operation op = opFact.cat(ConcatenationType.append, 0, key, co.getData(),
new OperationCallback() {
final Stopwatch operationDuration = EVCacheMetricsFactory.getStatsTimer(appName, serverGroup, "LatencyAoA").start();
boolean appendSuccess = true;
@Override
public void receivedStatus(OperationStatus val) {
if (val.getStatusCode().equals(StatusCode.SUCCESS)) {
operationDuration.stop();
if (log.isDebugEnabled()) log.debug("AddOrAppend Key (Append Operation): " + key + "; Status : " + val.getStatusCode().name()
+ "; Message : " + val.getMessage() + "; Elapsed Time - " + (System.currentTimeMillis() - operationDuration.getDuration()));

EVCacheMetricsFactory.getCounter(appName + "-" + serverGroup.getName() + "-AoA-AppendCall-SUCCESS").increment();
rv.set(val.isSuccess(), val);
} else {
Expand All @@ -299,14 +304,9 @@ public void complete() {
Operation op = opFact.store(StoreType.add, key, co.getFlags(), exp, co.getData(), new StoreOperation.Callback() {
@Override
public void receivedStatus(OperationStatus val) {
if (log.isDebugEnabled()) log.debug("Storing Key : " + key + "; Status : " + val.getStatusCode().name()
+ "; Message : " + val.getMessage());

Tag tag = null;
final MemcachedNode node = getEVCacheNode(key);
if (node.getSocketAddress() instanceof InetSocketAddress) {
tag = new BasicTag("HOST", ((InetSocketAddress) node.getSocketAddress()).getHostName());
}
operationDuration.stop();
if (log.isDebugEnabled()) log.debug("AddOrAppend Key (Ad Operation): " + key + "; Status : " + val.getStatusCode().name()
+ "; Message : " + val.getMessage() + "; Elapsed Time - " + (System.currentTimeMillis() - operationDuration.getDuration()));
rv.set(val.isSuccess(), val);
}

Expand All @@ -328,8 +328,7 @@ public void complete() {
});
rv.setOperation(op);
mconn.enqueueOperation(key, op);
if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl) ((EVCacheLatchImpl) evcacheLatch)
.addFuture(rv);
if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl) ((EVCacheLatchImpl) evcacheLatch).addFuture(rv);
return rv;
}

Expand Down

0 comments on commit 76a389d

Please sign in to comment.