private boolean hasWorkerTagConflict(WorkerData worker) { if (workerTags != null) { return !matches(workerTags, worker.getTags()); } return false; }
@Override public Object exec(List list) throws TemplateModelException { if (list.size() == 0) { return componentRegistry.getAgents(); } else if (list.size() == 1) { Object arg = list.get(0); if (!(arg instanceof SimpleScalar)) { throw new TemplateModelException("Wrong type of the first parameter." + " It should be SimpleScalar . Found: " + arg.getClass()); } Map<String, String> tags = TagUtils.parseTags(((SimpleScalar) arg).getAsString()); List<AgentData> result = new ArrayList<AgentData>(); for (AgentData agent : componentRegistry.getAgents()) { if (TagUtils.matches(tags, agent.getTags())) { result.add(agent); } } return result; } else { throw new TemplateModelException("Wrong number of arguments for method agents()." + " Method has zero a 1 String argument, found " + list.size()); } } }
private List<SimulatorAddress> findAgents(RcWorkerStartOperation op) { List<AgentData> agents = new ArrayList<AgentData>(componentRegistry.getAgents()); List<SimulatorAddress> result = new ArrayList<SimulatorAddress>(); for (AgentData agent : agents) { List<String> expectedAgentAddresses = op.getAgentAddresses(); if (expectedAgentAddresses != null) { if (!expectedAgentAddresses.contains(agent.getAddress().toString())) { continue; } } Map<String, String> expectedAgentTags = op.getAgentTags(); if (expectedAgentTags != null) { if (!matches(op.getAgentTags(), agent.getTags())) { continue; } } result.add(agent.getAddress()); } return result; }