Search in sources :

Example 1 with LockServiceDestroyedException

use of org.apache.geode.distributed.LockServiceDestroyedException 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 2 with LockServiceDestroyedException

use of org.apache.geode.distributed.LockServiceDestroyedException in project geode by apache.

the class PartitionedRegion method registerPartitionedRegion.

/**
   * Register this PartitionedRegion by: 1) Create a PartitionRegionConfig and 2) Bind it into the
   * allPartitionedRegion system wide Region.
   * 
   * @param storesData which indicates whether the instance in this cache stores data, effecting the
   *        Nodes PRType
   * 
   * @see Node#setPRType(int)
   */
private void registerPartitionedRegion(boolean storesData) {
    // Register this ParitionedRegion. First check if the ParitionedRegion
    // entry already exists globally.
    PartitionRegionConfig prConfig = null;
    PartitionAttributes prAttribs = getAttributes().getPartitionAttributes();
    if (storesData) {
        if (this.fixedPAttrs != null) {
            this.node.setPRType(Node.FIXED_PR_DATASTORE);
        } else {
            this.node.setPRType(Node.ACCESSOR_DATASTORE);
        }
        this.node.setPersistence(getAttributes().getDataPolicy() == DataPolicy.PERSISTENT_PARTITION);
        byte loaderByte = (byte) (getAttributes().getCacheLoader() != null ? 0x01 : 0x00);
        byte writerByte = (byte) (getAttributes().getCacheWriter() != null ? 0x02 : 0x00);
        this.node.setLoaderWriterByte((byte) (loaderByte + writerByte));
    } else {
        if (this.fixedPAttrs != null) {
            this.node.setPRType(Node.FIXED_PR_ACCESSOR);
        } else {
            this.node.setPRType(Node.ACCESSOR);
        }
    }
    final RegionLock rl = getRegionLock();
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("registerPartitionedRegion: obtaining lock");
        }
        rl.lock();
        checkReadiness();
        prConfig = this.prRoot.get(getRegionIdentifier());
        if (prConfig == null) {
            validateParalleGatewaySenderIds();
            this.partitionedRegionId = generatePRId(getSystem());
            prConfig = new PartitionRegionConfig(this.partitionedRegionId, this.getFullPath(), prAttribs, this.getScope(), getAttributes().getEvictionAttributes(), getAttributes().getRegionIdleTimeout(), getAttributes().getRegionTimeToLive(), getAttributes().getEntryIdleTimeout(), getAttributes().getEntryTimeToLive(), this.getAllGatewaySenderIds());
            logger.info(LocalizedMessage.create(LocalizedStrings.PartitionedRegion_PARTITIONED_REGION_0_IS_BORN_WITH_PRID_1_IDENT_2, new Object[] { getFullPath(), this.partitionedRegionId, getRegionIdentifier() }));
            PRSanityCheckMessage.schedule(this);
        } else {
            validator.validatePartitionAttrsFromPRConfig(prConfig);
            if (storesData) {
                validator.validatePersistentMatchBetweenDataStores(prConfig);
                validator.validateCacheLoaderWriterBetweenDataStores(prConfig);
                validator.validateFixedPABetweenDataStores(prConfig);
            }
            this.partitionedRegionId = prConfig.getPRId();
            logger.info(LocalizedMessage.create(LocalizedStrings.PartitionedRegion_PARTITIONED_REGION_0_IS_CREATED_WITH_PRID_1, new Object[] { getFullPath(), this.partitionedRegionId }));
        }
        synchronized (prIdToPR) {
            // last
            prIdToPR.put(this.partitionedRegionId, this);
        }
        prConfig.addNode(this.node);
        if (this.getFixedPartitionAttributesImpl() != null) {
            calculateStartingBucketIDs(prConfig);
        }
        updatePRConfig(prConfig, false);
        /*
       * try { if (this.redundantCopies > 0) { if (storesData) {
       * this.dataStore.grabBackupBuckets(false); } } } catch (RegionDestroyedException rde) { if
       * (!this.isClosed) throw rde; }
       */
        this.cleanPRRegistration = true;
    } catch (LockServiceDestroyedException lsde) {
        if (logger.isDebugEnabled()) {
            logger.debug("registerPartitionedRegion: unable to obtain lock for {}", this);
        }
        cleanupFailedInitialization();
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_CAN_NOT_CREATE_PARTITIONEDREGION_FAILED_TO_ACQUIRE_REGIONLOCK.toLocalizedString(), lsde);
    } catch (IllegalStateException ill) {
        cleanupFailedInitialization();
        throw ill;
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable t) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        String registerErrMsg = LocalizedStrings.PartitionedRegion_AN_EXCEPTION_WAS_CAUGHT_WHILE_REGISTERING_PARTITIONEDREGION_0_DUMPPRID_1.toLocalizedString(getFullPath(), prIdToPR.dump());
        try {
            synchronized (prIdToPR) {
                if (prIdToPR.containsKey(this.partitionedRegionId)) {
                    prIdToPR.put(this.partitionedRegionId, PRIdMap.FAILED_REGISTRATION, false);
                    logger.info(LocalizedMessage.create(LocalizedStrings.PartitionedRegion_FAILED_REGISTRATION_PRID_0_NAMED_1, new Object[] { this.partitionedRegionId, this.getName() }));
                }
            }
        } catch (VirtualMachineError err) {
            SystemFailure.initiateFailure(err);
            // now, so don't let this thread continue.
            throw err;
        } catch (Throwable e) {
            // Whenever you catch Error or Throwable, you must also
            // catch VirtualMachineError (see above). However, there is
            // _still_ a possibility that you are dealing with a cascading
            // error condition, so you also need to check to see if the JVM
            // is still usable:
            SystemFailure.checkFailure();
            if (logger.isDebugEnabled()) {
                logger.debug("Partitioned Region creation, could not clean up after caught exception", e);
            }
        }
        throw new PartitionedRegionException(registerErrMsg, t);
    } finally {
        try {
            rl.unlock();
            if (logger.isDebugEnabled()) {
                logger.debug("registerPartitionedRegion: released lock");
            }
        } catch (Exception es) {
            if (logger.isDebugEnabled()) {
                logger.debug(es.getMessage(), es);
            }
        }
    }
}
Also used : LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) TimeoutException(org.apache.geode.cache.TimeoutException) IndexCreationException(org.apache.geode.cache.query.IndexCreationException) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) ExecutionException(java.util.concurrent.ExecutionException) ReplyException(org.apache.geode.distributed.internal.ReplyException) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) IndexExistsException(org.apache.geode.cache.query.IndexExistsException) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) EntryExistsException(org.apache.geode.cache.EntryExistsException) PartitionedRegionDistributionException(org.apache.geode.cache.PartitionedRegionDistributionException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) NoSuchElementException(java.util.NoSuchElementException) QueryException(org.apache.geode.cache.query.QueryException) PartitionNotAvailableException(org.apache.geode.cache.partition.PartitionNotAvailableException) LowMemoryException(org.apache.geode.cache.LowMemoryException) InternalFunctionInvocationTargetException(org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException) IndexInvalidException(org.apache.geode.cache.query.IndexInvalidException) PRLocallyDestroyedException(org.apache.geode.internal.cache.partitioned.PRLocallyDestroyedException) RegionExistsException(org.apache.geode.cache.RegionExistsException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) TransactionException(org.apache.geode.cache.TransactionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) EmptyRegionFunctionException(org.apache.geode.cache.execute.EmptyRegionFunctionException)

