use of org.apache.geode.distributed.DistributedLockService in project geode by apache.
the class BackupDataStoreHelper method getLockService.
private static DistributedLockService getLockService(DM dm) {
DistributedLockService dls = DistributedLockService.getServiceNamed(LOCK_SERVICE_NAME);
if (dls == null) {
synchronized (LOCK_SYNC) {
dls = DistributedLockService.getServiceNamed(LOCK_SERVICE_NAME);
if (dls == null) {
// Create the DistributedLockService
dls = DistributedLockService.create(LOCK_SERVICE_NAME, dm.getSystem());
}
}
}
Assert.assertTrue(dls != null);
return dls;
}
use of org.apache.geode.distributed.DistributedLockService in project geode by apache.
the class CreateRegionFunction method getDistributedLock.
private DistributedMemberLock getDistributedLock() {
String dlsName = this.regionConfigurationsRegion.getName();
DistributedLockService lockService = initializeDistributedLockService(dlsName);
String lockToken = dlsName + "_token";
return new DistributedMemberLock(lockService, lockToken);
}
use of org.apache.geode.distributed.DistributedLockService in project geode by apache.
the class DistributedRegion method becomeLockGrantor.
@Override
public void becomeLockGrantor() {
checkReadiness();
checkForLimitedOrNoAccess();
if (!this.scope.isGlobal()) {
throw new IllegalStateException(LocalizedStrings.DistributedRegion_DISTRIBUTION_LOCKS_ARE_ONLY_SUPPORTED_FOR_REGIONS_WITH_GLOBAL_SCOPE_NOT_0.toLocalizedString(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());
}
}
}
}
use of org.apache.geode.distributed.DistributedLockService in project geode by apache.
the class PeerTypeRegistration method unlock.
private void unlock() {
try {
DistributedLockService dls = getLockService();
dls.unlock(LOCK_NAME);
} catch (LockServiceDestroyedException e) {
// fix for bug 43574
cache.getCancelCriterion().checkCancelInProgress(e);
throw e;
}
}
use of org.apache.geode.distributed.DistributedLockService in project geode by apache.
the class ConsoleDistributionManagerDUnitTest method remoteAcquireDistLock.
/**
* Accessed via reflection. DO NOT REMOVE
*
* @param lockName
* @return
*/
protected static boolean remoteAcquireDistLock(String lockName) {
String serviceName = "cdmtest_service";
DistributedLockService service = DistributedLockService.getServiceNamed(serviceName);
if (service == null) {
service = DistributedLockService.create(serviceName, InternalDistributedSystem.getAnyInstance());
}
assertNotNull(service);
try {
return service.lock(lockName, 1000, 3000);
} catch (Exception e) {
throw new RuntimeException("DEBUG: remoteAcquireDistLock", e);
// return false;
}
}
Aggregations