Search in sources :

Example 1 with Milestone

use of org.jvnet.hudson.reactor.Milestone in project hudson-2.x by hudson.

the class Hudson method buildReactorListener.

/**
     * Aggregates all the listeners into one and returns it.
     *
     * <p>
     * At this point plugins are not loaded yet, so we fall back to the META-INF/services look up to discover implementations.
     * As such there's no way for plugins to participate into this process.
     */
private ReactorListener buildReactorListener() throws IOException {
    List<ReactorListener> r = (List) Service.loadInstances(Thread.currentThread().getContextClassLoader(), InitReactorListener.class);
    r.add(new ReactorListener() {

        final Level level = Level.parse(System.getProperty(Hudson.class.getName() + ".initLogLevel", "FINE"));

        public void onTaskStarted(Task t) {
            LOGGER.log(level, "Started " + t.getDisplayName());
        }

        public void onTaskCompleted(Task t) {
            LOGGER.log(level, "Completed " + t.getDisplayName());
        }

        public void onTaskFailed(Task t, Throwable err, boolean fatal) {
            LOGGER.log(Level.SEVERE, "Failed " + t.getDisplayName(), err);
        }

        public void onAttained(Milestone milestone) {
            Level lv = level;
            String s = "Attained " + milestone.toString();
            if (milestone instanceof InitMilestone) {
                // noteworthy milestones --- at least while we debug problems further
                lv = Level.INFO;
                initLevel = (InitMilestone) milestone;
                s = initLevel.toString();
            }
            LOGGER.log(lv, s);
        }
    });
    return new ReactorListener.Aggregator(r);
}
Also used : Task(org.jvnet.hudson.reactor.Task) Milestone(org.jvnet.hudson.reactor.Milestone) InitMilestone(hudson.init.InitMilestone) InitReactorListener(hudson.init.InitReactorListener) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) CopyOnWriteList(hudson.util.CopyOnWriteList) ExtensionList(hudson.ExtensionList) NodeList(hudson.slaves.NodeList) ArrayList(java.util.ArrayList) DescriptorExtensionList(hudson.DescriptorExtensionList) DescribableList(hudson.util.DescribableList) List(java.util.List) Level(java.util.logging.Level) InitReactorListener(hudson.init.InitReactorListener) ReactorListener(org.jvnet.hudson.reactor.ReactorListener) InitMilestone(hudson.init.InitMilestone)

Aggregations

DescriptorExtensionList (hudson.DescriptorExtensionList)1 ExtensionList (hudson.ExtensionList)1 InitMilestone (hudson.init.InitMilestone)1 InitReactorListener (hudson.init.InitReactorListener)1 NodeList (hudson.slaves.NodeList)1 CopyOnWriteList (hudson.util.CopyOnWriteList)1 DescribableList (hudson.util.DescribableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Level (java.util.logging.Level)1 Milestone (org.jvnet.hudson.reactor.Milestone)1 ReactorListener (org.jvnet.hudson.reactor.ReactorListener)1 Task (org.jvnet.hudson.reactor.Task)1