Search in sources :

Example 76 with CancelException

use of org.apache.geode.CancelException in project geode by apache.

the class AbstractGatewaySender method distribute.

public void distribute(EnumListenerEvent operation, EntryEventImpl event, List<Integer> allRemoteDSIds) {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    // If this gateway is not running, return
    if (!isRunning()) {
        if (isDebugEnabled) {
            logger.debug("Returning back without putting into the gateway sender queue");
        }
        return;
    }
    final GatewaySenderStats stats = getStatistics();
    stats.incEventsReceived();
    if (!checkForDistribution(event, stats)) {
        stats.incEventsNotQueued();
        return;
    }
    // not considering this filter
    if (!this.filter.enqueueEvent(event)) {
        stats.incEventsFiltered();
        return;
    }
    // released by this method or transfers ownership to TmpQueueEvent
    @Released EntryEventImpl clonedEvent = new EntryEventImpl(event, false);
    boolean freeClonedEvent = true;
    try {
        Region region = event.getRegion();
        setModifiedEventId(clonedEvent);
        Object callbackArg = clonedEvent.getRawCallbackArgument();
        if (isDebugEnabled) {
            // We can't deserialize here for logging purposes so don't
            // call getNewValue.
            // event.getNewValue(); // to deserialize the value if necessary
            logger.debug("{} : About to notify {} to perform operation {} for {} callback arg {}", this.isPrimary(), getId(), operation, clonedEvent, callbackArg);
        }
        if (callbackArg instanceof GatewaySenderEventCallbackArgument) {
            GatewaySenderEventCallbackArgument seca = (GatewaySenderEventCallbackArgument) callbackArg;
            if (isDebugEnabled) {
                logger.debug("{}: Event originated in {}. My DS id is {}. The remote DS id is {}. The recipients are: {}", this, seca.getOriginatingDSId(), this.getMyDSId(), this.getRemoteDSId(), seca.getRecipientDSIds());
            }
            if (seca.getOriginatingDSId() == DEFAULT_DISTRIBUTED_SYSTEM_ID) {
                if (isDebugEnabled) {
                    logger.debug("{}: Event originated in {}. My DS id is {}. The remote DS id is {}. The recipients are: {}", this, seca.getOriginatingDSId(), this.getMyDSId(), this.getRemoteDSId(), seca.getRecipientDSIds());
                }
                seca.setOriginatingDSId(this.getMyDSId());
                seca.initializeReceipientDSIds(allRemoteDSIds);
            } else {
                // if the dispatcher is GatewaySenderEventCallbackDispatcher (which is the case of WBCL),
                // skip the below check of remoteDSId.
                // Fix for #46517
                AbstractGatewaySenderEventProcessor ep = getEventProcessor();
                if (ep != null && !(ep.getDispatcher() instanceof GatewaySenderEventCallbackDispatcher)) {
                    if (seca.getOriginatingDSId() == this.getRemoteDSId()) {
                        if (isDebugEnabled) {
                            logger.debug("{}: Event originated in {}. My DS id is {}. It is being dropped as remote is originator.", this, seca.getOriginatingDSId(), getMyDSId());
                        }
                        return;
                    } else if (seca.getRecipientDSIds().contains(this.getRemoteDSId())) {
                        if (isDebugEnabled) {
                            logger.debug("{}: Event originated in {}. My DS id is {}. The remote DS id is {}.. It is being dropped as remote ds is already a recipient. Recipients are: {}", this, seca.getOriginatingDSId(), getMyDSId(), this.getRemoteDSId(), seca.getRecipientDSIds());
                        }
                        return;
                    }
                }
                seca.getRecipientDSIds().addAll(allRemoteDSIds);
            }
        } else {
            GatewaySenderEventCallbackArgument geCallbackArg = new GatewaySenderEventCallbackArgument(callbackArg, this.getMyDSId(), allRemoteDSIds);
            clonedEvent.setCallbackArgument(geCallbackArg);
        }
        if (!this.getLifeCycleLock().readLock().tryLock()) {
            synchronized (this.queuedEventsSync) {
                if (!this.enqueuedAllTempQueueEvents) {
                    if (!this.getLifeCycleLock().readLock().tryLock()) {
                        Object substituteValue = getSubstituteValue(clonedEvent, operation);
                        this.tmpQueuedEvents.add(new TmpQueueEvent(operation, clonedEvent, substituteValue));
                        freeClonedEvent = false;
                        stats.incTempQueueSize();
                        if (isDebugEnabled) {
                            logger.debug("Event : {} is added to TempQueue", clonedEvent);
                        }
                        return;
                    }
                }
            }
            if (this.enqueuedAllTempQueueEvents) {
                this.getLifeCycleLock().readLock().lock();
            }
        }
        try {
            // The sender may have stopped, after we have checked the status in the beginning.
            if (!isRunning()) {
                if (isDebugEnabled) {
                    logger.debug("Returning back without putting into the gateway sender queue");
                }
                return;
            }
            try {
                AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
                if (ev == null) {
                    getStopper().checkCancelInProgress(null);
                    this.getCache().getDistributedSystem().getCancelCriterion().checkCancelInProgress(null);
                    // connecting to the other site (bug #40681)
                    if (ev == null) {
                        throw new GatewayCancelledException("Event processor thread is gone");
                    }
                }
                // Get substitution value to enqueue if necessary
                Object substituteValue = getSubstituteValue(clonedEvent, operation);
                ev.enqueueEvent(operation, clonedEvent, substituteValue);
            } catch (CancelException e) {
                logger.debug("caught cancel exception", e);
                throw e;
            } catch (RegionDestroyedException e) {
                logger.warn(LocalizedMessage.create(LocalizedStrings.GatewayImpl_0_AN_EXCEPTION_OCCURRED_WHILE_QUEUEING_1_TO_PERFORM_OPERATION_2_FOR_3, new Object[] { this, getId(), operation, clonedEvent }), e);
            } catch (Exception e) {
                logger.fatal(LocalizedMessage.create(LocalizedStrings.GatewayImpl_0_AN_EXCEPTION_OCCURRED_WHILE_QUEUEING_1_TO_PERFORM_OPERATION_2_FOR_3, new Object[] { this, getId(), operation, clonedEvent }), e);
            }
        } finally {
            this.getLifeCycleLock().readLock().unlock();
        }
    } finally {
        if (freeClonedEvent) {
            // fix for bug 48035
            clonedEvent.release();
        }
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) GatewayCancelledException(org.apache.geode.distributed.GatewayCancelledException) RegionExistsException(org.apache.geode.cache.RegionExistsException) BucketMovedException(org.apache.geode.internal.cache.execute.BucketMovedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) GatewayCancelledException(org.apache.geode.distributed.GatewayCancelledException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException)

Example 77 with CancelException

use of org.apache.geode.CancelException in project geode by apache.

the class CacheUtils method init.

public static String init(DistributedSystem ds1, String className) throws Exception {
    System.out.println("Entering CacheUtils.init, DS is " + ds1);
    String tableName = "";
    try {
        try {
            cache = CacheFactory.getInstance(ds1);
        } catch (CancelException cce) {
            cache = CacheFactory.create(ds1);
        }
        if (className != null && !className.equals("")) {
            String time = new Long(System.currentTimeMillis()).toString();
            tableName = className + time;
            createTable(tableName);
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
        throw new Exception("Exception in CacheUtils::init, The Exception is " + e);
    }
    return tableName;
}
Also used : CancelException(org.apache.geode.CancelException) NamingException(javax.naming.NamingException) SQLException(java.sql.SQLException) CancelException(org.apache.geode.CancelException)

Example 78 with CancelException

use of org.apache.geode.CancelException in project geode by apache.

the class ClientCQImpl method close.

@Override
public void close(boolean sendRequestToServer) throws CqClosedException, CqException {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (isDebugEnabled) {
        logger.debug("Started closing CQ CqName: {} SendRequestToServer: {}", cqName, sendRequestToServer);
    }
    // Synchronize with stop and execute CQ commands
    synchronized (this.cqState) {
        // Check if the cq is already closed.
        if (this.isClosed()) {
            // throw new CqClosedException("CQ is already closed, CqName : " + this.cqName);
            if (isDebugEnabled) {
                logger.debug("CQ is already closed, CqName: {}", this.cqName);
            }
            return;
        }
        int stateBeforeClosing = this.cqState.getState();
        this.cqState.setState(CqStateImpl.CLOSING);
        boolean isClosed = false;
        // Client Close. Proxy is null in case of server.
        // Check if this has been sent to server, if so send
        // Close request to server.
        Exception exception = null;
        if (this.cqProxy != null && sendRequestToServer) {
            try {
                if (this.proxyCache != null) {
                    if (this.proxyCache.isClosed()) {
                        throw new CacheClosedException("Cache is closed for this user.");
                    }
                    UserAttributes.userAttributes.set(this.proxyCache.getUserAttributes());
                }
                cqProxy.close(this);
                isClosed = true;
            } catch (CancelException e) {
                throw e;
            } catch (Exception ex) {
                if (shutdownInProgress()) {
                    return;
                }
                exception = ex;
            } finally {
                UserAttributes.userAttributes.set(null);
            }
        }
        // Cleanup the resource used by cq.
        this.removeFromCqMap();
        if (cqProxy == null || !sendRequestToServer || isClosed) {
            // Stat update.
            if (stateBeforeClosing == CqStateImpl.RUNNING) {
                cqService.stats().decCqsActive();
            } else if (stateBeforeClosing == CqStateImpl.STOPPED) {
                cqService.stats().decCqsStopped();
            }
            // Set the state to close, and update stats
            this.cqState.setState(CqStateImpl.CLOSED);
            cqService.stats().incCqsClosed();
            cqService.stats().decCqsOnClient();
            if (this.stats != null)
                this.stats.close();
        } else {
            if (shutdownInProgress()) {
                return;
            }
            // Hasn't able to send close request to any server.
            if (exception != null) {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_CLOSE_THE_CQ_CQNAME_0_ERROR_FROM_LAST_ENDPOINT_1.toLocalizedString(this.cqName, exception.getLocalizedMessage()), exception.getCause());
            } else {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_CLOSE_THE_CQ_CQNAME_0_THE_SERVER_ENDPOINTS_ON_WHICH_THIS_CQ_WAS_REGISTERED_WERE_NOT_FOUND.toLocalizedString(this.cqName));
            }
        }
    }
    // Invoke close on Listeners if any.
    if (this.cqAttributes != null) {
        CqListener[] cqListeners = this.getCqAttributes().getCqListeners();
        if (cqListeners != null) {
            if (isDebugEnabled) {
                logger.debug("Invoking CqListeners close() api for the CQ, CqName: {} Number of CqListeners: {}", cqName, cqListeners.length);
            }
            for (int lCnt = 0; lCnt < cqListeners.length; lCnt++) {
                try {
                    cqListeners[lCnt].close();
                // Handle client side exceptions.
                } catch (Exception ex) {
                    logger.warn(LocalizedMessage.create(LocalizedStrings.CqQueryImpl_EXCEPTION_OCCOURED_IN_THE_CQLISTENER_OF_THE_CQ_CQNAME_0_ERROR_1, new Object[] { cqName, ex.getLocalizedMessage() }));
                    if (isDebugEnabled) {
                        logger.debug(ex.getMessage(), ex);
                    }
                } 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.warn(LocalizedMessage.create(LocalizedStrings.CqQueryImpl_RUNTIMEEXCEPTION_OCCOURED_IN_THE_CQLISTENER_OF_THE_CQ_CQNAME_0_ERROR_1, new Object[] { cqName, t.getLocalizedMessage() }));
                    if (isDebugEnabled) {
                        logger.debug(t.getMessage(), t);
                    }
                }
            }
        }
    }
    if (isDebugEnabled) {
        logger.debug("Successfully closed the CQ. {}", cqName);
    }
}
Also used : CqException(org.apache.geode.cache.query.CqException) CqListener(org.apache.geode.cache.query.CqListener) CacheClosedException(org.apache.geode.cache.CacheClosedException) CancelException(org.apache.geode.CancelException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqException(org.apache.geode.cache.query.CqException) CacheClosedException(org.apache.geode.cache.CacheClosedException) CancelException(org.apache.geode.CancelException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) CqClosedException(org.apache.geode.cache.query.CqClosedException)

Example 79 with CancelException

use of org.apache.geode.CancelException in project geode by apache.

the class InternalDistributedSystem method reconnect.

/**
   * A reconnect is tried when gemfire is configured to reconnect in case of a required role loss.
   * The reconnect will try reconnecting to the distributed system every max-time-out millseconds
   * for max-number-of-tries configured in gemfire.properties file. It uses the cache.xml file to
   * intialize the cache and create regions.
   */
private void reconnect(boolean forcedDisconnect, String reason) {
    // Collect all the state for cache
    // Collect all the state for Regions
    // Close the cache,
    // loop trying to connect, waiting before each attempt
    //
    // If reconnecting for lost-roles the reconnected system's cache will decide
    // whether the reconnected system should stay up. After max-tries we will
    // give up.
    //
    // If reconnecting for forced-disconnect we ignore max-tries and keep attempting
    // to join the distributed system until successful
    this.attemptingToReconnect = true;
    InternalDistributedSystem ids = InternalDistributedSystem.getAnyInstance();
    if (ids == null) {
        ids = this;
    }
    // first save the current cache description. This is created by
    // the membership manager when forced-disconnect starts. If we're
    // reconnecting for lost roles then this will be null
    String cacheXML = null;
    List<CacheServerCreation> cacheServerCreation = null;
    InternalCache cache = GemFireCacheImpl.getInstance();
    if (cache != null) {
        cacheXML = cache.getCacheConfig().getCacheXMLDescription();
        cacheServerCreation = cache.getCacheConfig().getCacheServerCreation();
    }
    DistributionConfig oldConfig = ids.getConfig();
    Properties configProps = getProperties();
    int timeOut = oldConfig.getMaxWaitTimeForReconnect();
    int maxTries = oldConfig.getMaxNumReconnectTries();
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (Thread.currentThread().getName().equals("DisconnectThread")) {
        if (isDebugEnabled) {
            logger.debug("changing thread name to ReconnectThread");
        }
        Thread.currentThread().setName("ReconnectThread");
    }
    // get the membership manager for quorum checks
    MembershipManager mbrMgr = this.dm.getMembershipManager();
    this.quorumChecker = mbrMgr.getQuorumChecker();
    if (logger.isDebugEnabled()) {
        if (quorumChecker == null) {
            logger.debug("No quorum checks will be performed during reconnect attempts");
        } else {
            logger.debug("Initialized quorum checking service: {}", quorumChecker);
        }
    }
    // LOG:CLEANUP: deal with reconnect and INHIBIT_DM_BANNER -- this should be ok now
    String appendToLogFile = System.getProperty(APPEND_TO_LOG_FILE);
    if (appendToLogFile == null) {
        System.setProperty(APPEND_TO_LOG_FILE, "true");
    }
    String inhibitBanner = System.getProperty(InternalLocator.INHIBIT_DM_BANNER);
    if (inhibitBanner == null) {
        System.setProperty(InternalLocator.INHIBIT_DM_BANNER, "true");
    }
    if (forcedDisconnect) {
        systemAttemptingReconnect = this;
    }
    try {
        while (this.reconnectDS == null || !this.reconnectDS.isConnected()) {
            if (isReconnectCancelled()) {
                break;
            }
            if (!forcedDisconnect) {
                if (isDebugEnabled) {
                    logger.debug("Max number of tries : {} and max time out : {}", maxTries, timeOut);
                }
                if (reconnectAttemptCounter >= maxTries) {
                    if (isDebugEnabled) {
                        logger.debug("Stopping the checkrequiredrole thread because reconnect : {} reached the max number of reconnect tries : {}", reconnectAttemptCounter, maxTries);
                    }
                    throw new CacheClosedException(LocalizedStrings.InternalDistributedSystem_SOME_REQUIRED_ROLES_MISSING.toLocalizedString());
                }
            }
            if (reconnectAttemptCounter == 0) {
                reconnectAttemptTime = System.currentTimeMillis();
            }
            reconnectAttemptCounter++;
            if (isReconnectCancelled()) {
                return;
            }
            logger.info("Disconnecting old DistributedSystem to prepare for a reconnect attempt");
            try {
                disconnect(true, reason, false);
            } catch (Exception ee) {
                logger.warn("Exception disconnecting for reconnect", ee);
            }
            try {
                reconnectLock.wait(timeOut);
            } catch (InterruptedException e) {
                logger.warn(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_WAITING_THREAD_FOR_RECONNECT_GOT_INTERRUPTED));
                Thread.currentThread().interrupt();
                return;
            }
            if (isReconnectCancelled()) {
                return;
            }
            logger.info(LocalizedMessage.create(LocalizedStrings.DISTRIBUTED_SYSTEM_RECONNECTING, new Object[] { reconnectAttemptCounter }));
            int savNumOfTries = reconnectAttemptCounter;
            try {
                // notify listeners of each attempt and then again after successful
                notifyReconnectListeners(this, this.reconnectDS, true);
                if (this.locatorDMTypeForced) {
                    System.setProperty(InternalLocator.FORCE_LOCATOR_DM_TYPE, "true");
                }
                configProps.put(DistributionConfig.DS_RECONNECTING_NAME, Boolean.TRUE);
                if (quorumChecker != null) {
                    configProps.put(DistributionConfig.DS_QUORUM_CHECKER_NAME, quorumChecker);
                }
                InternalDistributedSystem newDS = null;
                if (isReconnectCancelled()) {
                    return;
                }
                try {
                    newDS = (InternalDistributedSystem) connect(configProps);
                } catch (CancelException e) {
                    if (isReconnectCancelled()) {
                        return;
                    } else {
                        throw e;
                    }
                } finally {
                    if (newDS == null && quorumChecker != null) {
                        // make sure the quorum checker is listening for messages from former members
                        quorumChecker.resume();
                    }
                }
                if (this.reconnectCancelled) {
                    newDS.disconnect();
                    continue;
                }
                this.reconnectDS = newDS;
            } catch (SystemConnectException e) {
                logger.debug("Attempt to reconnect failed with SystemConnectException");
                if (e.getMessage().contains("Rejecting the attempt of a member using an older version")) {
                    logger.warn(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_EXCEPTION_OCCURRED_WHILE_TRYING_TO_CONNECT_THE_SYSTEM_DURING_RECONNECT), e);
                    attemptingToReconnect = false;
                    return;
                }
                continue;
            } catch (GemFireConfigException e) {
                if (isDebugEnabled) {
                    logger.debug("Attempt to reconnect failed with GemFireConfigException");
                }
                continue;
            } catch (Exception ee) {
                logger.warn(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_EXCEPTION_OCCURRED_WHILE_TRYING_TO_CONNECT_THE_SYSTEM_DURING_RECONNECT), ee);
                attemptingToReconnect = false;
                return;
            } finally {
                if (this.locatorDMTypeForced) {
                    System.getProperties().remove(InternalLocator.FORCE_LOCATOR_DM_TYPE);
                }
                reconnectAttemptCounter = savNumOfTries;
            }
            DM newDM = this.reconnectDS.getDistributionManager();
            if (newDM instanceof DistributionManager) {
                // a cache
                if (((DistributionManager) newDM).getDMType() != DistributionManager.ADMIN_ONLY_DM_TYPE) {
                    try {
                        CacheConfig config = new CacheConfig();
                        if (cacheXML != null) {
                            config.setCacheXMLDescription(cacheXML);
                        }
                        cache = GemFireCacheImpl.create(this.reconnectDS, config);
                        createAndStartCacheServers(cacheServerCreation, cache);
                        if (cache.getCachePerfStats().getReliableRegionsMissing() == 0) {
                            reconnectAttemptCounter = 0;
                        } else {
                        // this try failed. The new cache will call reconnect again
                        }
                    } catch (CacheXmlException e) {
                        logger.warn("Exception occurred while trying to create the cache during reconnect", e);
                        reconnectDS.disconnect();
                        reconnectDS = null;
                        reconnectCancelled = true;
                        break;
                    } catch (CancelException ignor) {
                        logger.warn("Exception occurred while trying to create the cache during reconnect", ignor);
                        reconnectDS.disconnect();
                        reconnectDS = null;
                    } catch (Exception e) {
                        logger.warn(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_EXCEPTION_OCCURRED_WHILE_TRYING_TO_CREATE_THE_CACHE_DURING_RECONNECT), e);
                    }
                }
            }
            if (reconnectDS != null && reconnectDS.isConnected()) {
                // make sure the new DS and cache are stable before exiting this loop
                try {
                    Thread.sleep(config.getMemberTimeout() * 3);
                } catch (InterruptedException e) {
                    logger.info("Reconnect thread has been interrupted - exiting");
                    Thread.currentThread().interrupt();
                    return;
                }
            }
        }
        if (isReconnectCancelled()) {
            reconnectDS.disconnect();
        } else {
            reconnectDS.isReconnectingDS = false;
            notifyReconnectListeners(this, this.reconnectDS, false);
        }
    } finally {
        systemAttemptingReconnect = null;
        attemptingToReconnect = false;
        if (appendToLogFile == null) {
            System.getProperties().remove(APPEND_TO_LOG_FILE);
        } else {
            System.setProperty(APPEND_TO_LOG_FILE, appendToLogFile);
        }
        if (inhibitBanner == null) {
            System.getProperties().remove(InternalLocator.INHIBIT_DM_BANNER);
        } else {
            System.setProperty(InternalLocator.INHIBIT_DM_BANNER, inhibitBanner);
        }
        if (quorumChecker != null) {
            mbrMgr.releaseQuorumChecker(quorumChecker);
        }
    }
    if (isReconnectCancelled()) {
        logger.debug("reconnect can no longer be done because of an explicit disconnect");
        if (reconnectDS != null) {
            reconnectDS.disconnect();
        }
        attemptingToReconnect = false;
        return;
    } else {
        logger.info("Reconnect completed.\nNew DistributedSystem is {}\nNew Cache is {}", reconnectDS, cache);
    }
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) CacheClosedException(org.apache.geode.cache.CacheClosedException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CacheXmlException(org.apache.geode.cache.CacheXmlException) CancelException(org.apache.geode.CancelException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) ManagementException(org.apache.geode.management.ManagementException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) GemFireIOException(org.apache.geode.GemFireIOException) CacheClosedException(org.apache.geode.cache.CacheClosedException) SystemConnectException(org.apache.geode.SystemConnectException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) CacheXmlException(org.apache.geode.cache.CacheXmlException) CacheServerCreation(org.apache.geode.internal.cache.xmlcache.CacheServerCreation) GemFireConfigException(org.apache.geode.GemFireConfigException) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager) GMSMembershipManager(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager) CancelException(org.apache.geode.CancelException) CacheConfig(org.apache.geode.internal.cache.CacheConfig) SystemConnectException(org.apache.geode.SystemConnectException)

