// the failed update -- which should not have changed anything
rollbacks.add(0, rollback);
// Stick in a placeholder result that will survive if
// a host update faiure triggers a rollback or will get replaced with
// the final result if we apply to servers
result.add(new HostUpdateApplierResponse(false));
}
catch (UpdateFailedException e) {
ok = false;
result.add(new HostUpdateApplierResponse(e));
}
} else {
// Add a cancellation response
result.add(new HostUpdateApplierResponse(true));
}
}
if (!ok) {
// Apply compensating updates to fix our local model
for (int i = 0; i < rollbacks.size(); i++) {
AbstractHostModelUpdate<?> rollback = rollbacks.get(i);
try {
hostModel.update(rollback);
}
catch (UpdateFailedException e) {
// TODO uh oh. Reload from the file?
}
}
}
else {
// Persist model
configPersister.persistConfiguration(hostModel);
result.clear();
for (AbstractHostModelUpdate<?> update : updates) {
result.add(new HostUpdateApplierResponse(getAffectedServers(update)));
}
}
return result;
}