Search in sources :

Example 1 with NodeIsBusyException

use of com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException in project cloudbreak by hortonworks.

the class ClouderaManagerDecomissioner method verifyNodeNotBusy.

private void verifyNodeNotBusy(Collection<String> hosts, ApiClient client) {
    HostServiceStatuses hostServiceStates = getHostServiceStatuses(hosts, client);
    if (hostServiceStates.anyHostBusy()) {
        Set<String> busyHostNames = hostServiceStates.getBusyHosts();
        LOGGER.info("Cannot downscale, some nodes are is BUSY state : ", busyHostNames);
        throw new NodeIsBusyException(String.format("Node is in 'busy' state, cannot be decommissioned right now. " + "Please try to remove the node later. Busy hosts: %s", busyHostNames));
    }
}
Also used : HostServiceStatuses(com.sequenceiq.cloudbreak.cluster.status.HostServiceStatuses) NodeIsBusyException(com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException)

Example 2 with NodeIsBusyException

use of com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException in project cloudbreak by hortonworks.

the class ClusterDownscaleService method handleClusterDownscaleFailure.

public void handleClusterDownscaleFailure(long stackId, Exception error) {
    String errorDetails = error.getMessage();
    LOGGER.warn("Error during Cluster downscale flow: ", error);
    DetailedStackStatus detailedStackStatus = DetailedStackStatus.DOWNSCALE_FAILED;
    if (error instanceof NotEnoughNodeException || error instanceof NodeIsBusyException) {
        detailedStackStatus = DetailedStackStatus.AVAILABLE;
    }
    stackUpdater.updateStackStatus(stackId, detailedStackStatus, "Node(s) could not be removed from the cluster: " + errorDetails);
    flowMessageService.fireEventAndLog(stackId, UPDATE_FAILED.name(), CLUSTER_SCALING_FAILED, "removed from", errorDetails);
}
Also used : NotEnoughNodeException(com.sequenceiq.cloudbreak.cluster.service.NotEnoughNodeException) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) NodeIsBusyException(com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException)

Example 3 with NodeIsBusyException

use of com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException in project cloudbreak by hortonworks.

the class ClouderaManagerDecommisionerTest method testVerifyNodesAreBusy.

@Test
public void testVerifyNodesAreBusy() throws ApiException {
    // GIVEN
    VolumeSetAttributes volumeSetAttributes = new VolumeSetAttributes("az", false, "fstab", List.of(), 50, "vt");
    Stack stack = createTestStack(volumeSetAttributes);
    Cluster cluster = new Cluster();
    stack.setCluster(cluster);
    Set<HostGroup> hostGroups = createTestHostGroups(1, 6);
    cluster.setHostGroups(hostGroups);
    ApiHostTemplateList hostTemplates = createEmptyHostTemplates();
    when(clouderaManagerApiFactory.getHostTemplatesResourceApi(Mockito.any(ApiClient.class))).thenReturn(hostTemplatesResourceApi);
    when(hostTemplatesResourceApi.readHostTemplates(stack.getName())).thenReturn(hostTemplates);
    when(clouderaManagerApiFactory.getHostsResourceApi(Mockito.any(ApiClient.class))).thenReturn(hostsResourceApi);
    when(hostsResourceApi.readHosts(eq(null), eq(null), anyString())).thenReturn(apiHostList);
    when(apiHostList.getItems()).thenReturn(List.of(getBusyHost()));
    when(resourceAttributeUtil.getTypedAttributes(Mockito.any(Resource.class), Mockito.any(Class.class))).thenReturn(Optional.of(volumeSetAttributes));
    // WHEN
    HostGroup firstHostGroup = hostGroups.iterator().next();
    NodeIsBusyException e = Assertions.assertThrows(NodeIsBusyException.class, () -> underTest.verifyNodesAreRemovable(stack, firstHostGroup.getInstanceGroup().getInstanceMetaDataSet(), new ApiClient()));
    assertEquals("Node is in 'busy' state, cannot be decommissioned right now. " + "Please try to remove the node later. Busy hosts: [hg0-host-1]", e.getMessage());
// THEN exception
}
Also used : Resource(com.sequenceiq.cloudbreak.domain.Resource) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) NodeIsBusyException(com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiHostTemplateList(com.cloudera.api.swagger.model.ApiHostTemplateList) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Aggregations

NodeIsBusyException (com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException)3 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 ApiHostTemplateList (com.cloudera.api.swagger.model.ApiHostTemplateList)1 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)1 NotEnoughNodeException (com.sequenceiq.cloudbreak.cluster.service.NotEnoughNodeException)1 HostServiceStatuses (com.sequenceiq.cloudbreak.cluster.status.HostServiceStatuses)1 Resource (com.sequenceiq.cloudbreak.domain.Resource)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)1 Test (org.junit.Test)1