public List<V> executeModules(List<ScriptModule> modules, ScriptModuleExecutable<V> executable) {
        Objects.requireNonNull(modules, "modules");
        Objects.requireNonNull(executable, "executable");

        List<Future<V>> futureResults = new ArrayList<Future<V>>(modules.size());
        for (ScriptModule module : modules) {
           Future<V> future = new ScriptModuleExecutionCommand<V>(executorId, executable, module).queue();
           futureResults.add(future);

           ExecutionStatistics moduleStats = getOrCreateModuleStatistics(module.getModuleId());
           moduleStats.executionCount.incrementAndGet();
           moduleStats.lastExecutionTime.set(System.currentTimeMillis());
        }

        List<V> results = new ArrayList<V>(modules.size());
        for (int i = 0; i < futureResults.size(); i++) {
            Future<V> futureResult = futureResults.get(i);
            try {
                V result = futureResult.get();
                results.add(result);
            } catch (Exception e) {
                // the exception is already logged by the hystrix command, so just add some additional context
                ScriptModule failedModule = modules.get(i);
                logger.error("moduleId {} with creationTime: {} failed execution. see hystrix command log for deatils.",
                    failedModule.getModuleId(), failedModule.getCreateTime());
                continue;
            }
        }
        return results;
    }
public List < V > executeModules ( List < ScriptModule > modules , ScriptModuleExecutable < V > executable ) { Objects . requireNonNull ( modules , "modules" ) ; Objects . requireNonNull ( executable , "executable" ) ; List < Future < V > > futureResults = new ArrayList < Future < V > > ( modules . size ( ) ) ; for ( ScriptModule module : modules ) { Future < V > future = new ScriptModuleExecutionCommand < V > ( executorId , executable , module ) . queue ( ) ; futureResults . add ( future ) ; ExecutionStatistics moduleStats = getOrCreateModuleStatistics ( module . getModuleId ( ) ) ; moduleStats . executionCount . incrementAndGet ( ) ; moduleStats . lastExecutionTime . set ( System . currentTimeMillis ( ) ) ; } List < V > results = new ArrayList < V > ( modules . size ( ) ) ; for ( int i = 0 ; i < futureResults . size ( ) ; i ++ ) { Future < V > futureResult = futureResults . get ( i ) ; try { V result = futureResult . get ( ) ; results . add ( result ) ; } catch ( Exception e ) { ScriptModule failedModule = modules . get ( i ) ; logger . error ( "moduleId {} with creationTime: {} failed execution. see hystrix command log for deatils." , failedModule . getModuleId ( ) , failedModule . getCreateTime ( ) ) ; continue ; } } return results ; }
Execute a collection of modules.

@param modules modules to execute.
@param executable execution logic to be performed for each module.
@return list of the outputs from the executable.