use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.
the class ReplyProcessor21 method getDistributionManager.
///////////////////// Instance Methods /////////////////////
/**
* get the distribution manager for this processor. If the distributed system has a distribution
* manager, it is used. Otherwise, we expect a distribution manager has been set with
* setDistributionManager and we'll use that
*/
protected DM getDistributionManager() {
try {
DM result = this.system.getDistributionManager();
if (result == null) {
result = this.dmgr;
Assert.assertTrue(result != null, "null DistributionManager");
}
return result;
} catch (IllegalStateException ex) {
// fix for bug 35000
this.system.getCancelCriterion().checkCancelInProgress(null);
throw new DistributedSystemDisconnectedException(ex.getMessage());
}
}
use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.
the class ReplyProcessor21 method stillWaiting.
/**
* We're still waiting if there is any member still left in the set and an exception hasn't been
* returned from anyone yet.
*
* @return true if we are still waiting for a response
*/
protected boolean stillWaiting() {
if (shutdown) {
// Create the exception here, so that the call stack reflects the
// failed computation. If you set the exception in onShutdown,
// the resulting stack is not of interest.
ReplyException re = new ReplyException(new DistributedSystemDisconnectedException(LocalizedStrings.ReplyProcessor21_ABORTED_DUE_TO_SHUTDOWN.toLocalizedString()));
this.exception = re;
return false;
}
// Optional override by subclass
if (canStopWaiting()) {
return false;
}
// If an error has occurred, we're done.
if (stopBecauseOfExceptions()) {
return false;
}
// All else is good, keep waiting if we have members to wait on.
return numMembers() > 0;
}
use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.
the class BucketAdvisor method getPrimaryLock.
/**
* Lazily gets the lock for acquiring primary lock. Caller must handle null. If DLS, Cache, or
* DistributedSystem are shutting down then null will be returned. If DLS does not yet exist and
* createDLS is false then null will be returned.
*
* @param createDLS true will create DLS if it does not exist
* @return distributed lock indicating primary member or null
*/
DistributedMemberLock getPrimaryLock(boolean createDLS) {
synchronized (this) {
if (this.primaryLock == null) {
DistributedLockService dls = DistributedLockService.getServiceNamed(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME);
if (dls == null) {
if (!createDLS || getProxyBucketRegion().getCache().isClosed()) {
// cache closure has destroyed the DLS
return null;
}
try {
// TODO: call GemFireCache#getPartitionedRegionLockService
dls = DLockService.create(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME, getAdvisee().getSystem(), true, /* distributed */
true, /* destroyOnDisconnect */
true);
} catch (IllegalArgumentException e) {
// indicates that the DLS is already created
dls = DistributedLockService.getServiceNamed(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME);
if (dls == null) {
// ok, caller will loop if necessary
return null;
}
}// perhaps: DistributedSystemUnavailableException
catch (IllegalStateException e) {
// create still throws IllegalStateException if isDisconnecting is true
return null;
} catch (DistributedSystemDisconnectedException e) {
// this would certainly prevent us from creating a DLS... messy
return null;
}
}
this.primaryLock = new DistributedMemberLock(dls, getAdvisee().getName(), DistributedMemberLock.NON_EXPIRING_LEASE, DistributedMemberLock.LockReentryPolicy.PREVENT_SILENTLY);
}
return this.primaryLock;
}
}
use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.
the class DestroyRegion method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, InterruptedException {
Part regionNamePart = null, callbackArgPart = null;
String regionName = null;
Object callbackArg = null;
Part eventPart = null;
StringBuffer errMessage = new StringBuffer();
CacheServerStats stats = serverConnection.getCacheServerStats();
serverConnection.setAsTrue(REQUIRES_RESPONSE);
{
long oldStart = start;
start = DistributionStats.getStatTime();
stats.incReadDestroyRegionRequestTime(start - oldStart);
}
// Retrieve the data from the message parts
regionNamePart = clientMessage.getPart(0);
eventPart = clientMessage.getPart(1);
// callbackArgPart = null; (redundant assignment)
if (clientMessage.getNumberOfParts() > 2) {
callbackArgPart = clientMessage.getPart(2);
try {
callbackArg = callbackArgPart.getObject();
} catch (DistributedSystemDisconnectedException se) {
// FIXME this can't happen
if (logger.isDebugEnabled()) {
logger.debug("{} ignoring message of type {} from client {} because shutdown occurred during message processing.", serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()), serverConnection.getProxyID());
}
serverConnection.setFlagProcessMessagesAsFalse();
serverConnection.setClientDisconnectedException(se);
return;
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
}
regionName = regionNamePart.getString();
if (logger.isDebugEnabled()) {
logger.debug("{}: Received destroy region request ({} bytes) from {} for region {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName);
}
// Process the destroy region request
if (regionName == null) {
logger.warn(LocalizedMessage.create(LocalizedStrings.DestroyRegion_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REGION_REQUEST_IS_NULL, serverConnection.getName()));
errMessage.append(LocalizedStrings.DestroyRegion__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REGION_REQUEST_IS_NULL.toLocalizedString());
writeErrorResponse(clientMessage, MessageType.DESTROY_REGION_DATA_ERROR, errMessage.toString(), serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
LocalRegion region = (LocalRegion) serverConnection.getCache().getRegion(regionName);
if (region == null) {
String reason = LocalizedStrings.DestroyRegion_REGION_WAS_NOT_FOUND_DURING_DESTROY_REGION_REQUEST.toLocalizedString();
writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
// Destroy the region
ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
EventID eventId = new EventID(serverConnection.getEventMemberIDByteArray(), threadId, sequenceId);
try {
// user needs to have data:manage on all regions in order to destory a particular region
this.securityService.authorizeDataManage();
AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
if (authzRequest != null) {
RegionDestroyOperationContext destroyContext = authzRequest.destroyRegionAuthorize(regionName, callbackArg);
callbackArg = destroyContext.getCallbackArg();
}
// region.destroyRegion(callbackArg);
region.basicBridgeDestroyRegion(callbackArg, serverConnection.getProxyID(), true, /* boolean from cache Client */
eventId);
} catch (DistributedSystemDisconnectedException e) {
// FIXME better exception hierarchy would avoid this check
if (serverConnection.getCachedRegionHelper().getCache().getCancelCriterion().cancelInProgress() != null) {
if (logger.isDebugEnabled()) {
logger.debug("{} ignoring message of type {} from client {} because shutdown occurred during message processing.", serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()), serverConnection.getProxyID());
}
serverConnection.setFlagProcessMessagesAsFalse();
serverConnection.setClientDisconnectedException(e);
} else {
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
}
return;
} catch (Exception e) {
// If an interrupted exception is thrown , rethrow it
checkForInterrupt(serverConnection, e);
// Otherwise, write an exception message and continue
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
// Update the statistics and write the reply
{
long oldStart = start;
start = DistributionStats.getStatTime();
stats.incProcessDestroyRegionTime(start - oldStart);
}
writeReply(clientMessage, serverConnection);
serverConnection.setAsTrue(RESPONDED);
if (logger.isDebugEnabled()) {
logger.debug("{}: Sent destroy region response for region {}", serverConnection.getName(), regionName);
}
stats.incWriteDestroyRegionResponseTime(DistributionStats.getStatTime() - start);
}
use of org.apache.geode.distributed.DistributedSystemDisconnectedException in project geode by apache.
the class InternalDistributedSystemJUnitTest method testAccessingClosedDistributedSystem.
@Test
public void testAccessingClosedDistributedSystem() {
Properties props = new Properties();
// a loner is all this test needs
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
InternalDistributedSystem system = createSystem(props);
system.disconnect();
try {
system.getDistributionManager();
fail("Should have thrown an IllegalStateException");
} catch (DistributedSystemDisconnectedException ex) {
// pass...
}
try {
system.getLogWriter();
} catch (IllegalStateException ex) {
fail("Shouldn't have thrown an IllegalStateException");
}
}
Aggregations