Author: michiel
Date: 2009-05-18 19:44:34 +0200 (Mon, 18 May 2009)
New Revision: 35273
Modified:
mmbase/trunk/src/org/mmbase/util/ThreadPools.java
Log:
Less casting, exposing a map of availble threadpools for generialization of
jobs-overview in admin-pages
Modified: mmbase/trunk/src/org/mmbase/util/ThreadPools.java
===================================================================
--- mmbase/trunk/src/org/mmbase/util/ThreadPools.java 2009-05-18 17:04:25 UTC
(rev 35272)
+++ mmbase/trunk/src/org/mmbase/util/ThreadPools.java 2009-05-18 17:44:34 UTC
(rev 35273)
@@ -140,7 +140,7 @@
*
* @since MMBase-1.9
*/
- public static final ScheduledExecutorService scheduler = new
ScheduledThreadPoolExecutor(2, new ThreadFactory() {
+ public static final ScheduledThreadPoolExecutor scheduler = new
ScheduledThreadPoolExecutor(2, new ThreadFactory() {
public Thread newThread(Runnable r) {
return ThreadPools.newThread(r, "SchedulerThread-" +
(schedSeq++));
}
@@ -149,8 +149,18 @@
((ScheduledThreadPoolExecutor)
scheduler).setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
}
+ private static final Map<String, ExecutorService> threadPools = new
ConcurrentHashMap<String, ExecutorService>();
+ static {
+ threadPools.put("jobs", jobsExecutor);
+ threadPools.put("filters", filterExecutor);
+ threadPools.put("schedules", scheduler);
+ }
+ public static Map<String, ExecutorService> getThreadPools() {
+ return threadPools;
+ }
+
static final UtilReader properties = new UtilReader("threadpools.xml", new
Runnable() { public void run() { configure(); }});
/**
@@ -162,26 +172,26 @@
String max = props.get("jobs.maxsize");
if (max != null) {
int newSize = Integer.parseInt(max);
- if (((ThreadPoolExecutor) jobsExecutor).getMaximumPoolSize() !=
newSize) {
- log.info("Setting max pool size from " + ((ThreadPoolExecutor)
jobsExecutor).getMaximumPoolSize() + " to " + newSize);
- ((ThreadPoolExecutor)
jobsExecutor).setMaximumPoolSize(newSize);
+ if (jobsExecutor.getMaximumPoolSize() != newSize) {
+ log.info("Setting max pool size from " +
jobsExecutor.getMaximumPoolSize() + " to " + newSize);
+ jobsExecutor.setMaximumPoolSize(newSize);
}
}
String core = props.get("jobs.coresize");
if (core != null) {
int newSize = Integer.parseInt(core);
- if (((ThreadPoolExecutor) jobsExecutor).getCorePoolSize() !=
newSize) {
- log.info("Setting core pool size from " +
((ThreadPoolExecutor) jobsExecutor).getCorePoolSize() + " to " + newSize);
- ((ThreadPoolExecutor) jobsExecutor).setCorePoolSize(newSize);
+ if (jobsExecutor.getCorePoolSize() != newSize) {
+ log.info("Setting core pool size from " +
jobsExecutor.getCorePoolSize() + " to " + newSize);
+ jobsExecutor.setCorePoolSize(newSize);
}
}
String schedSize = props.get("scheduler.coresize");
if (schedSize != null) {
int newSize = Integer.parseInt(schedSize);
- if (((ThreadPoolExecutor) scheduler).getCorePoolSize() != newSize)
{
- log.info("Setting scheduler pool size from " +
((ThreadPoolExecutor) scheduler).getCorePoolSize() + " to " + schedSize);
- ((ThreadPoolExecutor) scheduler).setCorePoolSize(newSize);
+ if (scheduler.getCorePoolSize() != newSize) {
+ log.info("Setting scheduler pool size from " +
scheduler.getCorePoolSize() + " to " + schedSize);
+ scheduler.setCorePoolSize(newSize);
}
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs