use of com.yahoo.vespa.applicationmodel.HostName in project vespa by vespa-engine.
the class HostedVespaPolicy method releaseSuspensionGrant.
@Override
public void releaseSuspensionGrant(ApplicationApi application) throws HostStateChangeDeniedException {
// Always defer to Cluster Controller whether it's OK to resume storage node
for (StorageNode storageNode : application.getStorageNodesAllowedToBeDownInGroupInReverseClusterOrder()) {
storageNode.setNodeState(ClusterControllerNodeState.UP);
log.log(LogLevel.INFO, "The storage node on " + storageNode.hostName() + " has been set to UP");
}
for (HostName hostName : application.getNodesInGroupWithStatus(HostStatus.ALLOWED_TO_BE_DOWN)) {
application.setHostState(hostName, HostStatus.NO_REMARKS);
log.log(LogLevel.INFO, hostName + " is no longer allowed to be down (resumed)");
}
}
use of com.yahoo.vespa.applicationmodel.HostName in project vespa by vespa-engine.
the class HostedVespaPolicy method grantSuspensionRequest.
@Override
public void grantSuspensionRequest(ApplicationApi application) throws HostStateChangeDeniedException {
// Apply per-cluster policy
for (ClusterApi cluster : application.getClusters()) {
clusterPolicy.verifyGroupGoingDownIsFine(cluster);
}
// These storage nodes are guaranteed to be NO_REMARKS
for (StorageNode storageNode : application.getUpStorageNodesInGroupInClusterOrder()) {
storageNode.setNodeState(ClusterControllerNodeState.MAINTENANCE);
log.log(LogLevel.INFO, "The storage node on " + storageNode.hostName() + " has been set to MAINTENANCE");
}
// Ensure all nodes in the group are marked as allowed to be down
for (HostName hostName : application.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)) {
application.setHostState(hostName, HostStatus.ALLOWED_TO_BE_DOWN);
log.log(LogLevel.INFO, hostName + " is now allowed to be down (suspended)");
}
}
use of com.yahoo.vespa.applicationmodel.HostName in project vespa by vespa-engine.
the class HostResource method patch.
@Override
public PatchHostResponse patch(String hostNameString, PatchHostRequest request) {
HostName hostName = new HostName(hostNameString);
if (request.state != null) {
HostStatus state;
try {
state = HostStatus.valueOf(request.state);
} catch (IllegalArgumentException dummy) {
throw new BadRequestException("Bad state in request: '" + request.state + "'");
}
try {
orchestrator.setNodeStatus(hostName, state);
} catch (HostNameNotFoundException e) {
log.log(LogLevel.INFO, "Host not found: " + hostName);
throw new NotFoundException(e);
} catch (OrchestrationException e) {
String message = "Failed to set " + hostName + " to " + state + ": " + e.getMessage();
log.log(LogLevel.INFO, message, e);
throw new InternalServerErrorException(message);
}
}
PatchHostResponse response = new PatchHostResponse();
response.description = "ok";
return response;
}
use of com.yahoo.vespa.applicationmodel.HostName in project vespa by vespa-engine.
the class HostResource method getHost.
@Override
public GetHostResponse getHost(String hostNameString) {
HostName hostName = new HostName(hostNameString);
try {
Host host = orchestrator.getHost(hostName);
URI applicationUri = uriInfo.getBaseUriBuilder().path(InstanceResource.class).path(host.getApplicationInstanceReference().asString()).build();
List<HostService> hostServices = host.getServiceInstances().stream().map(serviceInstance -> new HostService(serviceInstance.getServiceCluster().clusterId().s(), serviceInstance.getServiceCluster().serviceType().s(), serviceInstance.configId().s(), serviceInstance.serviceStatus().name())).collect(Collectors.toList());
return new GetHostResponse(host.getHostName().s(), host.getHostStatus().name(), applicationUri.toString(), hostServices);
} catch (HostNameNotFoundException e) {
log.log(LogLevel.INFO, "Host not found: " + hostName);
throw new NotFoundException(e);
}
}
use of com.yahoo.vespa.applicationmodel.HostName in project vespa by vespa-engine.
the class RetryingClusterControllerClientFactory method createClient.
@Override
public ClusterControllerClient createClient(List<HostName> clusterControllers, String clusterName) {
Set<HostName> clusterControllerSet = clusterControllers.stream().collect(Collectors.toSet());
JaxRsStrategy<ClusterControllerJaxRsApi> jaxRsApi = new JaxRsStrategyFactory(clusterControllerSet, HARDCODED_CLUSTERCONTROLLER_PORT, jaxRsClientFactory, CLUSTERCONTROLLER_SCHEME).apiWithRetries(ClusterControllerJaxRsApi.class, CLUSTERCONTROLLER_API_PATH);
return new ClusterControllerClientImpl(jaxRsApi, clusterName);
}
Aggregations