use of com.yahoo.vespa.orchestrator.model.VespaModelUtil in project vespa by vespa-engine.
the class OrchestratorImpl method setClusterStateInController.
private void setClusterStateInController(ApplicationInstance application, ClusterControllerNodeState state) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException {
// Get all content clusters for this application
Set<ClusterId> contentClusterIds = application.serviceClusters().stream().filter(VespaModelUtil::isContent).map(ServiceCluster::clusterId).collect(Collectors.toSet());
// For all content clusters set in maintenance
log.log(LogLevel.INFO, String.format("Setting content clusters %s for application %s to %s", contentClusterIds, application.applicationInstanceId(), state));
for (ClusterId clusterId : contentClusterIds) {
List<HostName> clusterControllers = VespaModelUtil.getClusterControllerInstancesInOrder(application, clusterId);
ClusterControllerClient client = clusterControllerClientFactory.createClient(clusterControllers, clusterId.s());
try {
ClusterControllerStateResponse response = client.setApplicationState(state);
if (!response.wasModified) {
String msg = String.format("Fail to set application %s, cluster name %s to cluster state %s due to: %s", application.applicationInstanceId(), clusterId, state, response.reason);
throw new ApplicationStateChangeDeniedException(msg);
}
} catch (IOException e) {
throw new ApplicationStateChangeDeniedException(e.getMessage());
}
}
}
Aggregations