Search in sources :

Example 1 with AlertListener

use of org.apache.geode.admin.AlertListener in project geode by apache.

the class AdminDistributedSystemImpl method alert.

// ----------- org.apache.geode.internal.admin.AlertListener -----------
/**
   * Listener callback for when a SystemMember of this DistributedSystem has crashed.
   *
   * @param alert the latest alert from the system
   * @see org.apache.geode.internal.admin.AlertListener#alert
   */
public void alert(org.apache.geode.internal.admin.Alert alert) {
    if (AlertLevel.forSeverity(alert.getLevel()).ordinal < alertLevel.ordinal) {
        return;
    }
    Alert alert2 = new AlertImpl(alert);
    this.latestAlert = alert2;
    for (Iterator<AlertListener> iter = this.alertListeners.iterator(); iter.hasNext(); ) {
        AlertListener listener = iter.next();
        listener.alert(alert2);
    }
}
Also used : Alert(org.apache.geode.admin.Alert) AlertListener(org.apache.geode.admin.AlertListener)

Example 2 with AlertListener

use of org.apache.geode.admin.AlertListener in project geode by apache.

the class DistributionManagerDUnitTest method createAlertListener.

static void createAlertListener() throws Exception {
    DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(getSystemStatic(), null);
    adminSystem = AdminDistributedSystemFactory.getDistributedSystem(config);
    adminSystem.setAlertLevel(AlertLevel.SEVERE);
    adminSystem.addAlertListener(new AlertListener() {

        public void alert(Alert alert) {
            try {
                logger.info("alert listener invoked for alert originating in " + alert.getConnectionName());
                logger.info("  alert text = " + alert.getMessage());
                logger.info("  systemMember = " + alert.getSystemMember());
            } catch (Exception e) {
                logger.fatal("exception trying to use alert object", e);
            }
            synchronized (alertGuard) {
                alertReceived = true;
            }
        }
    });
    adminSystem.connect();
    assertTrue(adminSystem.waitToBeConnected(5 * 1000));
}
Also used : DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) Alert(org.apache.geode.admin.Alert) AlertListener(org.apache.geode.admin.AlertListener) UnknownHostException(java.net.UnknownHostException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Aggregations

Alert (org.apache.geode.admin.Alert)2 AlertListener (org.apache.geode.admin.AlertListener)2 UnknownHostException (java.net.UnknownHostException)1 DistributedSystemConfig (org.apache.geode.admin.DistributedSystemConfig)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1