Map<InstanceTemplate, Future<Set<? extends NodeMetadata>>> futures = Maps.newHashMap();
// initialize startup processes per InstanceTemplates
for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
final InstanceTemplate instanceTemplate = entry.getKey();
final ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
final int maxNumberOfRetries = clusterSpec.getMaxStartupRetries();
StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
final ComputeService computeService =
computeServiceContext.getComputeService();
final Template template = BootstrapTemplate.build(clusterSpec, computeService,
statementBuilder, entry.getKey());
Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(
new StartupProcess(
clusterSpec.getClusterName(),
instanceTemplate.getNumberOfInstances(),
instanceTemplate.getMinNumberOfInstances(),
maxNumberOfRetries,
instanceTemplate.getRoles(),
computeService, template, executorService, nodeStarterFactory));