Search in sources :

Example 1 with SystemStateFailureException

use of org.opendaylight.odlparent.bundlestest.lib.SystemStateFailureException 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;
    }
}
Also used : Var(com.google.errorprone.annotations.Var) SystemReadyListener(org.opendaylight.infrautils.ready.SystemReadyListener) SystemStateFailureException(org.opendaylight.odlparent.bundlestest.lib.SystemStateFailureException)

Aggregations

Var (com.google.errorprone.annotations.Var)1 SystemReadyListener (org.opendaylight.infrautils.ready.SystemReadyListener)1 SystemStateFailureException (org.opendaylight.odlparent.bundlestest.lib.SystemStateFailureException)1