예제 #1
0
  /**
   * Create and initialize a pool of threads to serve clients requests.
   *
   * @param routingTable the Routing Table used to find WS.
   */
  public PoolClientConnection(RoutingTable routingTable) {
    super();
    PoolClientConnection.routingTable = routingTable;
    PoolClientConnection.mailBox = new MailBoxImpl();

    // Pool creation and initialisation
    // Max threads
    int sizeMax = Integer.parseInt(DispatcherMSG.CONFIGURATION.getProperty("clients.max"));
    pool = new PooledExecutor(sizeMax);

    // Min threads
    int sizeMin = Integer.parseInt(DispatcherMSG.CONFIGURATION.getProperty("clients.min"));
    pool.setMinimumPoolSize(sizeMin);

    // Keep alive time
    long keepAliveTime =
        Long.parseLong(DispatcherMSG.CONFIGURATION.getProperty("clients.keepAliveTime"));
    pool.setKeepAliveTime(keepAliveTime);

    // Pre-start threads
    int preCreateThread =
        Integer.parseInt(DispatcherMSG.CONFIGURATION.getProperty("clients.preCreateThreads"));
    pool.createThreads(preCreateThread);

    // Set the policy for blocked execution to be to wait until a thread is
    // available
    pool.waitWhenBlocked();
  }
예제 #2
0
  /**
   * Default Constructor.
   *
   * @param instRep The WorkflowInstanceRepository to be used by this engine.
   * @param queueSize The size of the queue that the workflow engine should use (irrelevant if
   *     unlimitedQueue is set to true)
   * @param maxPoolSize The minimum thread pool size.
   * @param minPoolSize The maximum thread pool size.
   * @param threadKeepAliveTime The amount of minutes that each thread in the pool should be kept
   *     alive.
   * @param unlimitedQueue Whether or not to use a queue whose bounds are dictated by the physical
   *     memory of the underlying hardware.
   * @param resUrl A URL pointer to a resource manager. If this is set Tasks will be wrapped as
   *     Resource Manager {@link Job}s and sent through the Resource Manager. If this parameter is
   *     not set, local execution (the default) will be used
   */
  public ThreadPoolWorkflowEngine(
      WorkflowInstanceRepository instRep,
      int queueSize,
      int maxPoolSize,
      int minPoolSize,
      long threadKeepAliveTime,
      boolean unlimitedQueue,
      URL resUrl) {

    this.instRep = instRep;
    Channel c = null;
    if (unlimitedQueue) {
      c = new LinkedQueue();
    } else {
      c = new BoundedBuffer(queueSize);
    }

    pool = new PooledExecutor(c, maxPoolSize);
    pool.setMinimumPoolSize(minPoolSize);
    pool.setKeepAliveTime(1000 * 60 * threadKeepAliveTime);

    workerMap = new HashMap();

    if (resUrl != null) rClient = new XmlRpcResourceManagerClient(resUrl);
  }
 static {
   JSONObject json =
       JSONObject.fromObject(PropertiesDeploy.getConfigureMap().get(Constant.OTHERS_HOST_NAME));
   othersPooledExecutor.setKeepAliveTime(
       Integer.parseInt(json.getString(Constant.KEEP_ALIVE_TIME)));
   othersPooledExecutor.createThreads(Integer.parseInt(json.getString(Constant.CREATE_SIZE)));
   othersPooledExecutor.setMinimumPoolSize(
       Integer.parseInt(json.getString(Constant.MIN_POOL_SIZE)));
   othersPooledExecutor.setMaximumPoolSize(
       Integer.parseInt(json.getString(Constant.MAX_POOL_SIZE)));
   othersPooledExecutor.abortWhenBlocked();
 }