protected void initEngine()

in src/main/java/com/revo/deployr/client/broker/engine/RBrokerEngine.java [200:247]


    protected void initEngine(int parallelTaskLimit)
            throws RBrokerException {

        try {

            this.parallelTaskLimit = new AtomicInteger(parallelTaskLimit);

            this.taskWorkerExecutor =
                    Executors.newFixedThreadPool(parallelTaskLimit);

            this.resourceTokenPool =
                    new ArrayBlockingQueue<Object>(parallelTaskLimit);

            this.taskResourceTokenMap =
                    new ConcurrentHashMap<RTask, Object>(parallelTaskLimit);

            this.taskTokenListenerMap =
                    new ConcurrentHashMap<RTask, RTaskTokenListener>(parallelTaskLimit);

        } catch (Exception ex) {
            throw new RBrokerException("Broker failed to " +
                    "initialize, cause" + ex);
        }

        try {
            brokerEngineExecutor.execute(new RBrokerWorkerManager());
        } catch (RejectedExecutionException rex) {
            shutdown();
            throw new RBrokerException("Broker failed " +
                    "to start worker manager, cause: " + rex);
        }

        try {
            brokerEngineExecutor.execute(new RBrokerListenerManager());
        } catch (RejectedExecutionException rex) {
            shutdown();
            throw new RBrokerException("Broker failed " +
                    "to start listener manager, cause: " + rex);
        }

        try {
            engineInitialized.tryAcquire(5000L, TimeUnit.MILLISECONDS);
        } catch (InterruptedException iex) {
            shutdown();
            throw new RBrokerException("Broker failed " +
                    "to initialized, cause: " + iex);
        }
    }