use of org.apache.geode.distributed.internal.locks.DLockRequestProcessor.DLockRequestMessage in project geode by apache.
the class DLockGrantor method drainPermittedRequests.
/**
* Drains newly permitted requests that have been removed from suspendQueue. All requests in the
* permittedRequests queue already have permission to proceed with granting or scheduling.
* <p>
* Caller must acquire destroyReadLock. Synchronizes on suspendLock, grantTokens and each grant
* token.
*
* Concurrency: protected by {@link #destroyLock} via invoking
* {@link #acquireDestroyReadLock(long)}
*/
protected void drainPermittedRequests() {
ArrayList drain = null;
synchronized (suspendLock) {
checkDestroyed();
if (this.permittedRequests.isEmpty()) {
return;
}
drain = this.permittedRequests;
this.permittedRequestsDrain.add(drain);
this.permittedRequests = new ArrayList();
}
// suspendLock sync
final boolean isDebugEnabled_DLS = logger.isTraceEnabled(LogMarker.DLS);
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS, "[drainPermittedRequests] draining {}", drain);
}
// iterate and attempt to grantOrSchedule each request
for (Iterator iter = drain.iterator(); iter.hasNext(); ) {
DLockRequestMessage request = (DLockRequestMessage) iter.next();
// destroyAndRemove should respond to all of these
checkDestroyed();
try {
// synchronizes on grant instance
handlePermittedLockRequest(request);
} catch (LockGrantorDestroyedException e) {
try {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS, "LockGrantorDestroyedException respondWithNotGrantor to {}", request);
}
request.respondWithNotGrantor();
} finally {
}
} catch (LockServiceDestroyedException e) {
try {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS, "LockServiceDestroyedException respondWithNotGrantor to {}", request);
}
request.respondWithNotGrantor();
} finally {
}
} catch (RuntimeException e) {
logger.error(LocalizedMessage.create(LocalizedStrings.DLockGrantor_PROCESSING_OF_POSTREMOTERELEASELOCK_THREW_UNEXPECTED_RUNTIMEEXCEPTION, e));
request.respondWithException(e);
} finally {
}
}
synchronized (suspendLock) {
checkDestroyed();
this.permittedRequestsDrain.remove(drain);
}
}
Aggregations