private void update() throws ChainException { Set<String> activeEngineNames = new HashSet<String>(tracker.getActiveEngineNames()); if(activeEngineNames.isEmpty()){ throw new ChainException("Currently there are no active EnhancementEngines available"); } List<EnhancementEngine> activeEngines = new ArrayList<EnhancementEngine>(activeEngineNames.size()); Iterator<String> names = activeEngineNames.iterator(); while(names.hasNext()){ String name = names.next(); EnhancementEngine engine = tracker.getEngine(name); if(engine != null){ activeEngines.add(engine); } else { //looks like the config has changed in the meantime names.remove(); } } Set<String> emptySet = Collections.emptySet(); executionPlan = calculateExecutionPlan( getName(),activeEngines, emptySet,//this Chain does not support optional engines emptySet); //only active meaning that no engines are missing engineNames = Collections.unmodifiableSet(activeEngineNames); }
/** * Creates a new execution plan based on the configured {@link #chain} and * the currently available {@link EnhancementEngine}s. If required * {@link EnhancementEngine}s are missing a {@link ChainException} will be * thrown. * @return the execution plan * @throws ChainException if a required {@link EnhancementEngine} of the * configured {@link #chain} is not active. */ private ImmutableGraph createExecutionPlan() throws ChainException { List<EnhancementEngine> availableEngines = new ArrayList<EnhancementEngine>(chain.size()); Set<String> optionalEngines = new HashSet<String>(); Set<String> missingEngines = new HashSet<String>(); for(Entry<String,Map<String,List<String>>> entry : chain.entrySet()){ boolean optional = getState(entry.getValue(),"optional"); EnhancementEngine engine = tracker.getEngine(entry.getKey()); if(engine != null){ availableEngines.add(engine); } else { missingEngines.add(entry.getKey()); } if(optional){ optionalEngines.add(entry.getKey()); } } return calculateExecutionPlan(getName(),availableEngines,optionalEngines, missingEngines,chainScopedEnhProps); }