Execution resource allocation

You manage the allocation of the threads needed to execute a scenario suite using a resource allocation policy manager. On WebSphere® Application Server, the creation of the threads is delegated to work managers.

Each time an execution request is sent to the Scenario Service Provider (SSP) from Decision Center, the SSP has to decide the priority of the threads to use to run the scenario suite, and the maximum number of threads to allocate to a parallel execution of a simulation. On WebSphere Application Server, the priority of the threads is decided by which work manager to use.

The default scenario suite resource allocation policy manager has the following behavior:

Resource allocation on WebSphere Application Server

When the SSP is deployed to WebSphere Application Server, the creation of threads is delegated to work managers. For more information, see Work managers in the WebSphere Application Server documentation.

To dispatch an execution request to threads with different priorities, the SSP uses three different work managers. Each work manager defines its own thread priority, which is referenced in the web.xml deployment descriptor of the SSP web application. The priority of the scenario suite is then used to decide which work manager can run the scenario suite.

There are three initialization parameters defined for the SSP servlet:

  • NORMAL_PRIORITY_MANAGER: defines the work manager to use to run normal priority threads.
  • HIGH_PRIORITY_WORK_MANAGER: defines the work manager to use to run high priority threads.
  • LOW_PRIORITY_MANAGER: defines the work manager to use to run low priority threads.

The three work managers are defined as follows in the deployment descriptor:

   <init-param>
      <description>Name of the high priority work manager to use to spawn high
                   priority threads in the SSP.
                   If this value is updated to use a dedicated work manager that
                   is not the default (wm/default), the resources references
                   section of this descriptor must be updated to make sure that
                   the new work manager is referenced in a resource-ref element.</description>
         <param-name>HIGH_PRIORITY_WORK_MANAGER</param-name>
         <param-value>wm/default</param-value>
   </init-param>
   <init-param>
      <description>Name of the normal priority work manager to use to spawn
                   normal priority threads in the SSP.
                   If this value is updated to use a dedicated work manager that
                   is not the default (wm/default), the resources references
                   section of this descriptor must be updated to make sure that
                   the new work manager is referenced in a resource-ref element.</description>
         <param-name>NORMAL_PRIORITY_WORK_MANAGER</param-name>
         <param-value>wm/default</param-value>
   </init-param>
   <init-param>
      <description>Name of the low priority work manager to use to spawn low
                   priority threads in the SSP.
                   If this value is updated to use a dedicated work manager that
                   is not the default (wm/default), the resources references 
                   section of this descriptor must be updated to make sure that 
                   the new work manager is referenced in a resource-ref element.</description>
         <param-name>LOW_PRIORITY_WORK_MANAGER</param-name>
         <param-value>wm/default</param-value>
   </init-param>

The value for each parameter is the name of the work manager to use, as defined in the resource reference of the web.xml deployment descriptor under the <res-ref-name> element:

   <resource-ref>
         <res-ref-name>wm/default</res-ref-name>
         <res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
         <res-auth>Container</res-auth>
         <res-sharing-scope>Unshareable</res-sharing-scope>
   </resource-ref>

By default, all three work manager definitions reference the default work manager defined for a WebSphere Application Server instance (wm/default). All threads run with the same priority as defined by this work manager.

Note:

Using multiple work managers with different thread priorities assigned to them is only useful if you are defining a custom resources allocation policy manager. It is important to remember that the maximum number of threads that can be created by the SSP is defined by the work manager configuration. Work managers can be shared between different applications deployed on the same application server.

Resource allocation on other application servers and Java SE

On the other supported Java EE application servers and Java SE, a fixed thread pool size is used to run threads with different priorities. The size of the fixed thread pool is defined by the JRULES_JOBS_POOL_SIZE parameter in the web.xml deployment descriptor of the SSP web application.

The default value for the pool size is 10, as shown in the following example:

   <init-param>
         <description>The number of threads in the pool for asynchronous
                      executions (jobs)</description>
         <param-name>JRULES_JOBS_POOL_SIZE</param-name>
         <param-value>10</param-value>
   </init-param>
Note:

In Java SE, you need to use an IlrLocalSSPService constructor that takes the pool size as an argument.

The priority of the thread is defined by the resource allocation policy manager. There are three priority values:

  • Thread.NORM_PRIORITY for priority NORMAL
  • Thread.MAX_PIORITY for priority HIGH
  • Thread.MIN_PRIORITY for priority LOW

When a thread is started, it is queued according to its priority. When all threads in the pool are running, new thread requests are queued until a thread from the pool completes an execution. Threads waiting to be executed are prioritized, which means if a HIGH priority scenario suite is added to the queue, it is added closer to the front of the queue compared to all the other scenario suites that have a lower priority.