@Override public void becomeLockGrantor() { checkReadiness(); checkForLimitedOrNoAccess(); if (!this.scope.isGlobal()) { throw new IllegalStateException( String.format( "Distribution locks are only supported for regions with GLOBAL scope, not %s", this.scope)); } DistributedLockService svc = getLockService(); try { super.becomeLockGrantor(); if (!svc.isLockGrantor()) { svc.becomeLockGrantor(); } } finally { if (!svc.isLockGrantor()) { if (logger.isDebugEnabled()) { logger.debug("isLockGrantor is false after becomeLockGrantor for {}", getFullPath()); } } } }
/** * Return the DistributedLockService associated with this Region. This method will lazily create * that service the first time it is invoked on this region. */ public DistributedLockService getLockService() { synchronized (this.dlockMonitor) { String dlsName = getFullPath(); if (this.dlockService == null) { this.dlockService = DistributedLockService.getServiceNamed(dlsName); if (this.dlockService == null) { // region destroy will destroy dls and manual freeResources only this.dlockService = DLockService.create(getFullPath(), getSystem(), true, false, false); } // handle is-lock-grantor region attribute... if (this.isLockGrantor) { this.dlockService.becomeLockGrantor(); } if (logger.isDebugEnabled()) { logger.debug("LockService for {} is using LockLease={}, LockTimeout={}", dlsName, getCache().getLockLease(), getCache().getLockTimeout()); } } return this.dlockService; } }