Search in sources :

Example 76 with StackV4Response

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

the class StackToStackV4ResponseConverter method convert.

public StackV4Response convert(Stack source) {
    StackV4Response response = new StackV4Response();
    try {
        restRequestThreadLocalService.setWorkspace(source.getWorkspace());
        Image image = imageService.getImage(source.getId());
        response.setImage(imageToStackImageV4ResponseConverter.convert(image));
    } catch (CloudbreakImageNotFoundException exc) {
        LOGGER.debug(exc.getMessage());
    }
    response.setName(source.getName());
    response.setAuthentication(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(source.getStackAuthentication()));
    response.setCrn(source.getResourceCrn());
    response.setId(source.getId());
    response.setEnvironmentCrn(source.getEnvironmentCrn());
    response.setCloudPlatform(CloudPlatform.valueOf(source.getCloudPlatform()));
    response.setPlacement(stackToPlacementSettingsV4ResponseConverter.convert(source));
    response.setStatus(source.getStatus());
    response.setTerminated(source.getTerminated());
    response.setStatusReason(source.getStatusReason());
    response.setInstanceGroups(getInstanceGroups(source));
    response.setTunnel(source.getTunnel());
    response.setCluster(clusterToClusterV4ResponseConverter.convert(source.getCluster()));
    response.setNetwork(networkToNetworkV4ResponseConverter.convert(source));
    providerParameterCalculator.parse(new HashMap<>(source.getParameters()), response);
    response.setCreated(source.getCreated());
    response.setGatewayPort(source.getGatewayPort());
    response.setCustomDomains(stackToCustomDomainsSettingsV4Response.convert(source));
    response.setWorkspace(workspaceToWorkspaceResourceV4ResponseConverter.convert(source.getWorkspace()));
    addNodeCount(source, response);
    convertComponentConfig(response, source);
    convertTelemetryComponent(response, source);
    response.setTags(getTags(source.getTags()));
    response.setTimeToLive(getStackTimeToLive(source));
    response.setVariant(Strings.isNullOrEmpty(source.getPlatformVariant()) ? source.getCloudPlatform() : source.getPlatformVariant());
    response.setExternalDatabase(externalDatabaseToDatabaseResponseConverter.convert(source.getExternalDatabaseCreationType(), source.getExternalDatabaseEngineVersion()));
    datalakeService.addSharedServiceResponse(source, response);
    filterExposedServicesByType(source.getType(), response.getCluster());
    response.setLoadBalancers(convertLoadBalancers(source.getId()));
    if (!source.getLoadBalancers().isEmpty()) {
        response.setEnableLoadBalancer(true);
    }
    return response;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 77 with StackV4Response

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

the class DatalakeServiceTest method testAddSharedServiceResponseWhenDatalakeCrnIsNotNull.

@Test
public void testAddSharedServiceResponseWhenDatalakeCrnIsNotNull() {
    ResourceBasicView resourceBasicView = mock(ResourceBasicView.class);
    when(resourceBasicView.getId()).thenReturn(1L);
    when(resourceBasicView.getName()).thenReturn("teststack");
    lenient().when(stackService.getResourceBasicViewByResourceCrn(anyString())).thenReturn(Optional.of(resourceBasicView));
    Stack source = new Stack();
    source.setDatalakeCrn("crn");
    StackV4Response x = new StackV4Response();
    underTest.addSharedServiceResponse(source, x);
    verify(stackService, times(1)).getResourceBasicViewByResourceCrn("crn");
    assertEquals(1L, x.getSharedService().getSharedClusterId());
    assertEquals("teststack", x.getSharedService().getSharedClusterName());
}
Also used : ResourceBasicView(com.sequenceiq.cloudbreak.common.dal.ResourceBasicView) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 78 with StackV4Response

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

the class StackService method getJsonByCrn.

public StackV4Response getJsonByCrn(String crn, Collection<String> entry) {
    try {
        return transactionService.required(() -> {
            Stack stack = getByCrnWithLists(crn);
            StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack);
            stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entry);
            return stackResponse;
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Example 79 with StackV4Response

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

the class StackService method getByCrnInWorkspaceWithEntries.

public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
    try {
        return transactionService.required(() -> {
            Workspace workspace = workspaceService.get(workspaceId, user);
            ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
            Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
            if (stack.isEmpty()) {
                throw new NotFoundException(format("Stack not found by crn '%s'", crn));
            }
            StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
            stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
            return stackResponse;
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : ShowTerminatedClustersAfterConfig(com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Example 80 with StackV4Response

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

the class StackResponseHardwareInfoProviderTest method testProviderEntriesToStackResponseEmptyInstanceGroup.

@Test
public void testProviderEntriesToStackResponseEmptyInstanceGroup() {
    Stack stack = new Stack();
    stack.setInstanceGroups(emptySet());
    StackV4Response actual = underTest.providerEntriesToStackResponse(stack, new StackV4Response());
    Assert.assertEquals(0L, actual.getHardwareInfoGroups().size());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)101 Test (org.junit.jupiter.api.Test)26 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)19 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)14 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)7 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)7 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)6 TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)6 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)6 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)6