statementBuilder.addStatement(Statements.call("installRunUrl"));
ClusterActionEvent event = new ClusterActionEvent(getAction(),
clusterSpec, newCluster, statementBuilder);
eventMap.put(instanceTemplate, event);
for (String role : instanceTemplate.getRoles()) {
ClusterActionHandler handler = handlerMap.get(role);
if (handler == null) {
throw new IllegalArgumentException("No handler for role " + role);
}
handler.beforeAction(event);
}
newCluster = event.getCluster(); // cluster may have been updated by handler
}
doAction(eventMap);
// cluster may have been updated by action
newCluster = Iterables.get(eventMap.values(), 0).getCluster();
for (InstanceTemplate instanceTemplate : clusterSpec.getInstanceTemplates()) {
for (String role : instanceTemplate.getRoles()) {
ClusterActionHandler handler = handlerMap.get(role);
if (handler == null) {
throw new IllegalArgumentException("No handler for role " + role);
}
ClusterActionEvent event = eventMap.get(instanceTemplate);
event.setCluster(newCluster);
handler.afterAction(event);
newCluster = event.getCluster(); // cluster may have been updated by handler
}
}
return newCluster;