Search in sources :

Example 36 with HostName

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)");
    }
}
Also used : StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 37 with HostName

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)");
    }
}
Also used : ClusterApi(com.yahoo.vespa.orchestrator.model.ClusterApi) StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 38 with HostName

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;
}
Also used : PatchHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse) OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) BadRequestException(javax.ws.rs.BadRequestException) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) HostName(com.yahoo.vespa.applicationmodel.HostName) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException)

Example 39 with HostName

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);
    }
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) PatchHostRequest(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest) Path(javax.ws.rs.Path) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) Inject(javax.inject.Inject) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) MediaType(javax.ws.rs.core.MediaType) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Component(com.yahoo.container.jaxrs.annotation.Component) LogLevel(com.yahoo.log.LogLevel) Host(com.yahoo.vespa.orchestrator.Host) BadRequestException(javax.ws.rs.BadRequestException) URI(java.net.URI) UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) Context(javax.ws.rs.core.Context) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) List(java.util.List) Response(javax.ws.rs.core.Response) HostService(com.yahoo.vespa.orchestrator.restapi.wire.HostService) WebApplicationException(javax.ws.rs.WebApplicationException) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) UriInfo(javax.ws.rs.core.UriInfo) PatchHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse) HostApi(com.yahoo.vespa.orchestrator.restapi.HostApi) HostService(com.yahoo.vespa.orchestrator.restapi.wire.HostService) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) Host(com.yahoo.vespa.orchestrator.Host) URI(java.net.URI) HostName(com.yahoo.vespa.applicationmodel.HostName) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException)

Example 40 with HostName

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);
}
Also used : JaxRsStrategyFactory(com.yahoo.vespa.jaxrs.client.JaxRsStrategyFactory) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

HostName (com.yahoo.vespa.applicationmodel.HostName)46 Test (org.junit.Test)20 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)14 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)13 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)9 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)9 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)8 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)8 List (java.util.List)8 ApplicationId (com.yahoo.config.provision.ApplicationId)7 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)7 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)7 Collectors (java.util.stream.Collectors)7 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)6 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)6 TenantId (com.yahoo.vespa.applicationmodel.TenantId)6 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)5 OrchestrationException (com.yahoo.vespa.orchestrator.OrchestrationException)5 StorageNode (com.yahoo.vespa.orchestrator.model.StorageNode)5 IOException (java.io.IOException)5