@@ -117,7 +117,8 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
117117 private volatile long _executionRunNumber = 1 ;
118118
119119 private final ScheduledExecutorService _heartbeatScheduler = Executors .newScheduledThreadPool (1 , new NamedThreadFactory ("AsyncJobMgr-Heartbeat" ));
120- private ExecutorService _executor ;
120+ private ExecutorService _apiJobExecutor ;
121+ private ExecutorService _workerJobExecutor ;
121122
122123 @ Override
123124 public String getConfigComponentName () {
@@ -390,7 +391,10 @@ private void scheduleExecution(final AsyncJob job, boolean executeInContext) {
390391 if (executeInContext ) {
391392 runnable .run ();
392393 } else {
393- _executor .submit (runnable );
394+ if (job .getDispatcher () == null || job .getDispatcher ().equalsIgnoreCase ("ApiAsyncJobDispatcher" ))
395+ _apiJobExecutor .submit (runnable );
396+ else
397+ _workerJobExecutor .submit (runnable );
394398 }
395399 }
396400
@@ -855,10 +859,14 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
855859 final Properties dbProps = DbProperties .getDbProperties ();
856860 final int cloudMaxActive = Integer .parseInt (dbProps .getProperty ("db.cloud.maxActive" ));
857861
858- int poolSize = (cloudMaxActive * 2 ) / 3 ;
862+ int apiPoolSize = cloudMaxActive / 2 ;
863+ int workPoolSize = (cloudMaxActive * 2 ) / 3 ;
859864
860- s_logger .info ("Start AsyncJobManager thread pool in size " + poolSize );
861- _executor = Executors .newFixedThreadPool (poolSize , new NamedThreadFactory (AsyncJobManager .JOB_POOL_THREAD_PREFIX ));
865+ s_logger .info ("Start AsyncJobManager API executor thread pool in size " + apiPoolSize );
866+ _apiJobExecutor = Executors .newFixedThreadPool (apiPoolSize , new NamedThreadFactory (AsyncJobManager .API_JOB_POOL_THREAD_PREFIX ));
867+
868+ s_logger .info ("Start AsyncJobManager Work executor thread pool in size " + workPoolSize );
869+ _workerJobExecutor = Executors .newFixedThreadPool (workPoolSize , new NamedThreadFactory (AsyncJobManager .WORK_JOB_POOL_THREAD_PREFIX ));
862870 } catch (final Exception e ) {
863871 throw new ConfigurationException ("Unable to load db.properties to configure AsyncJobManagerImpl" );
864872 }
@@ -941,7 +949,8 @@ public boolean start() {
941949 @ Override
942950 public boolean stop () {
943951 _heartbeatScheduler .shutdown ();
944- _executor .shutdown ();
952+ _apiJobExecutor .shutdown ();
953+ _workerJobExecutor .shutdown ();
945954 return true ;
946955 }
947956
0 commit comments