Example 3 with LockServiceDestroyedException

use of org.apache.geode.distributed.LockServiceDestroyedException 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)

Example 4 with LockServiceDestroyedException

use of org.apache.geode.distributed.LockServiceDestroyedException in project geode by apache.

the class PersistentRecoveryOrderDUnitTest method createDataAsyncTX.

public AsyncInvocation createDataAsyncTX(VM vm1, final int member) {
    SerializableCallable createData1 = new SerializableCallable() {

        public Object call() {
            Cache cache = getCache();
            Region region = cache.getRegion(REGION_NAME);
            int i = 0;
            TXManagerImpl txManager = (TXManagerImpl) cache.getCacheTransactionManager();
            while (true) {
                try {
                    txManager.begin();
                    region.put(member, i);
                    txManager.commit();
                    i++;
                } catch (RegionDestroyedException e) {
                    break;
                } catch (CacheClosedException e) {
                    break;
                } catch (IllegalArgumentException e) {
                    if (!e.getMessage().contains("Invalid txLockId")) {
                        throw e;
                    }
                    break;
                } catch (LockServiceDestroyedException e) {
                    break;
                }
            }
            return i - 1;
        }
    };
    AsyncInvocation asyncCreate1 = vm1.invokeAsync(createData1);
    return asyncCreate1;
}
Also used : TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) DiskRegion(org.apache.geode.internal.cache.DiskRegion) Region(org.apache.geode.cache.Region) CacheClosedException(org.apache.geode.cache.CacheClosedException) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Cache(org.apache.geode.cache.Cache)

Aggregations

LockServiceDestroyedException (org.apache.geode.distributed.LockServiceDestroyedException)4 CacheClosedException (org.apache.geode.cache.CacheClosedException)2 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)2 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 ExecutionException (java.util.concurrent.ExecutionException)1 CancelException (org.apache.geode.CancelException)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 Cache (org.apache.geode.cache.Cache)1 CacheException (org.apache.geode.cache.CacheException)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 EntryExistsException (org.apache.geode.cache.EntryExistsException)1 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)1 LowMemoryException (org.apache.geode.cache.LowMemoryException)1 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)1 PartitionedRegionDistributionException (org.apache.geode.cache.PartitionedRegionDistributionException)1 PartitionedRegionStorageException (org.apache.geode.cache.PartitionedRegionStorageException)1 Region (org.apache.geode.cache.Region)1