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);
}
}
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));
}
Aggregations