use of org.apache.geode.cache.CacheRuntimeException in project geode by apache.
the class DistTXAdjunctCommitMessage method basicProcessOps.
@Override
public void basicProcessOps() {
Collections.sort(this.farSideEntryOps);
Iterator it = this.farSideEntryOps.iterator();
while (it.hasNext()) {
try {
RegionCommit.FarSideEntryOp entryOp = (RegionCommit.FarSideEntryOp) it.next();
entryOp.processAdjunctOnly();
} catch (CacheRuntimeException problem) {
processCacheRuntimeException(problem);
} catch (Exception e) {
addProcessingException(e);
}
}
}
use of org.apache.geode.cache.CacheRuntimeException in project geode by apache.
the class TXCommitMessage method basicProcessOps.
public void basicProcessOps() {
List<EntryEventImpl> pendingCallbacks = new ArrayList<>(this.farSideEntryOps.size());
Collections.sort(this.farSideEntryOps);
Iterator it = this.farSideEntryOps.iterator();
while (it.hasNext()) {
try {
RegionCommit.FarSideEntryOp entryOp = (RegionCommit.FarSideEntryOp) it.next();
entryOp.process(pendingCallbacks);
} catch (CacheRuntimeException problem) {
processCacheRuntimeException(problem);
} catch (Exception e) {
addProcessingException(e);
}
}
firePendingCallbacks(pendingCallbacks);
}
use of org.apache.geode.cache.CacheRuntimeException in project geode by apache.
the class FlushMessage method process.
/*
* Used both for the reciept of a FlushMessage and the reply to a Flushmessage
*/
@Override
protected void process(DistributionManager dm) {
if (this.bucketId != Integer.MIN_VALUE) {
if (logger.isDebugEnabled()) {
logger.debug("Received sent FlushMessage {}", this);
}
try {
final PartitionedRegion p = PartitionedRegion.getPRFromId(this.prId);
Assert.assertTrue(p.getRegionAdvisor().isPrimaryForBucket(this.bucketId));
} catch (PRLocallyDestroyedException fre) {
if (logger.isDebugEnabled()) {
logger.debug("Sending reply despite Region getting locally destroyed prId={}", this.prId, fre);
}
} catch (CacheRuntimeException ce) {
logger.debug("Sending reply despite unavailable Partitioned Region using prId={}", this.prId, ce);
} finally {
dm.putOutgoing(new FlushMessage(this.prId, Integer.MIN_VALUE, getProcessorId(), getSender()));
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Processing FlushMessage as a response {}", this);
}
ReplyProcessor21 rep = ReplyProcessor21.getProcessor(this.processorId);
if (rep != null) {
rep.process(this);
}
}
}
use of org.apache.geode.cache.CacheRuntimeException in project geode by apache.
the class TXCommitMessage method basicProcess.
public void basicProcess() {
final DM dm = this.dm;
synchronized (this) {
if (isProcessing()) {
if (logger.isDebugEnabled()) {
logger.debug("TXCommitMessage {} is already in process, returning", this);
}
return;
} else {
setIsProcessing(true);
}
}
if (logger.isDebugEnabled()) {
logger.debug("begin processing TXCommitMessage for {}", this.txIdent);
}
// do this before CacheFactory.getInstance for bug 33471
final int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE);
// this gets flipped if we need to fire tx listener
boolean forceListener = false;
// it needs to default to false because we don't want to fire listeners on pr replicates
try {
TXRmtEvent txEvent = null;
final Cache cache = CacheFactory.getInstance(dm.getSystem());
if (cache == null) {
addProcessingException(new CacheClosedException());
// return ... this cache is closed so we can't do anything.
return;
}
final TransactionListener[] tls = cache.getCacheTransactionManager().getListeners();
if (tls.length > 0) {
txEvent = new TXRmtEvent(this.txIdent, cache);
}
try {
// Pre-process each Region in the tx
try {
Iterator it = this.regions.iterator();
while (it.hasNext()) {
boolean failedBeginProcess = true;
RegionCommit rc = (RegionCommit) it.next();
try {
failedBeginProcess = !rc.beginProcess(dm, this.txIdent, txEvent);
} catch (CacheRuntimeException problem) {
processCacheRuntimeException(problem);
} finally {
if (failedBeginProcess) {
// Cause related FarSideEntryOps to skip processing
rc.r = null;
// Skip endProcessing as well
it.remove();
}
}
}
basicProcessOps();
} finally {
// fix for bug 40001
// post-process each Region in the tx
Iterator it = this.regions.iterator();
while (it.hasNext()) {
try {
RegionCommit rc = (RegionCommit) it.next();
rc.endProcess();
if (rc.isForceFireEvent(dm)) {
forceListener = true;
}
} catch (CacheRuntimeException problem) {
processCacheRuntimeException(problem);
}
}
}
/*
* We need to make sure that we should fire a TX afterCommit event.
*/
boolean internalEvent = (txEvent != null && txEvent.hasOnlyInternalEvents());
if (!disableListeners && !internalEvent && (forceListener || (txEvent != null && !txEvent.isEmpty()))) {
for (int i = 0; i < tls.length; i++) {
try {
tls[i].afterCommit(txEvent);
} 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();
logger.error(LocalizedMessage.create(LocalizedStrings.TXCommitMessage_EXCEPTION_OCCURRED_IN_TRANSACTIONLISTENER), t);
}
}
}
} catch (CancelException e) {
processCacheRuntimeException(e);
} finally {
if (txEvent != null) {
txEvent.freeOffHeapResources();
}
}
} finally {
LocalRegion.setThreadInitLevelRequirement(oldLevel);
if (isAckRequired()) {
ack();
}
if (!GemFireCacheImpl.getExisting("Applying TXCommitMessage").isClient()) {
getTracker().saveTXForClientFailover(txIdent, this);
}
if (logger.isDebugEnabled()) {
logger.debug("completed processing TXCommitMessage for {}", this.txIdent);
}
}
}
use of org.apache.geode.cache.CacheRuntimeException in project geode by apache.
the class LocalRegion method clearRegionLocally.
/**
* Common code used by both clear and localClear. On the lines of destroyRegion, this method will
* be invoked for clearing the local cache.The cmnClearRegion will be overridden in the derived
* class DistributedRegion too. For clear operation , no CacheWriter will be invoked . It will
* only have afterClear callback. Also like destroyRegion & invalidateRegion , the clear operation
* will not take distributedLock. The clear operation will also clear the local tranxnl entries .
* The clear operation will have immediate committed state.
*/
void clearRegionLocally(RegionEventImpl regionEvent, boolean cacheWrite, RegionVersionVector vector) {
final boolean isRvvDebugEnabled = logger.isTraceEnabled(LogMarker.RVV);
RegionVersionVector rvv = vector;
if (this.serverRegionProxy != null) {
// clients and local regions do not maintain a full RVV. can't use it with clear()
rvv = null;
}
if (rvv != null && this.dataPolicy.withStorage()) {
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "waiting for my version vector to dominate{}mine={}{} other={}", getLineSeparator(), getLineSeparator(), this.versionVector.fullToString(), rvv);
}
boolean result = this.versionVector.waitToDominate(rvv, this);
if (!result) {
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "incrementing clearTimeouts for {} rvv={}", getName(), this.versionVector.fullToString());
}
getCachePerfStats().incClearTimeouts();
}
}
// If the initial image operation is still in progress then we need will have to do the clear
// operation at the end of the GII.For this we try to acquire the lock of GII the boolean
// returned is true that means lock was obtained which also means that GII is still in progress.
boolean isGIIinProgress = lockGII();
if (isGIIinProgress) {
// Also we should try & abort the GII
try {
getImageState().setClearRegionFlag(true, /* Clear region */
rvv);
} finally {
unlockGII();
}
}
if (cacheWrite && !isGIIinProgress) {
this.cacheWriteBeforeRegionClear(regionEvent);
}
RegionVersionVector myVector = getVersionVector();
if (myVector != null) {
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "processing version information for {}", regionEvent);
}
if (!regionEvent.isOriginRemote() && !regionEvent.getOperation().isLocal()) {
// generate a new version for the operation
VersionTag tag = VersionTag.create(getVersionMember());
tag.setVersionTimeStamp(cacheTimeMillis());
tag.setRegionVersion(myVector.getNextVersionWhileLocked());
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "generated version tag for clear: {}", tag);
}
regionEvent.setVersionTag(tag);
} else {
VersionTag tag = regionEvent.getVersionTag();
if (tag != null) {
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "recording version tag for clear: {}", tag);
}
// clear() events always have the ID in the tag
myVector.recordVersion(tag.getMemberID(), tag);
}
}
}
// Clear the expiration task for all the entries. It is possible that
// after clearing it some new entries may get added before issuing clear
// on the map , but that should be OK, as the expiration thread will
// silently move ahead if the entry to be expired no longer existed
this.cancelAllEntryExpiryTasks();
if (this.entryUserAttributes != null) {
this.entryUserAttributes.clear();
}
// be set to the current vector versions
if (rvv == null && myVector != null) {
myVector.removeOldVersions();
}
// clear the disk region if present
if (this.diskRegion != null) {
// persist current rvv and rvvgc which contained version for clear() itself
if (this.getDataPolicy().withPersistence()) {
// null means not to change dr.rvvTrust
if (isRvvDebugEnabled) {
logger.trace(LogMarker.RVV, "Clear: Saved current rvv: {}", this.diskRegion.getRegionVersionVector());
}
this.diskRegion.writeRVV(this, null);
this.diskRegion.writeRVVGC(this);
}
// clear the entries in disk
this.diskRegion.clear(this, rvv);
} else // this will be done in diskRegion.clear if it is not null else it has to be
// done here
{
// Now remove the tx entries for this region
txClearRegion();
// Now clear the map of committed entries
Set<VersionSource> remainingIDs = clearEntries(rvv);
if (!this.dataPolicy.withPersistence()) {
// persistent regions do not reap IDs
if (myVector != null) {
myVector.removeOldMembers(remainingIDs);
}
}
}
if (!isProxy()) {
// TODO made indexManager variable is made volatile. Is it necessary?
if (this.indexManager != null) {
try {
this.indexManager.rerunIndexCreationQuery();
} catch (QueryException qe) {
// TODO: never throw an annonymous class (and outer-class is not serializable)
throw new CacheRuntimeException(LocalizedStrings.LocalRegion_EXCEPTION_OCCURRED_WHILE_RE_CREATING_INDEX_DATA_ON_CLEARED_REGION.toLocalizedString(), qe) {
private static final long serialVersionUID = 0L;
};
}
}
}
if (ISSUE_CALLBACKS_TO_CACHE_OBSERVER) {
CacheObserverHolder.getInstance().afterRegionClear(regionEvent);
}
if (isGIIinProgress) {
return;
}
regionEvent.setEventType(EnumListenerEvent.AFTER_REGION_CLEAR);
// Issue a callback to afterClear if the region is initialized
boolean hasListener = hasListener();
if (hasListener) {
dispatchListenerEvent(EnumListenerEvent.AFTER_REGION_CLEAR, regionEvent);
}
}
Aggregations