提交 12084e63 编写于 作者: K kohsuke

rolling back parallel loading for now.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3416 71c3de6d-444a-0410-be80-ed276b4c234a
上级 72031621
......@@ -27,20 +27,12 @@ import hudson.scm.RepositoryBrowsers;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.scm.SCMS;
import hudson.tasks.BuildStep;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrappers;
import hudson.tasks.Builder;
import hudson.tasks.DynamicLabeler;
import hudson.tasks.LabelFinder;
import hudson.tasks.Mailer;
import hudson.tasks.Publisher;
import hudson.tasks.*;
import hudson.triggers.Trigger;
import hudson.triggers.TriggerDescriptor;
import hudson.triggers.Triggers;
import hudson.util.CopyOnWriteList;
import hudson.util.CopyOnWriteMap;
import hudson.util.DaemonThreadFactory;
import hudson.util.FormFieldValidator;
import hudson.util.MultipartFormDataParser;
import hudson.util.XStream2;
......@@ -83,14 +75,6 @@ import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
......@@ -934,7 +918,6 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
private synchronized void load() throws IOException {
long startTime = System.currentTimeMillis();
XmlFile cfg = getConfigFile();
if(cfg.exists())
cfg.unmarshal(this);
......@@ -950,26 +933,15 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
return child.isDirectory();
}
});
// load jobs in parallel for
items.clear();
List<Future<TopLevelItem>> loaders = new ArrayList<Future<TopLevelItem>>();
for (final File subdir : subdirs) {
loaders.add(threadPoolForLoad.submit(new Callable<TopLevelItem>() {
public TopLevelItem call() throws Exception {
return (TopLevelItem)Items.load(Hudson.this,subdir);
}
}));
}
for (Future<TopLevelItem> loader : loaders) {
for (File subdir : subdirs) {
try {
TopLevelItem item = loader.get();
TopLevelItem item = (TopLevelItem)Items.load(this,subdir);
items.put(item.getName(), item);
} catch (ExecutionException e) {
e.getCause().printStackTrace(); // TODO: logging
} catch (InterruptedException e) {
e.printStackTrace(); // this is probably not the right thing to do
} catch (Error e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace(); // TODO: logging
}
}
rebuildDependencyGraph();
......@@ -979,7 +951,7 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
for (Slave slave : slaves)
slave.getAssignedLabels();
}
LOGGER.info(String.format("Took %s ms to load",System.currentTimeMillis()-startTime));
}
......@@ -1673,23 +1645,13 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
*/
private static final XStream XSTREAM = new XStream2();
private static final Logger LOGGER = Logger.getLogger(Hudson.class.getName());
/**
* Thread pool used to load configuration in parallel, to improve the start up time.
*
* The idea here is to overlap the CPU and I/O, so we want more threads than CPU numbers.
*/
/*package*/ static final ExecutorService threadPoolForLoad = new ThreadPoolExecutor(
0, Runtime.getRuntime().availableProcessors()*2,
5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new DaemonThreadFactory());
/**
* Version number of this Hudson.
*/
public static String VERSION;
private static final Logger LOGGER = Logger.getLogger(Hudson.class.getName());
static {
XSTREAM.alias("hudson",Hudson.class);
XSTREAM.alias("slave",Slave.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册