use of com.yahoo.vespa.orchestrator.model.StorageNode 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();
}
use of com.yahoo.vespa.orchestrator.model.StorageNode in project vespa by vespa-engine.
the class HostedVespaPolicy method acquirePermissionToRemove.
@Override
public void acquirePermissionToRemove(ApplicationApi applicationApi) throws HostStateChangeDeniedException {
ApplicationInstanceStatus applicationStatus = applicationApi.getApplicationStatus();
if (applicationStatus == ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN) {
throw new HostStateChangeDeniedException(applicationApi.getNodeGroup(), HostedVespaPolicy.APPLICATION_SUSPENDED_CONSTRAINT, "Unable to test availability constraints as the application " + applicationApi.applicationId() + " is allowed to be down");
}
// Apply per-cluster policy
for (ClusterApi cluster : applicationApi.getClusters()) {
clusterPolicy.verifyGroupGoingDownPermanentlyIsFine(cluster);
}
// These storage nodes are guaranteed to be NO_REMARKS
for (StorageNode storageNode : applicationApi.getStorageNodesInGroupInClusterOrder()) {
storageNode.setNodeState(ClusterControllerNodeState.DOWN);
log.log(LogLevel.INFO, "The storage node on " + storageNode.hostName() + " has been set DOWN");
}
// Ensure all nodes in the group are marked as allowed to be down
for (HostName hostName : applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)) {
applicationApi.setHostState(hostName, HostStatus.ALLOWED_TO_BE_DOWN);
log.log(LogLevel.INFO, hostName + " is now allowed to be down (suspended)");
}
}
use of com.yahoo.vespa.orchestrator.model.StorageNode 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.orchestrator.model.StorageNode 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.orchestrator.model.StorageNode in project vespa by vespa-engine.
the class HostedVespaPolicyTest method testAcquirePermissionToRemove.
@Test
public void testAcquirePermissionToRemove() throws OrchestrationException {
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.getStorageNodesInGroupInClusterOrder()).thenReturn(upStorageNodes);
List<HostName> noRemarksHostNames = Arrays.asList(hostName1, hostName2, hostName3);
when(applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)).thenReturn(noRemarksHostNames);
InOrder order = inOrder(applicationApi, clusterPolicy, storageNode1, storageNode3);
policy.acquirePermissionToRemove(applicationApi);
order.verify(applicationApi).getClusters();
order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi1);
order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi2);
order.verify(clusterPolicy).verifyGroupGoingDownPermanentlyIsFine(clusterApi3);
order.verify(applicationApi).getStorageNodesInGroupInClusterOrder();
order.verify(storageNode1).setNodeState(ClusterControllerNodeState.DOWN);
order.verify(storageNode3).setNodeState(ClusterControllerNodeState.DOWN);
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();
}
Aggregations