Search in sources :

Example 1 with DistributedLockService

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;
}
Also used : DistributedLockService(org.apache.geode.distributed.DistributedLockService)

Example 2 with DistributedLockService

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);
}
Also used : DistributedLockService(org.apache.geode.distributed.DistributedLockService) DistributedMemberLock(org.apache.geode.distributed.internal.locks.DistributedMemberLock)

Example 3 with DistributedLockService

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());
            }
        }
    }
}
Also used : DistributedLockService(org.apache.geode.distributed.DistributedLockService)

Example 4 with DistributedLockService

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;
    }
}
Also used : LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) DistributedLockService(org.apache.geode.distributed.DistributedLockService)

Example 5 with DistributedLockService

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;
    }
}
Also used : DistributedLockService(org.apache.geode.distributed.DistributedLockService) UnknownHostException(java.net.UnknownHostException) CacheException(org.apache.geode.cache.CacheException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Aggregations

DistributedLockService (org.apache.geode.distributed.DistributedLockService)12 GeodeCacheFacade (org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade)3 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Test (org.junit.Test)3 DistributedMemberLock (org.apache.geode.distributed.internal.locks.DistributedMemberLock)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CacheException (org.apache.geode.cache.CacheException)1 RegionDirectory (org.apache.geode.cache.lucene.internal.directory.RegionDirectory)1 IndexRepository (org.apache.geode.cache.lucene.internal.repository.IndexRepository)1 IndexRepositoryImpl (org.apache.geode.cache.lucene.internal.repository.IndexRepositoryImpl)1 CacheOperationFacade (org.apache.geode.cache.util.AutoBalancer.CacheOperationFacade)1 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)1 LockServiceDestroyedException (org.apache.geode.distributed.LockServiceDestroyedException)1 BucketRegion (org.apache.geode.internal.cache.BucketRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1 IndexWriter (org.apache.lucene.index.IndexWriter)1