@Override
public ExecutionContextProvider build(Context context, String workingDirectory) throws Exception {
String privateKey = Preconditions.checkNotNull(context.getString(PRIVATE_KEY), PRIVATE_KEY + " is required");
Set<Host> hosts = Sets.newHashSet();
for(String alias : Splitter.on(" ").omitEmptyStrings().split(context.getString("hosts", ""))) {
Context hostContext = new Context(context.getSubProperties(
Joiner.on(".").join("host", alias, "")));
LOG.info("Processing host {}: {}", alias, hostContext.getParameters().toString());
hosts.add(new Host(hostContext.getString("host"), hostContext.getString("user"),
Iterables.toArray(Splitter.on(",").trimResults().split(hostContext.getString("localDirs")), String.class),
hostContext.getInteger("threads")));
}
Preconditions.checkState(hosts.size() > 0, "no hosts specified");
ExecutionContextProvider hostProvider = new FixedExecutionContextProvider(hosts, workingDirectory, privateKey);
return hostProvider;
}