Author: doogie
Date: Wed Aug 13 19:38:01 2014 New Revision: 1617809 URL: http://svn.apache.org/r1617809 Log: Add a global fork-join thread pool, and switch a bunch of stuff over to it. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java?rev=1617809&r1=1617808&r2=1617809&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java Wed Aug 13 19:38:01 2014 @@ -25,6 +25,7 @@ import java.util.concurrent.DelayQueue; import java.util.concurrent.Delayed; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; @@ -39,6 +40,7 @@ import org.ofbiz.base.util.Debug; public final class ExecutionPool { public static final String module = ExecutionPool.class.getName(); public static final ScheduledExecutorService GLOBAL_EXECUTOR = getExecutor(null, "OFBiz-config", -1, false); + public static final ForkJoinPool GLOBAL_FORK_JOIN = getForkJoinPool(-1); protected static class ExecutionPoolThreadFactory implements ThreadFactory { private final ThreadGroup group; @@ -83,6 +85,10 @@ public final class ExecutionPool { return executor; } + public static ForkJoinPool getForkJoinPool(int threadCount) { + return new ForkJoinPool(autoAdjustThreadCount(threadCount)); + } + public static <F> List<F> getAllFutures(Collection<Future<F>> futureList) { List<F> result = FastList.newInstance(); for (Future<F> future: futureList) { Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=1617809&r1=1617808&r2=1617809&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Wed Aug 13 19:38:01 2014 @@ -90,13 +90,13 @@ public class EntityEcaUtil { List<Future<List<EntityEcaRule>>> futures = FastList.newInstance(); for (Resource eecaResourceElement : entityEcaReaderInfo.getResourceList()) { ResourceHandler handler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, eecaResourceElement.getLoader(), eecaResourceElement.getLocation()); - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(handler))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(handler))); } // get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file for (ComponentConfig.EntityResourceInfo componentResourceInfo: ComponentConfig.getAllEntityResourceInfos("eca")) { if (entityEcaReaderName.equals(componentResourceInfo.readerName)) { - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler()))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler()))); } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java?rev=1617809&r1=1617808&r2=1617809&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java Wed Aug 13 19:38:01 2014 @@ -258,12 +258,12 @@ public class DispatchContext implements } for (GlobalServices globalServices : globalServicesList) { ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.SERVICE_ENGINE_XML_FILENAME, globalServices.getLoader(), globalServices.getLocation()); - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createServiceReaderCallable(handler))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createServiceReaderCallable(handler))); } // get all of the component resource model stuff, ie specified in each ofbiz-component.xml file for (ComponentConfig.ServiceResourceInfo componentResourceInfo: ComponentConfig.getAllServiceResourceInfos("model")) { - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createServiceReaderCallable(componentResourceInfo.createResourceHandler()))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createServiceReaderCallable(componentResourceInfo.createResourceHandler()))); } for (Map<String, ModelService> servicesMap: ExecutionPool.getAllFutures(futures)) { if (servicesMap != null) { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java?rev=1617809&r1=1617808&r2=1617809&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java Wed Aug 13 19:38:01 2014 @@ -77,12 +77,12 @@ public class ServiceEcaUtil { } for (ServiceEcas serviceEcas : serviceEcasList) { ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.SERVICE_ENGINE_XML_FILENAME, serviceEcas.getLoader(), serviceEcas.getLocation()); - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(handler))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(handler))); } // get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file for (ComponentConfig.ServiceResourceInfo componentResourceInfo: ComponentConfig.getAllServiceResourceInfos("eca")) { - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler()))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler()))); } for (List<ServiceEcaRule> handlerRules: ExecutionPool.getAllFutures(futures)) { Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=1617809&r1=1617808&r2=1617809&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Wed Aug 13 19:38:01 2014 @@ -152,7 +152,7 @@ public class ArtifactInfoFactory { Set<String> serviceNames = this.getDispatchContext().getAllServiceNames(); for (String serviceName: serviceNames) { - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(prepareTaskForServiceAnalysis(serviceName))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(prepareTaskForServiceAnalysis(serviceName))); } // how to get all Service ECAs to prepare? don't worry about it, will be populated from service load, ie all ECAs for each service @@ -160,7 +160,7 @@ public class ArtifactInfoFactory { ExecutionPool.getAllFutures(futures); futures = new ArrayList<Future<Void>>(); for (ComponentConfig componentConfig: componentConfigs) { - futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(prepareTaskForComponentAnalysis(componentConfig))); + futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(prepareTaskForComponentAnalysis(componentConfig))); } ExecutionPool.getAllFutures(futures); Debug.logInfo("Artifact info objects loaded.", module); |
Free forum by Nabble | Edit this page |