Search in sources :

Example 36 with RegionDestroyedException

use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.

the class DistributedRegion method initMembershipRoles.

private void initMembershipRoles() {
    synchronized (this.advisorListener) {
        // hold sync to prevent listener from changing initial members
        Set others = this.distAdvisor.addMembershipListenerAndAdviseGeneric(this.advisorListener);
        this.advisorListener.addMembers(others);
        // initialize missing required roles with initial member info
        if (getMembershipAttributes().hasRequiredRoles()) {
            // AdvisorListener will also sync on missingRequiredRoles
            synchronized (this.missingRequiredRoles) {
                this.missingRequiredRoles.addAll(getMembershipAttributes().getRequiredRoles());
                // remove all the roles we are playing since they will never be
                // missing
                this.missingRequiredRoles.removeAll(getSystem().getDistributedMember().getRoles());
                for (Object other1 : others) {
                    DistributedMember other = (DistributedMember) other1;
                    this.missingRequiredRoles.removeAll(other.getRoles());
                }
            }
        }
    }
    if (getMembershipAttributes().hasRequiredRoles()) {
        // wait up to memberTimeout for required roles...
        // boolean requiredRolesAreMissing = false;
        int memberTimeout = getSystem().getConfig().getMemberTimeout();
        if (logger.isDebugEnabled()) {
            logger.debug("Waiting up to {} for required roles.", memberTimeout);
        }
        try {
            if (this.giiMissingRequiredRoles) {
                // force reliability loss and possibly resumption
                this.isInitializingThread = true;
                synchronized (this.advisorListener) {
                    synchronized (this.missingRequiredRoles) {
                        // forcing state of loss because of bad GII
                        this.isMissingRequiredRoles = true;
                        getCachePerfStats().incReliableRegionsMissing(1);
                        if (getMembershipAttributes().getLossAction().isAllAccess())
                            // rahul
                            getCachePerfStats().incReliableRegionsMissingFullAccess(1);
                        else if (getMembershipAttributes().getLossAction().isLimitedAccess())
                            getCachePerfStats().incReliableRegionsMissingLimitedAccess(1);
                        else if (getMembershipAttributes().getLossAction().isNoAccess())
                            getCachePerfStats().incReliableRegionsMissingNoAccess(1);
                        // pur code to increment the stats.
                        if (logger.isDebugEnabled()) {
                            logger.debug("GetInitialImage had missing required roles.");
                        }
                        // TODO: will this work with RECONNECT and REINITIALIZE?
                        this.isInitializingThread = true;
                        lostReliability(null, null);
                        if (this.missingRequiredRoles.isEmpty()) {
                            // all required roles are present so force resumption
                            this.isMissingRequiredRoles = false;
                            getCachePerfStats().incReliableRegionsMissing(-1);
                            if (getMembershipAttributes().getLossAction().isAllAccess())
                                // rahul
                                getCachePerfStats().incReliableRegionsMissingFullAccess(-1);
                            else if (getMembershipAttributes().getLossAction().isLimitedAccess())
                                getCachePerfStats().incReliableRegionsMissingLimitedAccess(-1);
                            else if (getMembershipAttributes().getLossAction().isNoAccess())
                                getCachePerfStats().incReliableRegionsMissingNoAccess(-1);
                            // pur code to increment the stats.
                            boolean async = resumeReliability(null, null);
                            if (async) {
                                this.advisorListener.destroyed = true;
                            }
                        }
                    }
                }
            } else {
                if (!getSystem().isLoner()) {
                    waitForRequiredRoles(memberTimeout);
                }
                synchronized (this.advisorListener) {
                    synchronized (this.missingRequiredRoles) {
                        if (this.missingRequiredRoles.isEmpty()) {
                            Assert.assertTrue(!this.isMissingRequiredRoles);
                            if (logger.isDebugEnabled()) {
                                logger.debug("Initialization completed with all required roles present.");
                            }
                        } else {
                            // starting in state of loss...
                            this.isMissingRequiredRoles = true;
                            getCachePerfStats().incReliableRegionsMissing(1);
                            if (getMembershipAttributes().getLossAction().isAllAccess())
                                // rahul
                                getCachePerfStats().incReliableRegionsMissingFullAccess(1);
                            else if (getMembershipAttributes().getLossAction().isLimitedAccess())
                                getCachePerfStats().incReliableRegionsMissingLimitedAccess(1);
                            else if (getMembershipAttributes().getLossAction().isNoAccess())
                                getCachePerfStats().incReliableRegionsMissingNoAccess(1);
                            if (logger.isDebugEnabled()) {
                                logger.debug("Initialization completed with missing required roles: {}", this.missingRequiredRoles);
                            }
                            this.isInitializingThread = true;
                            lostReliability(null, null);
                        }
                    }
                }
            }
        } catch (RegionDestroyedException ignore) {
        // ignore to fix bug 34639 may be thrown by waitForRequiredRoles
        } catch (CancelException e) {
            // ignore to fix bug 34639 may be thrown by waitForRequiredRoles
            if (this.isInitializingThread) {
                throw e;
            }
        } catch (Exception e) {
            logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributedRegion_UNEXPECTED_EXCEPTION), e);
        }
    }
    // open latch which will allow any threads in lostReliability to proceed
    this.initializationLatchAfterMemberTimeout.countDown();
}
Also used : Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) CancelException(org.apache.geode.CancelException) TimeoutException(org.apache.geode.cache.TimeoutException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) RegionDistributionException(org.apache.geode.cache.RegionDistributionException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) IOException(java.io.IOException) RoleException(org.apache.geode.cache.RoleException) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) RegionAccessException(org.apache.geode.cache.RegionAccessException) FunctionException(org.apache.geode.cache.execute.FunctionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) PersistentReplicatesOfflineException(org.apache.geode.cache.persistence.PersistentReplicatesOfflineException)

