Search in sources :

Example 1 with ApplicationApi

use of com.yahoo.vespa.orchestrator.model.ApplicationApi in project vespa by vespa-engine.

the class HostedVespaPolicyTest method testGrantSuspension.

@Test
public void testGrantSuspension() throws HostStateChangeDeniedException {
    final HostedVespaClusterPolicy clusterPolicy = mock(HostedVespaClusterPolicy.class);
    final HostedVespaPolicy policy = new HostedVespaPolicy(clusterPolicy, clientFactory);
    final ApplicationApi applicationApi = mock(ApplicationApi.class);
    when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("tenant:app:default"));
    ClusterApi clusterApi1 = mock(ClusterApi.class);
    ClusterApi clusterApi2 = mock(ClusterApi.class);
    ClusterApi clusterApi3 = mock(ClusterApi.class);
    List<ClusterApi> clusterApis = Arrays.asList(clusterApi1, clusterApi2, clusterApi3);
    when(applicationApi.getClusters()).thenReturn(clusterApis);
    StorageNode storageNode1 = mock(StorageNode.class);
    HostName hostName1 = new HostName("storage-1");
    when(storageNode1.hostName()).thenReturn(hostName1);
    HostName hostName2 = new HostName("host-2");
    StorageNode storageNode3 = mock(StorageNode.class);
    HostName hostName3 = new HostName("storage-3");
    when(storageNode1.hostName()).thenReturn(hostName3);
    List<StorageNode> upStorageNodes = Arrays.asList(storageNode1, storageNode3);
    when(applicationApi.getUpStorageNodesInGroupInClusterOrder()).thenReturn(upStorageNodes);
    // setHostState
    List<HostName> noRemarksHostNames = Arrays.asList(hostName1, hostName2, hostName3);
    when(applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)).thenReturn(noRemarksHostNames);
    InOrder order = inOrder(applicationApi, clusterPolicy, storageNode1, storageNode3);
    policy.grantSuspensionRequest(applicationApi);
    order.verify(applicationApi).getClusters();
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi1);
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi2);
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi3);
    order.verify(applicationApi).getUpStorageNodesInGroupInClusterOrder();
    order.verify(storageNode1).setNodeState(ClusterControllerNodeState.MAINTENANCE);
    order.verify(storageNode3).setNodeState(ClusterControllerNodeState.MAINTENANCE);
    order.verify(applicationApi).getNodesInGroupWithStatus(HostStatus.NO_REMARKS);
    order.verify(applicationApi).setHostState(hostName1, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName2, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName3, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verifyNoMoreInteractions();
}
Also used : ClusterApi(com.yahoo.vespa.orchestrator.model.ClusterApi) InOrder(org.mockito.InOrder) ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 2 with ApplicationApi

use of com.yahoo.vespa.orchestrator.model.ApplicationApi in project vespa by vespa-engine.

the class HostedVespaPolicy method grantSuspensionRequest.

// TODO: Remove later - currently used for backward compatibility testing
@Override
public void grantSuspensionRequest(ApplicationInstance applicationInstance, HostName hostName, MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
    NodeGroup nodeGroup = new NodeGroup(applicationInstance);
    nodeGroup.addNode(hostName);
    ApplicationApi applicationApi = new ApplicationApiImpl(nodeGroup, hostStatusService, clusterControllerClientFactory);
    grantSuspensionRequest(applicationApi);
}
Also used : ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) NodeGroup(com.yahoo.vespa.orchestrator.model.NodeGroup)

Example 3 with ApplicationApi

use of com.yahoo.vespa.orchestrator.model.ApplicationApi in project vespa by vespa-engine.

the class OrchestratorImpl method suspendGroup.

// Public for testing purposes
@Override
public void suspendGroup(NodeGroup nodeGroup) throws HostStateChangeDeniedException, HostNameNotFoundException {
    ApplicationInstanceReference applicationReference = nodeGroup.getApplicationReference();
    try (MutableStatusRegistry hostStatusRegistry = statusService.lockApplicationInstance_forCurrentThreadOnly(applicationReference)) {
        ApplicationInstanceStatus appStatus = statusService.forApplicationInstance(applicationReference).getApplicationInstanceStatus();
        if (appStatus == ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN) {
            return;
        }
        ApplicationApi applicationApi = new ApplicationApiImpl(nodeGroup, hostStatusRegistry, clusterControllerClientFactory);
        policy.grantSuspensionRequest(applicationApi);
    }
}
Also used : ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)

Example 4 with ApplicationApi

use of com.yahoo.vespa.orchestrator.model.ApplicationApi in project vespa by vespa-engine.

the class OrchestratorImpl method acquirePermissionToRemove.

@Override
public void acquirePermissionToRemove(HostName hostName) throws OrchestrationException {
    ApplicationInstance appInstance = getApplicationInstance(hostName);
    NodeGroup nodeGroup = new NodeGroup(appInstance, hostName);
    try (MutableStatusRegistry statusRegistry = statusService.lockApplicationInstance_forCurrentThreadOnly(appInstance.reference())) {
        ApplicationApi applicationApi = new ApplicationApiImpl(nodeGroup, statusRegistry, clusterControllerClientFactory);
        policy.acquirePermissionToRemove(applicationApi);
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) NodeGroup(com.yahoo.vespa.orchestrator.model.NodeGroup)

Example 5 with ApplicationApi

use of com.yahoo.vespa.orchestrator.model.ApplicationApi in project vespa by vespa-engine.

the class HostedVespaPolicy method releaseSuspensionGrant.

// TODO: Remove later - currently used for backward compatibility testing
@Override
public void releaseSuspensionGrant(ApplicationInstance applicationInstance, HostName hostName, MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
    NodeGroup nodeGroup = new NodeGroup(applicationInstance, hostName);
    ApplicationApi applicationApi = new ApplicationApiImpl(nodeGroup, hostStatusService, clusterControllerClientFactory);
    releaseSuspensionGrant(applicationApi);
}
Also used : ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) NodeGroup(com.yahoo.vespa.orchestrator.model.NodeGroup)

Aggregations

ApplicationApi (com.yahoo.vespa.orchestrator.model.ApplicationApi)6 ApplicationApiImpl (com.yahoo.vespa.orchestrator.model.ApplicationApiImpl)4 NodeGroup (com.yahoo.vespa.orchestrator.model.NodeGroup)3 HostName (com.yahoo.vespa.applicationmodel.HostName)2 ClusterApi (com.yahoo.vespa.orchestrator.model.ClusterApi)2 StorageNode (com.yahoo.vespa.orchestrator.model.StorageNode)2 MutableStatusRegistry (com.yahoo.vespa.orchestrator.status.MutableStatusRegistry)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)1 ApplicationInstanceStatus (com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus)1