Example 80 with CancelException

use of org.apache.geode.CancelException in project geode by apache.

the class DistributionManager method sendMessage.

/**
   * @return recipients who did not receive the message
   * @throws NotSerializableException If <codE>message</code> cannot be serialized
   */
Set sendMessage(DistributionMessage message) throws NotSerializableException {
    Set result = null;
    try {
        // Verify we're not too far into the shutdown
        stopper.checkCancelInProgress(null);
        // avoid race condition during startup
        waitUntilReadyToSendMsgs(message);
        result = sendOutgoing(message);
    } catch (NotSerializableException ex) {
        // serialization error in user data
        throw ex;
    } catch (ToDataException ex) {
        // serialization error in user data
        throw ex;
    } catch (ReenteredConnectException ex) {
        // Recursively tried to get the same connection
        throw ex;
    } catch (CancelException ex) {
        // bug 37194, shutdown conditions
        throw ex;
    } catch (InvalidDeltaException ide) {
        logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_CAUGHT_EXCEPTION_WHILE_SENDING_DELTA), ide.getCause());
        throw (RuntimeException) ide.getCause();
    } catch (Exception ex) {
        DistributionManager.this.exceptionInThreads = true;
        String receiver = "NULL";
        if (message != null) {
            receiver = message.getRecipientsDescription();
        }
        logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionManager_WHILE_PUSHING_MESSAGE_0_TO_1, new Object[] { message, receiver }), ex);
        if (message == null || message.forAll())
            return null;
        result = new HashSet();
        for (int i = 0; i < message.getRecipients().length; i++) result.add(message.getRecipients()[i]);
        return result;
    /*
       * if (ex instanceof org.apache.geode.GemFireIpcResourceException) { return; }
       */
    }
    return result;
}
Also used : ReenteredConnectException(org.apache.geode.internal.tcp.ReenteredConnectException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) NotSerializableException(java.io.NotSerializableException) Set(java.util.Set) HashSet(java.util.HashSet) ToDataException(org.apache.geode.ToDataException) CancelException(org.apache.geode.CancelException) IncompatibleSystemException(org.apache.geode.IncompatibleSystemException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) CancelException(org.apache.geode.CancelException) InternalGemFireException(org.apache.geode.InternalGemFireException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) SystemConnectException(org.apache.geode.SystemConnectException) NoSuchElementException(java.util.NoSuchElementException) NotSerializableException(java.io.NotSerializableException) UnknownHostException(java.net.UnknownHostException) ReenteredConnectException(org.apache.geode.internal.tcp.ReenteredConnectException) ToDataException(org.apache.geode.ToDataException) HashSet(java.util.HashSet)

Aggregations

CancelException (org.apache.geode.CancelException)135 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)46 IOException (java.io.IOException)40 ReplyException (org.apache.geode.distributed.internal.ReplyException)30 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)25 CacheClosedException (org.apache.geode.cache.CacheClosedException)23 Region (org.apache.geode.cache.Region)22 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)21 LocalRegion (org.apache.geode.internal.cache.LocalRegion)18 Set (java.util.Set)16 Cache (org.apache.geode.cache.Cache)16 CacheException (org.apache.geode.cache.CacheException)16 HashSet (java.util.HashSet)15 Iterator (java.util.Iterator)15 QueryException (org.apache.geode.cache.query.QueryException)15 ArrayList (java.util.ArrayList)13 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)13 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)13 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)13 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)13