Search in sources :

Example 6 with DLockRequestMessage

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);
    }
}
Also used : DLockRequestMessage(org.apache.geode.distributed.internal.locks.DLockRequestProcessor.DLockRequestMessage) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) IdentityArrayList(org.apache.geode.internal.cache.IdentityArrayList)

Aggregations

DLockRequestMessage (org.apache.geode.distributed.internal.locks.DLockRequestProcessor.DLockRequestMessage)6 IdentityArrayList (org.apache.geode.internal.cache.IdentityArrayList)2 LockServiceDestroyedException (org.apache.geode.distributed.LockServiceDestroyedException)1 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)1 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)1 DistributionMessageObserver (org.apache.geode.distributed.internal.DistributionMessageObserver)1 Host (org.apache.geode.test.dunit.Host)1 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)1 VM (org.apache.geode.test.dunit.VM)1 DLockTest (org.apache.geode.test.junit.categories.DLockTest)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1