Search in sources :

Example 1 with VespaModelUtil

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());
        }
    }
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ClusterControllerStateResponse(com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse) ClusterControllerClient(com.yahoo.vespa.orchestrator.controller.ClusterControllerClient) VespaModelUtil(com.yahoo.vespa.orchestrator.model.VespaModelUtil) IOException(java.io.IOException) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 ClusterControllerClient (com.yahoo.vespa.orchestrator.controller.ClusterControllerClient)1 ClusterControllerStateResponse (com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse)1 VespaModelUtil (com.yahoo.vespa.orchestrator.model.VespaModelUtil)1 IOException (java.io.IOException)1