Search in sources :

Example 1 with ReenteredConnectException

use of org.apache.geode.internal.tcp.ReenteredConnectException in project geode by apache.

the class AlertAppender method append.

/**
   * This method is optimized with the assumption that at least one listener has set a level which
   * requires that the event be sent. This is ensured by modifying the appender's configuration
   * whenever a listener is added or removed.
   */
@Override
public void append(final LogEvent event) {
    if (this.alertingDisabled) {
        return;
    }
    // If already appending then don't send to avoid infinite recursion
    if ((alerting.get())) {
        return;
    }
    setIsAlerting(true);
    try {
        final boolean isDebugEnabled = logger.isDebugEnabled();
        if (isDebugEnabled) {
            logger.debug("Delivering an alert event: {}", event);
        }
        InternalDistributedSystem ds = this.systemRef.get();
        if (ds == null) {
            // Use info level to avoid triggering another alert
            logger.info("Did not append alert event because the distributed system is set to null.");
            return;
        }
        DistributionManager distMgr = (DistributionManager) ds.getDistributionManager();
        final int intLevel = logLevelToAlertLevel(event.getLevel().intLevel());
        final Date date = new Date(event.getTimeMillis());
        final String threadName = event.getThreadName();
        final String logMessage = event.getMessage().getFormattedMessage();
        final String stackTrace = ThreadUtils.stackTraceToString(event.getThrown(), true);
        final String connectionName = ds.getConfig().getName();
        for (Listener listener : this.listeners) {
            if (event.getLevel().intLevel() > listener.getLevel().intLevel()) {
                break;
            }
            try {
                AlertListenerMessage alertMessage = AlertListenerMessage.create(listener.getMember(), intLevel, date, connectionName, threadName, Thread.currentThread().getId(), logMessage, stackTrace);
                if (listener.getMember().equals(distMgr.getDistributionManagerId())) {
                    if (isDebugEnabled) {
                        logger.debug("Delivering local alert message: {}, {}, {}, {}, {}, [{}], [{}].", listener.getMember(), intLevel, date, connectionName, threadName, logMessage, stackTrace);
                    }
                    alertMessage.process(distMgr);
                } else {
                    if (isDebugEnabled) {
                        logger.debug("Delivering remote alert message: {}, {}, {}, {}, {}, [{}], [{}].", listener.getMember(), intLevel, date, connectionName, threadName, logMessage, stackTrace);
                    }
                    distMgr.putOutgoing(alertMessage);
                }
            } catch (ReenteredConnectException e) {
            // OK. We can't send to this recipient because we're in the middle of
            // trying to connect to it.
            }
        }
    } finally {
        setIsAlerting(false);
    }
}
Also used : ReenteredConnectException(org.apache.geode.internal.tcp.ReenteredConnectException) PropertyChangeListener(java.beans.PropertyChangeListener) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AlertListenerMessage(org.apache.geode.internal.admin.remote.AlertListenerMessage) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Date(java.util.Date)

Example 2 with ReenteredConnectException

use of org.apache.geode.internal.tcp.ReenteredConnectException 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

ReenteredConnectException (org.apache.geode.internal.tcp.ReenteredConnectException)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 NotSerializableException (java.io.NotSerializableException)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 CancelException (org.apache.geode.CancelException)1 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)1 IncompatibleSystemException (org.apache.geode.IncompatibleSystemException)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 InvalidDeltaException (org.apache.geode.InvalidDeltaException)1 SystemConnectException (org.apache.geode.SystemConnectException)1 ToDataException (org.apache.geode.ToDataException)1 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)1 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 AlertListenerMessage (org.apache.geode.internal.admin.remote.AlertListenerMessage)1