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;
}
}
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);
}
}
}
}
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);
}
}
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;
}
Aggregations