Example 37 with RegionDestroyedException

use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.

the class DiskStoreImpl method get.

/**
   * Returns the value of the key/value pair with the given diskId. Updates all of the necessary
   * {@linkplain DiskRegionStats statistics}
   * 
   */
Object get(DiskRegion dr, DiskId id) {
    acquireReadLock(dr);
    try {
        int count = 0;
        RuntimeException ex = null;
        while (count < 3) {
            // retry at most 3 times
            BytesAndBits bb = null;
            try {
                if (dr.isRegionClosed()) {
                    throw new RegionDestroyedException(LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED.toLocalizedString(), dr.getName());
                }
                if (dr.didClearCountChange()) {
                    return Token.REMOVED_PHASE1;
                }
                bb = getBytesAndBitsWithoutLock(dr, id, true, /* fault -in */
                false);
                if (bb == CLEAR_BB) {
                    return Token.REMOVED_PHASE1;
                }
                return convertBytesAndBitsIntoObject(bb);
            } catch (IllegalArgumentException e) {
                count++;
                if (logger.isDebugEnabled()) {
                    logger.debug("DiskRegion: Tried {}, getBytesAndBitsWithoutLock returns wrong byte array: {}", count, Arrays.toString(bb.getBytes()));
                }
                ex = e;
            }
        }
        // while
        if (logger.isDebugEnabled()) {
            logger.debug("Retried 3 times, getting entry from DiskRegion still failed. It must be Oplog file corruption due to HA");
        }
        throw ex;
    } finally {
        releaseReadLock(dr);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) BytesAndBits(org.apache.geode.internal.cache.persistence.BytesAndBits)

Example 38 with RegionDestroyedException

use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.

the class DiskStoreImpl method writeRVV.

public void writeRVV(DiskRegion dr, LocalRegion region, Boolean isRVVTrusted) {
    acquireReadLock(dr);
    try {
        if (dr.isRegionClosed()) {
            dr.getCancelCriterion().checkCancelInProgress(null);
            throw new RegionDestroyedException(LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED.toLocalizedString(), dr.getName());
        }
        RegionVersionVector inMemoryRVV = (region == null) ? null : region.getVersionVector();
        // persist the new GC RVV information for this region to the CRF
        PersistentOplogSet oplogSet = getPersistentOplogSet(dr);
        // use current dr.rvvTrust
        oplogSet.getChild().writeRVV(dr, inMemoryRVV, isRVVTrusted);
    } finally {
        releaseReadLock(dr);
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RegionVersionVector(org.apache.geode.internal.cache.versions.RegionVersionVector)

Example 39 with RegionDestroyedException

use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.

the class PartitionedRegion method basicInvalidate.

@Override
void basicInvalidate(EntryEventImpl event) throws EntryNotFoundException {
    final long startTime = PartitionedRegionStats.startTime();
    try {
        if (event.getEventId() == null) {
            event.setNewEventId(this.cache.getDistributedSystem());
        }
        discoverJTA();
        getDataView().invalidateExistingEntry(event, isInitialized(), false);
    } catch (RegionDestroyedException rde) {
        if (!rde.getRegionFullPath().equals(getFullPath())) {
            // Handle when a bucket is destroyed
            throw new RegionDestroyedException(toString(), getFullPath(), rde);
        }
    } finally {
        this.prStats.endInvalidate(startTime);
    }
    return;
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException)

Example 40 with RegionDestroyedException

use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.

the class PartitionedRegion method sendDumpB2NRegionForBucket.

/**
   * Sends a message to all the {@code PartitionedRegion} participants, telling each member of the
   * PartitionedRegion to dump the nodelist in bucket2node metadata for specified bucketId.
   */
public void sendDumpB2NRegionForBucket(int bucketId) {
    getRegionAdvisor().dumpProfiles("dumpB2NForBucket");
    try {
        PartitionResponse response = DumpB2NRegion.send(this.getRegionAdvisor().adviseAllPRNodes(), this, bucketId, false);
        response.waitForRepliesUninterruptibly();
        this.dumpB2NForBucket(bucketId);
    } catch (ReplyException re) {
        if (logger.isDebugEnabled()) {
            logger.debug("sendDumpB2NRegionForBucket got ReplyException", re);
        }
    } catch (CancelException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("sendDumpB2NRegionForBucket got CacheClosedException", e);
        }
    } catch (RegionDestroyedException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("sendDumpB2RegionForBucket got RegionDestroyedException", e);
        }
    }
}
Also used : PartitionResponse(org.apache.geode.internal.cache.partitioned.PartitionMessage.PartitionResponse) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CancelException(org.apache.geode.CancelException) ReplyException(org.apache.geode.distributed.internal.ReplyException)

Aggregations

RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)124 CancelException (org.apache.geode.CancelException)41 LocalRegion (org.apache.geode.internal.cache.LocalRegion)37 Region (org.apache.geode.cache.Region)35 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)28 IOException (java.io.IOException)25 Cache (org.apache.geode.cache.Cache)20 CacheException (org.apache.geode.cache.CacheException)19 QueryException (org.apache.geode.cache.query.QueryException)16 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)16 ReplyException (org.apache.geode.distributed.internal.ReplyException)16 CacheClosedException (org.apache.geode.cache.CacheClosedException)14 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)14 SelectResults (org.apache.geode.cache.query.SelectResults)13 EventID (org.apache.geode.internal.cache.EventID)13 Test (org.junit.Test)13 Iterator (java.util.Iterator)12 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)12 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)12 QueryService (org.apache.geode.cache.query.QueryService)11