use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class LocalRegion method initialize.
/**
* Do any extra initialization required. Region is already visible in parent's subregion map. This
* method releases the initialization Latches, so subclasses should call this super method last
* after performing additional initialization.
*
* @param imageTarget ignored, used by subclass for get initial image
* @see DistributedRegion#initialize(InputStream, InternalDistributedMember,
* InternalRegionArguments)
*/
protected void initialize(InputStream snapshotInputStream, InternalDistributedMember imageTarget, InternalRegionArguments internalRegionArgs) throws TimeoutException, IOException, ClassNotFoundException {
if (!isInternalRegion()) {
// acceptable because addResourceListener won't add it twice
if (!this.isDestroyed) {
this.cache.getInternalResourceManager().addResourceListener(ResourceType.MEMORY, this);
}
}
// if we're versioning entries we need a region-level version vector
if (this.concurrencyChecksEnabled && this.versionVector == null) {
createVersionVector();
}
// if not local, then recovery happens in InitialImageOperation
if (this.scope.isLocal()) {
createOQLIndexes(internalRegionArgs);
if (this.diskRegion != null) {
try {
this.diskRegion.initializeOwner(this);
this.diskRegion.finishInitializeOwner(this, GIIStatus.NO_GII);
// This block was added so that early recovery could figure out that
// this data needs to be recovered from disk. Local regions used to
// not bother assigning a memberId but that is what the early
// recovery
// code uses to figure out that a region needs to be recovered.
PersistentMemberID oldId = this.diskRegion.getMyInitializingID();
if (oldId == null) {
oldId = this.diskRegion.getMyPersistentID();
}
if (oldId == null) {
PersistentMemberID newId = this.diskRegion.generatePersistentID();
this.diskRegion.setInitializing(newId);
this.diskRegion.setInitialized();
}
} catch (DiskAccessException dae) {
releaseAfterRegionCreateEventLatch();
this.handleDiskAccessException(dae, true);
throw dae;
}
}
}
// make sure latches are released if they haven't been by now already
releaseBeforeGetInitialImageLatch();
if (snapshotInputStream != null && this.scope.isLocal()) {
try {
loadSnapshotDuringInitialization(snapshotInputStream);
} catch (DiskAccessException dae) {
releaseAfterRegionCreateEventLatch();
this.handleDiskAccessException(dae);
throw dae;
}
}
releaseAfterGetInitialImageLatch();
if (logger.isDebugEnabled()) {
logger.debug("Calling addExpiryTasks for {}", this);
}
// at this point
try {
addIdleExpiryTask();
addTTLExpiryTask();
if (isEntryExpiryPossible()) {
// called after gii to fix bug 35214
rescheduleEntryExpiryTasks();
}
initialized();
} catch (RegionDestroyedException ignore) {
// whether it is this region or a parent region that is destroyed,
// then so must we be
Assert.assertTrue(isDestroyed());
// just proceed, a destroyed region will be returned to caller
}
}
use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class LocalRegion method remove.
/**
* Same as {@link #remove(Object, Object)} except a callback argument is supplied to be passed on
* to <tt>CacheListener</tt>s and/or <tt>CacheWriter</tt>s.
*/
public boolean remove(Object key, Object value, Object callbackArg) {
checkIfConcurrentMapOpsAllowed();
validateKey(key);
validateCallbackArg(callbackArg);
checkReadiness();
checkForLimitedOrNoAccess();
if (value == null) {
value = Token.INVALID;
}
@Released EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVE, key, null, callbackArg, false, getMyId());
try {
if (generateEventID() && event.getEventId() == null) {
event.setNewEventId(this.cache.getDistributedSystem());
}
discoverJTA();
getDataView().destroyExistingEntry(event, true, value);
} catch (EntryNotFoundException ignore) {
return false;
} catch (RegionDestroyedException rde) {
if (!rde.getRegionFullPath().equals(getFullPath())) {
// Handle when a bucket is destroyed
throw new RegionDestroyedException(toString(), getFullPath(), rde);
} else {
throw rde;
}
} finally {
event.release();
}
return true;
}
use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class RemoteOperationMessage method process.
/**
* Upon receipt of the message, both process the message and send an acknowledgement, not
* necessarily in that order. Note: Any hang in this message may cause a distributed deadlock for
* those threads waiting for an acknowledgement.
*
* @throws PartitionedRegionException if the region does not exist (typically, if it has been
* destroyed)
*/
@Override
public void process(final DistributionManager dm) {
Throwable thr = null;
boolean sendReply = true;
LocalRegion r = null;
long startTime = 0;
try {
if (checkCacheClosing(dm) || checkDSClosing(dm)) {
thr = new CacheClosedException(LocalizedStrings.PartitionMessage_REMOTE_CACHE_IS_CLOSED_0.toLocalizedString(dm.getId()));
return;
}
InternalCache cache = getCache(dm);
r = getRegionByPath(cache);
if (r == null && failIfRegionMissing()) {
// if the distributed system is disconnecting, don't send a reply saying
// the partitioned region can't be found (bug 36585)
thr = new RegionDestroyedException(LocalizedStrings.RemoteOperationMessage_0_COULD_NOT_FIND_REGION_1.toLocalizedString(dm.getDistributionManagerId(), regionPath), regionPath);
// reply sent in finally block below
return;
}
thr = UNHANDLED_EXCEPTION;
// [bruce] r might be null here, so we have to go to the cache instance to get the txmgr
TXManagerImpl txMgr = getTXManager(cache);
TXStateProxy tx = txMgr.masqueradeAs(this);
if (tx == null) {
sendReply = operateOnRegion(dm, r, startTime);
} else {
try {
if (txMgr.isClosed()) {
// NO DISTRIBUTED MESSAGING CAN BE DONE HERE!
sendReply = false;
} else if (tx.isInProgress()) {
sendReply = operateOnRegion(dm, r, startTime);
tx.updateProxyServer(this.getSender());
}
} finally {
txMgr.unmasquerade(tx);
}
}
thr = null;
} catch (RemoteOperationException fre) {
thr = fre;
} catch (DistributedSystemDisconnectedException se) {
// bug 37026: this is too noisy...
// throw new CacheClosedException("remote system shutting down");
// thr = se; cache is closed, no point trying to send a reply
thr = null;
sendReply = false;
if (logger.isDebugEnabled()) {
logger.debug("shutdown caught, abandoning message: {}", se.getMessage(), se);
}
} catch (RegionDestroyedException rde) {
// [bruce] RDE does not always mean that the sender's region is also
// destroyed, so we must send back an exception. If the sender's
// region is also destroyed, who cares if we send it an exception
// if (pr != null && pr.isClosed) {
thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_REGION_IS_DESTROYED_IN_0.toLocalizedString(dm.getDistributionManagerId()), rde);
// }
} 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();
// log the exception at fine level if there is no reply to the message
thr = null;
if (sendReply) {
if (!checkDSClosing(dm)) {
thr = t;
} else {
// don't pass arbitrary runtime exceptions and errors back if this
// cache/vm is closing
thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_DISTRIBUTED_SYSTEM_IS_DISCONNECTING.toLocalizedString());
}
}
if (logger.isTraceEnabled(LogMarker.DM) && (t instanceof RuntimeException)) {
logger.trace(LogMarker.DM, "Exception caught while processing message", t);
}
} finally {
if (sendReply) {
ReplyException rex = null;
if (thr != null) {
// don't transmit the exception if this message was to a listener
// and this listener is shutting down
rex = new ReplyException(thr);
}
// Send the reply if the operateOnPartitionedRegion returned true
sendReply(getSender(), this.processorId, dm, rex, r, startTime);
}
}
}
use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class StateFlushOperation method flushTo.
/** flush current ops to the given members for the given region */
public static void flushTo(Set<InternalDistributedMember> targets, DistributedRegion region) {
DM dm = region.getDistributionManager();
boolean initialized = region.isInitialized();
if (initialized) {
// force a new "view" so we can track current ops
region.getDistributionAdvisor().forceNewMembershipVersion();
try {
region.getDistributionAdvisor().waitForCurrentOperations();
} catch (RegionDestroyedException ignore) {
return;
}
}
// send all state-flush messages and then wait for replies
Set<ReplyProcessor21> processors = new HashSet<ReplyProcessor21>();
for (InternalDistributedMember target : targets) {
StateStabilizationMessage gr = new StateStabilizationMessage();
// new for flushTo operation
gr.isSingleFlushTo = true;
gr.requestingMember = dm.getDistributionManagerId();
gr.setRecipient(target);
ReplyProcessor21 processor = new ReplyProcessor21(dm, target);
gr.processorId = processor.getProcessorId();
gr.channelState = dm.getMembershipManager().getMessageState(target, false);
if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP) && ((gr.channelState != null) && (gr.channelState.size() > 0))) {
logger.trace(LogMarker.STATE_FLUSH_OP, "channel states: {}", gr.channelStateDescription(gr.channelState));
}
if (logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP)) {
logger.trace(LogMarker.STATE_FLUSH_OP, "Sending {}", gr);
}
dm.putOutgoing(gr);
processors.add(processor);
}
if (region.getRegionMap().getARMLockTestHook() != null) {
region.getRegionMap().getARMLockTestHook().beforeStateFlushWait();
}
for (ReplyProcessor21 processor : processors) {
try {
processor.waitForReplies();
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
return;
}
}
}
use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class HARegionQueue method updateHAContainer.
/**
* Called from destroy(), this method decrements the referenceCount of all the HAEventWrapper
* instances held by this queue. Also, removes those instances whose referenceCount becomes zero.
*
* @since GemFire 5.7
*/
private void updateHAContainer() {
try {
Object[] wrapperArray = null;
acquireReadLock();
try {
if (this.availableIDsSize() != 0) {
wrapperArray = this.availableIDsArray();
}
} finally {
releaseReadLock();
}
if (wrapperArray != null) {
final Set wrapperSet = new HashSet();
for (int i = 0; i < wrapperArray.length; i++) {
wrapperSet.add(this.region.get(wrapperArray[i]));
}
// Start a new thread which will update the clientMessagesRegion for
// each of the HAEventWrapper instances present in the wrapperSet
Thread regionCleanupTask = new Thread(new Runnable() {
public void run() {
try {
Iterator iter = wrapperSet.iterator();
while (iter.hasNext()) {
Conflatable conflatable = (Conflatable) iter.next();
if (conflatable instanceof HAEventWrapper) {
HARegionQueue.this.decAndRemoveFromHAContainer((HAEventWrapper) conflatable);
}
}
} catch (CancelException ignore) {
// we're done
return;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Exception in regionCleanupTask thread of HARegionQueue.updateHAContainer$run()", e);
}
}
}
});
regionCleanupTask.start();
}
} catch (CancelException e) {
throw e;
} catch (RegionDestroyedException e) {
// TODO does this really generate a CancelException, or do we still
// get a warning in the logs?
// Odds are we're shutting down...
this.getRegion().getCache().getCancelCriterion().checkCancelInProgress(e);
// If we get back, this is Really Weird. Treat it like the
// Exception case below.
logger.warn("HARegionQueue.updateHAContainer: underlying region has been destroyed", e);
} catch (Exception e) {
logger.warn(LocalizedMessage.create(LocalizedStrings.HARegionQueue_TASK_TO_DECREMENT_THE_REF_COUNT_MAY_NOT_HAVE_BEEN_STARTED), e);
}
}
Aggregations