use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class CreateRegionProcessor method initializeRegion.
/** this method tells other members that the region is being created */
public void initializeRegion() {
InternalDistributedSystem system = this.newRegion.getSystem();
// try 5 times, see CreateRegionMessage#skipDuringInitialization
for (int retry = 0; retry < 5; retry++) {
Set recps = getRecipients();
if (logger.isDebugEnabled()) {
logger.debug("Creating region {}", this.newRegion);
}
if (recps.isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug("CreateRegionProcessor.initializeRegion, no recipients, msg not sent");
}
this.newRegion.getDistributionAdvisor().setInitialized();
EventTracker tracker = ((LocalRegion) this.newRegion).getEventTracker();
if (tracker != null) {
tracker.setInitialized();
}
return;
}
CreateRegionReplyProcessor replyProc = new CreateRegionReplyProcessor(recps);
newRegion.registerCreateRegionReplyProcessor(replyProc);
// multicast is disabled for this message for now
boolean useMcast = false;
CreateRegionMessage msg = getCreateRegionMessage(recps, replyProc, useMcast);
// severe alert processing if we're creating one of them
if (((LocalRegion) newRegion).isUsedForPartitionedRegionBucket()) {
replyProc.enableSevereAlertProcessing();
msg.severeAlertCompatible = true;
}
this.newRegion.getDistributionManager().putOutgoing(msg);
// Reply procs are deregistered when they return from waitForReplies
try {
// Don't allow a region to be created if the distributed system is
// disconnecting
this.newRegion.getCache().getCancelCriterion().checkCancelInProgress(null);
// // Similarly, don't allow new regions to be created if the cache is closing
try {
replyProc.waitForRepliesUninterruptibly();
if (!replyProc.needRetry()) {
break;
}
} catch (ReplyException e) {
Throwable t = e.getCause();
if (t instanceof IllegalStateException) {
// region is incompatible with region in another cache
throw (IllegalStateException) t;
}
e.handleAsUnexpected();
break;
}
} finally {
replyProc.cleanup();
EventTracker tracker = ((LocalRegion) this.newRegion).getEventTracker();
if (tracker != null) {
tracker.setInitialized();
}
if (((LocalRegion) this.newRegion).isUsedForPartitionedRegionBucket()) {
if (logger.isDebugEnabled()) {
logger.debug("initialized bucket event tracker: {}", tracker);
}
}
}
}
// while
// tell advisor that it has been initialized since a profile exchange occurred
this.newRegion.getDistributionAdvisor().setInitialized();
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class LocalRegion method basicDestroyRegion.
void basicDestroyRegion(RegionEventImpl event, boolean cacheWrite, boolean lock, boolean callbackEvents) throws CacheWriterException, TimeoutException {
preDestroyChecks();
final TXStateProxy tx = this.cache.getTXMgr().internalSuspend();
try {
boolean acquiredLock = false;
if (lock) {
try {
acquireDestroyLock();
acquiredLock = true;
} catch (CancelException ignore) {
if (logger.isDebugEnabled()) {
logger.debug("basicDestroyRegion: acquireDestroyLock failed due to cache closure, region = {}", getFullPath());
}
}
}
try {
// maintain destroy lock and TXStateInterface
// I moved checkRegionDestroyed up out of the following
// try block because it does not seem correct to deliver
// a destroy event to the clients of the region was already
// destroyed on the server.
checkRegionDestroyed(false);
// see bug 47736
boolean cancelledByCacheWriterException = false;
HashSet eventSet = null;
try {
// ensure that destroy events are dispatched
if (this instanceof PartitionedRegion && !((PartitionedRegion) this).getParallelGatewaySenderIds().isEmpty()) {
((PartitionedRegion) this).destroyParallelGatewaySenderRegion(event.getOperation(), cacheWrite, lock, callbackEvents);
}
if (this.parentRegion != null) {
// "Bubble up" the cache statistics to parent if this regions are more recent
this.parentRegion.updateStats();
}
try {
eventSet = callbackEvents ? new HashSet() : null;
this.destroyedSubregionSerialNumbers = collectSubregionSerialNumbers();
recursiveDestroyRegion(eventSet, event, cacheWrite);
} catch (CancelException e) {
// a serious problem.
if (!this.cache.forcedDisconnect()) {
logger.warn(LocalizedMessage.create(LocalizedStrings.LocalRegion_RECURSIVEDESTROYREGION_RECURSION_FAILED_DUE_TO_CACHE_CLOSURE_REGION_0, getFullPath()), e);
}
} catch (CacheWriterException cwe) {
cancelledByCacheWriterException = true;
throw cwe;
}
// at this point all subregions are destroyed and this region has been marked as destroyed
// and postDestroyRegion has been called for each region. The only detail left is
// unhooking this region from the parent subregion map, and sending listener events
Assert.assertTrue(this.isDestroyed);
// artifacts From Management Layer
if (!isInternalRegion()) {
InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
system.handleResourceEvent(ResourceEvent.REGION_REMOVE, this);
}
try {
LocalRegion parent = this.parentRegion;
if (parent == null) {
this.cache.removeRoot(this);
} else {
parent.subregions.remove(this.regionName, this);
}
} catch (CancelException e) {
// I don't think this should ever happens: bulletproofing for bug 39454
if (!this.cache.forcedDisconnect()) {
logger.warn(LocalizedMessage.create(LocalizedStrings.LocalRegion_BASICDESTROYREGION_PARENT_REMOVAL_FAILED_DUE_TO_CACHE_CLOSURE_REGION_0, getFullPath()), e);
}
}
} finally {
// ensure that destroy events are dispatched
if (!cancelledByCacheWriterException) {
// We only need to notify bridgeClients of the top level region destroy
// which it will take and do a localRegionDestroy.
// So we pass it event and NOT eventSet
event.setEventType(EnumListenerEvent.AFTER_REGION_DESTROY);
notifyBridgeClients(event);
}
// since some of the destroys happened.
if (eventSet != null && callbackEvents) {
try {
sendPendingRegionDestroyEvents(eventSet);
} catch (CancelException ignore) {
// ignore, we're mute.
}
}
}
} finally {
if (acquiredLock) {
try {
releaseDestroyLock();
} catch (CancelException ignore) {
// ignore
}
}
}
} finally {
this.cache.getTXMgr().internalResume(tx);
}
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class ServerPingMessage method send.
/**
* Sends a ping message. The pre-GFXD_101 recipients are filtered out and it is assumed that they
* are pingable.
*
* @return true if all the recipients are pingable
*/
public static boolean send(InternalCache cache, Set<InternalDistributedMember> recipients) {
InternalDistributedSystem ids = cache.getInternalDistributedSystem();
DM dm = ids.getDistributionManager();
Set<InternalDistributedMember> filteredRecipients = new HashSet<InternalDistributedMember>();
// filtered recipients
for (InternalDistributedMember recipient : recipients) {
if (Version.GFE_81.compareTo(recipient.getVersionObject()) <= 0) {
filteredRecipients.add(recipient);
}
}
if (filteredRecipients == null || filteredRecipients.size() == 0)
return true;
ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, filteredRecipients);
ServerPingMessage spm = new ServerPingMessage(replyProcessor);
spm.setRecipients(filteredRecipients);
Set failedServers = null;
try {
if (cache.getLoggerI18n().fineEnabled())
cache.getLoggerI18n().fine("Pinging following servers " + filteredRecipients);
failedServers = dm.putOutgoing(spm);
// wait for the replies for timeout msecs
boolean receivedReplies = replyProcessor.waitForReplies(0L);
dm.getCancelCriterion().checkCancelInProgress(null);
// If the reply is not received in the stipulated time, throw an exception
if (!receivedReplies) {
cache.getLoggerI18n().error(LocalizedStrings.Server_Ping_Failure, filteredRecipients);
return false;
}
} catch (Throwable e) {
cache.getLoggerI18n().error(LocalizedStrings.Server_Ping_Failure, filteredRecipients, e);
return false;
}
if (failedServers == null || failedServers.size() == 0)
return true;
cache.getLoggerI18n().info(LocalizedStrings.Server_Ping_Failure, failedServers);
return false;
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class AcceptorImpl method calcBindHostName.
/**
* @param bindName the ip address or host name that this acceptor should bind to. If null or ""
* then calculate it.
* @return the ip address or host name this acceptor will listen on. An "" if all local addresses
* will be listened to.
*
* @since GemFire 5.7
*/
private static String calcBindHostName(Cache cache, String bindName) {
if (bindName != null && !bindName.equals("")) {
return bindName;
}
InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
DistributionConfig config = system.getConfig();
String hostName = null;
// Get the server-bind-address. If it is not null, use it.
// If it is null, get the bind-address. If it is not null, use it.
// Otherwise set default.
String serverBindAddress = config.getServerBindAddress();
if (serverBindAddress != null && serverBindAddress.length() > 0) {
hostName = serverBindAddress;
} else {
String bindAddress = config.getBindAddress();
if (bindAddress != null && bindAddress.length() > 0) {
hostName = bindAddress;
}
}
return hostName;
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class CacheClientNotifier method deliverInterestChange.
protected void deliverInterestChange(ClientProxyMembershipID proxyID, ClientInterestMessageImpl message) {
DM dm = ((InternalDistributedSystem) this.getCache().getDistributedSystem()).getDistributionManager();
ServerInterestRegistrationMessage.sendInterestChange(dm, proxyID, message);
}
Aggregations