Skip to content
Browse files

Changed both serial (sync) operations and parallel (async) operations…

… to deduct the elapsed checkout time from the operation (routing) timeout for specific requests.
  • Loading branch information...
1 parent bb73de1 commit a34e62a15b4483b129600300879db05e73353c11 @jayjwylie jayjwylie committed Oct 10, 2012
View
10 src/java/voldemort/store/socket/SocketStore.java
@@ -263,22 +263,24 @@ public void close() throws VoldemortException {
*/
private <T> T request(ClientRequest<T> delegate, String operationName) {
- ClientRequestExecutor clientRequestExecutor = pool.checkout(destination);
-
long startTimeMs = -1;
long startTimeNs = -1;
if(logger.isDebugEnabled()) {
startTimeMs = System.currentTimeMillis();
- startTimeNs = System.nanoTime();
}
+ startTimeNs = System.nanoTime();
+
+ ClientRequestExecutor clientRequestExecutor = pool.checkout(destination);
String debugMsgStr = "";
BlockingClientRequest<T> blockingClientRequest = null;
try {
blockingClientRequest = new BlockingClientRequest<T>(delegate, timeoutMs);
- clientRequestExecutor.addClientRequest(blockingClientRequest, timeoutMs);
+ clientRequestExecutor.addClientRequest(blockingClientRequest,
+ timeoutMs,
+ System.nanoTime() - startTimeNs);
blockingClientRequest.await();
if(logger.isDebugEnabled())
View
12 src/java/voldemort/store/socket/clientrequest/ClientRequestExecutor.java
@@ -92,6 +92,12 @@ public synchronized void addClientRequest(ClientRequest<?> clientRequest) {
}
public synchronized void addClientRequest(ClientRequest<?> clientRequest, long timeoutMs) {
+ addClientRequest(clientRequest, timeoutMs, 0);
+ }
+
+ public synchronized void addClientRequest(ClientRequest<?> clientRequest,
+ long timeoutMs,
+ long elapsedNs) {
if(logger.isTraceEnabled())
logger.trace("Associating client with " + socketChannel.socket());
@@ -100,7 +106,11 @@ public synchronized void addClientRequest(ClientRequest<?> clientRequest, long t
if(timeoutMs == -1) {
this.expiration = -1;
} else {
- this.expiration = System.nanoTime() + (Time.NS_PER_MS * timeoutMs);
+ if (elapsedNs > (Time.NS_PER_MS * timeoutMs)) {
+ this.expiration = System.nanoTime();
+ } else {
+ this.expiration = System.nanoTime() + (Time.NS_PER_MS * timeoutMs) - elapsedNs;
+ }
if(this.expiration < System.nanoTime())
throw new IllegalArgumentException("timeout " + timeoutMs + " not valid");
View
3 src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java
@@ -298,7 +298,8 @@ public void useResource(ClientRequestExecutor clientRequestExecutor) {
delegate,
clientRequestExecutor,
callback);
- clientRequestExecutor.addClientRequest(clientRequest, timeoutMs);
+ clientRequestExecutor.addClientRequest(clientRequest, timeoutMs, System.nanoTime()
+ - startTimeNs);
}
@Override

0 comments on commit a34e62a

Please sign in to comment.
Something went wrong with that request. Please try again.