use of com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse 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);
}
}
use of com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse 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