Search in sources :

Example 11 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverter method convert.

public StackV4Request convert(DistroXV1Request source) {
    DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(source.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
    StackV4Request request = new StackV4Request();
    SdxClusterResponse sdxClusterResponse = getSdxClusterResponse(environment);
    request.setName(source.getName());
    request.setType(StackType.WORKLOAD);
    request.setCloudPlatform(getCloudPlatform(environment));
    request.setEnvironmentCrn(environment.getCrn());
    request.setAuthentication(getIfNotNull(environment.getAuthentication(), authenticationConverter::convert));
    request.setImage(getIfNotNull(source.getImage(), imageConverter::convert));
    request.setCluster(getIfNotNull(source, environment, clusterConverter::convert));
    NetworkV4Request network = getNetwork(source.getNetwork(), environment, source.getInstanceGroups());
    request.setNetwork(network);
    request.setInstanceGroups(getIfNotNull(source.getInstanceGroups(), igs -> instanceGroupConverter.convertTo(network, igs, environment)));
    request.setAws(getIfNotNull(source.getAws(), stackParameterConverter::convert));
    request.setAzure(getIfNotNull(source.getAzure(), stackParameterConverter::convert));
    request.setGcp(getIfNotNull(source.getGcp(), stackParameterConverter::convert));
    request.setYarn(getYarnProperties(source, environment));
    request.setInputs(source.getInputs());
    request.setTags(getIfNotNull(source.getTags(), this::getTags));
    request.setPlacement(preparePlacement(environment));
    request.setSharedService(sdxConverter.getSharedService(sdxClusterResponse));
    request.setCustomDomain(null);
    request.setTimeToLive(source.getTimeToLive());
    request.setTelemetry(getTelemetryRequest(environment, sdxClusterResponse));
    request.setGatewayPort(source.getGatewayPort());
    request.setExternalDatabase(getIfNotNull(source.getExternalDatabase(), databaseRequestConverter::convert));
    request.setEnableLoadBalancer(source.isEnableLoadBalancer());
    request.setVariant(source.getVariant());
    checkMultipleGatewayNodes(source);
    return request;
}
Also used : PlacementSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.environment.placement.PlacementSettingsV4Request) InstanceGroupNetworkV1Base(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Base) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) TelemetryConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.TelemetryConverter) LoggerFactory(org.slf4j.LoggerFactory) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TagsV1Request(com.sequenceiq.distrox.api.v1.distrox.model.tags.TagsV1Request) ArrayList(java.util.ArrayList) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) HashSet(java.util.HashSet) Inject(javax.inject.Inject) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) TagsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) Collection(java.util.Collection) Set(java.util.Set) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) YarnStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.YarnStackV4Parameters) Component(org.springframework.stereotype.Component) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)

Example 12 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class PaasSdxServiceTest method testListStatusPairsCrn.

@Test
public void testListStatusPairsCrn() {
    SdxClusterResponse sdxClusterResponse = getSdxClusterResponse();
    when(sdxEndpoint.list(any(), anyBoolean())).thenReturn(List.of(sdxClusterResponse));
    assertTrue(underTest.listSdxCrnStatusPair(ENV_CRN, "env", Set.of(PAAS_CRN)).contains(Pair.of(PAAS_CRN, SdxClusterStatusResponse.RUNNING)));
    verify(sdxEndpoint).list(any(), anyBoolean());
}
Also used : SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Example 13 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class PaasSdxServiceTest method testListCrn.

@Test
public void testListCrn() {
    SdxClusterResponse sdxClusterResponse = getSdxClusterResponse();
    when(sdxEndpoint.list(any(), anyBoolean())).thenReturn(List.of(sdxClusterResponse));
    assertTrue(underTest.listSdxCrns("envName", ENV_CRN).contains(PAAS_CRN));
    verify(sdxEndpoint).list(eq("envName"), anyBoolean());
}
Also used : SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Example 14 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class PaasSdxServiceTest method getSdxClusterResponse.

private SdxClusterResponse getSdxClusterResponse() {
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    sdxClusterResponse.setCrn(PAAS_CRN);
    sdxClusterResponse.setEnvironmentCrn(ENV_CRN);
    sdxClusterResponse.setStatus(SdxClusterStatusResponse.RUNNING);
    return sdxClusterResponse;
}
Also used : SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse)

Example 15 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class SdxPollerProviderTest method testStopDatalakePoller.

@ParameterizedTest
@MethodSource("datalakeStopStatuses")
void testStopDatalakePoller(SdxClusterStatusResponse s1Status, SdxClusterStatusResponse s2Status, AttemptState attemptState, String message, List<String> remaining) throws Exception {
    List<String> pollingCrn = new ArrayList<>();
    pollingCrn.add("crn1");
    pollingCrn.add("crn2");
    SdxClusterResponse sdx1 = getSdxResponse(s1Status, "crn1");
    SdxClusterResponse sdx2 = getSdxResponse(s2Status, "crn2");
    when(sdxService.getByCrn("crn1")).thenReturn(sdx1);
    when(sdxService.getByCrn("crn2")).thenReturn(sdx2);
    AttemptResult<Void> result = underTest.stopSdxClustersPoller(ENV_ID, pollingCrn).process();
    assertEquals(attemptState, result.getState());
}
Also used : ArrayList(java.util.ArrayList) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)54 Test (org.junit.jupiter.api.Test)22 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)10 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)8 Test (org.junit.Test)8 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)7 ArrayList (java.util.ArrayList)7 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)5 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 SdxClientService (com.sequenceiq.cloudbreak.service.datalake.SdxClientService)4 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)4 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)4 Set (java.util.Set)4 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3