in geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java [585:715]
protected void basicProcess(final DistributionManager dm, final boolean waitForGrantor) {
final boolean isDebugEnabled_DLS = logger.isTraceEnabled(LogMarker.DLS_VERBOSE);
try {
receivingDM = dm;
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE, "DLockRequestMessage.basicProcess processing <{}>",
this);
}
response = createResponse();
response.setProcessorId(getProcessorId());
response.setRecipient(getSender());
response.serviceName = serviceName;
response.objectName = objectName;
response.lockId = lockId;
if (waitForGrantor && svc != null) {
try {
grantor = DLockGrantor.waitForGrantor(svc);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
grantor = null; // fail it
}
}
if (svc == null || grantor == null) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE, "respondWithNotGrantor this.svc={} this.grantor={}",
svc, grantor);
}
respondWithNotGrantor();
}
else if (grantor.isDestroyed()) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE, "respondWithNotGrantor grantor was destroyed {}",
grantor);
}
respondWithNotGrantor();
} else if (grantor.getVersionId() != grantorVersion) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"respondWithNotGrantor current version is {}; request was for {}",
grantor.getVersionId(), grantorVersion);
}
respondWithNotGrantor();
} else if (svc.getSerialNumber() != grantorSerialNumber) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"respondWithNotGrantor current serial number is {}; request was for {}",
svc.getSerialNumber(), grantorSerialNumber);
}
respondWithNotGrantor();
}
// this is the grantor, so the request will be processed...
else {
svc.checkDestroyed();
if (!svc.isLockGrantor()) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"respondWithNotGrantor service !isLockGrantor svc={}", svc);
}
respondWithNotGrantor();
}
grantor.checkDestroyed();
// handle lock re-entry...
if (reentrant) {
long leaseExpireTime;
try {
leaseExpireTime = grantor.reenterLock(this);
} catch (InterruptedException e) {
leaseExpireTime = 0; // just fail it
}
if (leaseExpireTime == 0) {
respondWithNotHolder();
} else {
respondWithGrant(leaseExpireTime);
}
}
// queue up this request to be granted...
else {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE, "Handling lock request: <{}>", this);
}
if (grantor.isDestroyed()) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"respondWithNotGrantor grantor was destroyed grantor={}", grantor);
}
respondWithNotGrantor();
} else {
try {
grantor.handleLockRequest(this);
} catch (InterruptedException | LockGrantorDestroyedException e) {
// just fail it
respondWithNotGrantor();
}
}
}
}
} catch (LockGrantorDestroyedException e) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"LockGrantorDestroyedException respondWithNotGrantor svc={}", svc);
}
respondWithNotGrantor();
} catch (LockServiceDestroyedException e) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"LockServiceDestroyedException respondWithNotGrantor svc={}", svc);
}
respondWithNotGrantor();
} catch (CancelException e) {
if (isDebugEnabled_DLS) {
logger.trace(LogMarker.DLS_VERBOSE,
"CacheClosedException respondWithNotGrantor svc={} exception = {}", svc, e);
}
if (isLocal()) {
throw e;
} else {
respondWithNotGrantor();
}
} catch (RuntimeException e) {
logger.warn(LogMarker.DLS_MARKER,
"[DLockRequestMessage.process] Caught throwable:",
e);
respondWithException(e);
}
}