use of org.apache.geode.cache.RegionDestroyedException in project geode by apache.
the class QueueStateImpl method handleMarker.
public void handleMarker() {
ArrayList regions = new ArrayList();
Cache cache = GemFireCacheImpl.getInstance();
if (cache == null) {
return;
}
Set rootRegions = cache.rootRegions();
for (Iterator iter1 = rootRegions.iterator(); iter1.hasNext(); ) {
Region rootRegion = (Region) iter1.next();
regions.add(rootRegion);
try {
// throws RDE
Set subRegions = rootRegion.subregions(true);
for (Iterator iter2 = subRegions.iterator(); iter2.hasNext(); ) {
regions.add(iter2.next());
}
} catch (RegionDestroyedException e) {
// region is gone go to the next one bug 38705
continue;
}
}
for (Iterator iter = regions.iterator(); iter.hasNext(); ) {
LocalRegion region = (LocalRegion) iter.next();
try {
if (region.getAttributes().getPoolName() != null && region.getAttributes().getPoolName().equals(qManager.getPool().getName())) {
// can this throw RDE??
region.handleMarker();
}
} catch (RegionDestroyedException e) {
// region is gone go to the next one bug 38705
continue;
}
}
}
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();
}
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);
}
}
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);
}
}
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;
}
Aggregations