提交 0af3ec2f 编写于 作者: K kohsuke

modified to start monitoring slaves before anyone request the data,

so that the data is ready by the time someone shows up


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7919 71c3de6d-444a-0410-be80-ed276b4c234a
上级 da66d9e5
......@@ -21,21 +21,7 @@ import org.kohsuke.stapler.export.Exported;
*/
@ExportedBean
public final class ComputerSet implements ModelObject {
private static volatile List<NodeMonitor> monitors = Collections.emptyList();
public ComputerSet() {
if(monitors.isEmpty()) {
// create all instances when requested for the first time.
ArrayList<NodeMonitor> r = new ArrayList<NodeMonitor>();
for (Descriptor<NodeMonitor> d : NodeMonitor.LIST)
try {
r.add(d.newInstance(null,null));
} catch (FormException e) {
// so far impossible. TODO: report
}
monitors = r;
}
}
private static final List<NodeMonitor> monitors;
@Exported
public String getDisplayName() {
......@@ -67,4 +53,21 @@ public final class ComputerSet implements ModelObject {
public Api getApi() {
return new Api(this);
}
/**
* Just to force the execution of the static initializer.
*/
public static void initialize() {}
static {
// create all instances
ArrayList<NodeMonitor> r = new ArrayList<NodeMonitor>();
for (Descriptor<NodeMonitor> d : NodeMonitor.LIST)
try {
r.add(d.newInstance(null,null));
} catch (FormException e) {
// so far impossible. TODO: report
}
monitors = r;
}
}
package hudson.triggers;
import antlr.ANTLRException;
import hudson.DependencyRunner;
import hudson.ExtensionPoint;
import hudson.util.DoubleLaunchChecker;
import hudson.DependencyRunner.ProjectRunnable;
import hudson.ExtensionPoint;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Build;
import hudson.model.ComputerSet;
import hudson.model.Describable;
import hudson.model.FingerprintCleanupThread;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Project;
import hudson.model.WorkspaceCleanupThread;
import hudson.model.SlaveReconnectionWork;
import hudson.model.WorkspaceCleanupThread;
import hudson.scheduler.CronTab;
import hudson.scheduler.CronTabList;
import hudson.util.DoubleLaunchChecker;
import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
......@@ -28,8 +30,6 @@ import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import antlr.ANTLRException;
/**
* Triggers a {@link Build}.
*
......@@ -214,5 +214,12 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
timer.scheduleAtFixedRate(new FingerprintCleanupThread(),DAY,DAY);
timer.scheduleAtFixedRate(new WorkspaceCleanupThread(),DAY+4*HOUR,DAY);
timer.scheduleAtFixedRate(new SlaveReconnectionWork(),15*MIN,5*MIN);
// start monitoring nodes, although there's no hurry.
timer.schedule(new SafeTimerTask() {
public void doRun() {
ComputerSet.initialize();
}
}, 1000*10);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册