use of org.opendaylight.infrautils.ready.SystemReadyListener in project infrautils by opendaylight.
the class DiagStatusTestModule method configureBindings.
@Override
protected void configureBindings() throws UnknownHostException {
bind(DiagStatusService.class).to(DiagStatusServiceImpl.class);
bind(new TypeLiteral<List<ServiceStatusProvider>>() {
}).toInstance(Collections.emptyList());
bind(SystemReadyMonitor.class).annotatedWith(OsgiService.class).toInstance(new SystemReadyMonitor() {
@Override
public void registerListener(SystemReadyListener listener) {
// NOOP
}
@Override
public SystemState getSystemState() {
return SystemState.ACTIVE;
}
});
bind(DiagStatusServiceMBean.class).to(DiagStatusServiceMBeanImpl.class);
}
use of org.opendaylight.infrautils.ready.SystemReadyListener in project infrautils by opendaylight.
the class SystemReadyImpl method run.
@Override
// below
@SuppressWarnings("checkstyle:IllegalCatch")
public void run() {
try {
// 5 minutes really ought to be enough for the whole circus to completely boot up?!
testBundleDiag.checkBundleDiagInfos(5, TimeUnit.MINUTES, (timeInfo, bundleDiagInfos) -> LOG.info("checkBundleDiagInfos: Elapsed time {}s, remaining time {}s, {}", timeInfo.getElapsedTimeInMS() / 1000, timeInfo.getRemainingTimeInMS() / 1000, // INFRAUTILS-17: getSummaryText() instead getFullDiagnosticText() because ppl found log confusing
bundleDiagInfos.getSummaryText()));
currentSystemState.set(ACTIVE);
LOG.info("System ready; AKA: Aye captain, all warp coils are now operating at peak efficiency! [M.]");
if (!listeners.isEmpty()) {
LOG.info("Now notifying all its registered SystemReadyListeners...");
}
@Var SystemReadyListener listener;
while ((listener = listeners.poll()) != null) {
listener.onSystemBootReady();
}
} catch (SystemStateFailureException e) {
LOG.error("Failed, some bundles did not start (SystemReadyListeners are not called)", e);
currentSystemState.set(FAILURE);
// We do not re-throw this
} catch (RuntimeException throwable) {
// It's exceptionally OK to catch RuntimeException here,
// because we do want to set the currentFullSystemStatus
LOG.error("Failed unexpectedly (SystemReadyListeners are not called)", throwable);
currentSystemState.set(FAILURE);
// and now we do re-throw it!
throw throwable;
}
}
Aggregations