Skip to content

Commit

Permalink
add check to avoid requests to block in case the server is still star…
Browse files Browse the repository at this point in the history
…ting up
  • Loading branch information
tglman committed Feb 12, 2019
1 parent b569813 commit 53d9ad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -317,11 +317,15 @@ public void processRequest(final ODistributedRequest request, final boolean wait
final CountDownLatch syncLatch = new CountDownLatch(involvedWorkerQueues.size());
final ODistributedRequest syncRequest = new ODistributedRequest(null, request.getId().getNodeId(), -1, databaseName,
new OSynchronizedTaskWrapper(syncLatch));
boolean enqueued = true;
for (int queue : involvedWorkerQueues) {
ODistributedWorker worker = workerThreads.get(queue);
worker.processRequest(syncRequest);
enqueued &= worker.processRequest(syncRequest);
}
if (!enqueued) {
ODistributedWorker.sendResponseBack(this, manager, request, new OOfflineNodeException("Node Not yet online"));
return;
}

// Make infinite timeout everytime
long taskTimeout = 0;
try {
Expand Down Expand Up @@ -886,7 +890,7 @@ public ODistributedTxContext registerTxContext(final ODistributedRequestId reqId
@Override
public ODistributedTxContext registerTxContext(final ODistributedRequestId reqId, ODistributedTxContext ctx) {
final ODistributedTxContext prevCtx = activeTxContexts.put(reqId, ctx);
if(prevCtx != ctx && prevCtx != null) {
if (prevCtx != ctx && prevCtx != null) {
prevCtx.destroy();
}
return ctx;
Expand Down
Expand Up @@ -82,11 +82,11 @@ public ODistributedWorker(final ODistributedDatabaseImpl iDistributed, final Str
this.acceptsWhileNotOnline = acceptsWhileNotOnline;
}

public void processRequest(final ODistributedRequest request) {
public boolean processRequest(final ODistributedRequest request) {
if (!acceptsWhileNotOnline && manager.isOffline()) {
ODistributedServerLog.debug(this, manager.getLocalNodeName(), null, DIRECTION.NONE,
"Discard request '%s' for database '%s' because the server is not online", request, this.databaseName);
return;
return false;
}

if (!localQueue.offer(request)) {
Expand All @@ -101,8 +101,10 @@ public void processRequest(final ODistributedRequest request) {
} catch (InterruptedException e) {
// JUST RETURN
Thread.currentThread().interrupt();
return false;
}
}
return true;
}

@Override
Expand Down

0 comments on commit 53d9ad8

Please sign in to comment.