Search in sources :

Example 1 with ClusterControllerClient

use of com.yahoo.vespa.orchestrator.controller.ClusterControllerClient in project vespa by vespa-engine.

the class StorageNodeImpl method setNodeState.

@Override
public void setNodeState(ClusterControllerNodeState wantedNodeState) throws HostStateChangeDeniedException {
    // The "cluster name" used by the Cluster Controller IS the cluster ID.
    String clusterId = this.clusterId.s();
    List<HostName> clusterControllers = VespaModelUtil.getClusterControllerInstancesInOrder(applicationInstance, this.clusterId);
    ClusterControllerClient client = clusterControllerClientFactory.createClient(clusterControllers, clusterId);
    ConfigId configId = storageService.configId();
    int nodeIndex = VespaModelUtil.getStorageNodeIndex(configId);
    logger.log(LogLevel.DEBUG, () -> "Setting cluster controller state for " + "application " + applicationInstance.reference().asString() + ", host " + hostName() + ", cluster name " + clusterId + ", node index " + nodeIndex + ", node state " + wantedNodeState);
    ClusterControllerStateResponse response;
    try {
        response = client.setNodeState(nodeIndex, wantedNodeState);
    } catch (IOException e) {
        throw new HostStateChangeDeniedException(hostName(), HostedVespaPolicy.CLUSTER_CONTROLLER_AVAILABLE_CONSTRAINT, "Failed to communicate with cluster controllers " + clusterControllers + ": " + e, e);
    }
    if (!response.wasModified) {
        throw new HostStateChangeDeniedException(hostName(), HostedVespaPolicy.SET_NODE_STATE_CONSTRAINT, "Failed to set state to " + wantedNodeState + " in cluster controller: " + response.reason);
    }
}
Also used : HostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException) ClusterControllerStateResponse(com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse) ClusterControllerClient(com.yahoo.vespa.orchestrator.controller.ClusterControllerClient) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) IOException(java.io.IOException) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 2 with ClusterControllerClient

use of com.yahoo.vespa.orchestrator.controller.ClusterControllerClient 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

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