Search in sources :

Example 1 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class StackApiViewToStackViewV4ResponseConverter method convert.

public StackViewV4Response convert(StackApiView source) {
    StackViewV4Response stackViewResponse = new StackViewV4Response();
    stackViewResponse.setCrn(source.getResourceCrn());
    stackViewResponse.setName(source.getName());
    if (source.getCluster() != null) {
        stackViewResponse.setCluster(clusterApiViewToClusterViewV4ResponseConverter.convert(source.getCluster()));
    }
    stackViewResponse.setTunnel(source.getTunnel());
    stackViewResponse.setNodeCount(source.getNodeCount());
    stackViewResponse.setStatus(source.getStatus());
    stackViewResponse.setCreated(source.getCreated());
    stackViewResponse.setTerminated(source.getTerminated());
    addUser(source, stackViewResponse);
    stackViewResponse.setCloudPlatform(source.getCloudPlatform());
    stackViewResponse.setEnvironmentCrn(source.getEnvironmentCrn());
    stackViewResponse.setStackVersion(source.getStackVersion());
    stackViewResponse.setVariant(Strings.isNullOrEmpty(source.getPlatformVariant()) ? source.getCloudPlatform() : source.getPlatformVariant());
    return stackViewResponse;
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)

Example 2 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class SdxServiceDecorator method prepareMultipleSdxAttributes.

public void prepareMultipleSdxAttributes(Set<StackViewV4Response> stackViewResponses) {
    List<SdxClusterResponse> responses = sdxClientService.list();
    for (StackViewV4Response stackViewResponse : stackViewResponses) {
        Optional<SdxClusterResponse> first = responses.stream().filter(x -> x.getEnvironmentCrn().equals(stackViewResponse.getEnvironmentCrn())).findFirst();
        if (first.isPresent()) {
            SdxClusterResponse sdxCluster = first.get();
            SharedServiceV4Response sharedServiceResponse = stackViewResponse.getCluster().getSharedServiceResponse();
            sharedServiceResponse.setSdxCrn(sdxCluster.getCrn());
            sharedServiceResponse.setSdxName(sdxCluster.getName());
        } else {
            LOGGER.info("No SDX cluster found for stack {}.", stackViewResponse.getCrn());
        }
    }
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) Inject(javax.inject.Inject) List(java.util.List) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)

Example 3 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class LoadBalancerPollerServiceTest method setupDatahubResponse.

private void setupDatahubResponse() {
    StackViewV4Response response1 = new StackViewV4Response();
    response1.setName(DH_NAME1);
    StackViewV4Response response2 = new StackViewV4Response();
    response2.setName(DH_NAME2);
    when(datahubService.list(ENV_CRN)).thenReturn(new StackViewV4Responses(Set.of(response1, response2)));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)

Example 4 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class UpgradePreconditionServiceTest method testCheckForRunningAttachedClustersShouldNotReturnErrorMessageWhenThereAreNoClustersInNotProperState.

@Test
public void testCheckForRunningAttachedClustersShouldNotReturnErrorMessageWhenThereAreNoClustersInNotProperState() {
    StackViewV4Response dataHubStack1 = createStackResponse(Status.STOPPED, "stack-1", "stack-crn-1");
    dataHubStack1.setCluster(createClusterResponse(Status.STOPPED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack2 = createStackResponse(Status.DELETE_COMPLETED, "stack-2", "stack-crn-2");
    dataHubStack2.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack3 = createStackResponse(Status.STOPPED, "stack-3", "stack-crn-3");
    dataHubStack3.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses(Set.of(dataHubStack1, dataHubStack2, dataHubStack3));
    String actualRunning = underTest.checkForRunningAttachedClusters(stackViewV4Responses, new Stack());
    String actualNonUpgradeable = underTest.checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    assertEquals("", actualRunning);
    assertEquals("", actualNonUpgradeable);
    verifyNoInteractions(spotInstanceUsageCondition);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 5 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class UpgradePreconditionServiceTest method testCheckForRunningAttachedClustersShouldReturnErrorMessageWhenThereAreClustersInNotProperState.

@Test
public void testCheckForRunningAttachedClustersShouldReturnErrorMessageWhenThereAreClustersInNotProperState() {
    StackViewV4Response dataHubStack1 = createStackResponse(Status.AVAILABLE, "stack-1", "stack-crn-1");
    dataHubStack1.setCluster(createClusterResponse(Status.AVAILABLE, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack2 = createStackResponse(Status.DELETE_COMPLETED, "stack-2", "stack-crn-2");
    dataHubStack2.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack3 = createStackResponse(Status.STOPPED, "stack-3", "stack-crn-2");
    dataHubStack3.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses(Set.of(dataHubStack1, dataHubStack2, dataHubStack3));
    Stack stack = new Stack();
    String actualRunning = underTest.checkForRunningAttachedClusters(stackViewV4Responses, stack);
    String actualNonUpgradeable = underTest.checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    assertEquals("There are attached Data Hub clusters in incorrect state: stack-1. Please stop those to be able to perform the upgrade.", actualRunning);
    assertEquals("", actualNonUpgradeable);
    verify(spotInstanceUsageCondition).isStackRunsOnSpotInstances(stack);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Aggregations

StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)32 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)18 Test (org.junit.jupiter.api.Test)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 Test (org.junit.Test)8 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)3 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 StackApiView (com.sequenceiq.cloudbreak.domain.view.StackApiView)2