Search in sources :

Example 1 with SharedServiceV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response in project cloudbreak by hortonworks.

the class DatalakeService method addSharedServiceResponse.

public void addSharedServiceResponse(Stack stack, StackV4Response stackResponse) {
    SharedServiceV4Response sharedServiceResponse = new SharedServiceV4Response();
    if (!Strings.isNullOrEmpty(stack.getDatalakeCrn())) {
        LOGGER.debug("Checking datalake through the datalakeCrn.");
        Optional<ResourceBasicView> resourceBasicView = stackService.getResourceBasicViewByResourceCrn(stack.getDatalakeCrn());
        if (resourceBasicView.isPresent()) {
            ResourceBasicView s = resourceBasicView.get();
            sharedServiceResponse.setSharedClusterId(s.getId());
            sharedServiceResponse.setSharedClusterName(s.getName());
        } else {
            LOGGER.debug("Unable to find datalake with CRN {}", stack.getDatalakeCrn());
        }
    }
    stackResponse.setSharedService(sharedServiceResponse);
}
Also used : ResourceBasicView(com.sequenceiq.cloudbreak.common.dal.ResourceBasicView) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)

Example 2 with SharedServiceV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response 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 SharedServiceV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverterTest method setUp.

@Before
public void setUp() throws CloudbreakImageNotFoundException {
    underTest = new StackToStackV4ResponseConverter();
    MockitoAnnotations.initMocks(this);
    when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", Collections.emptyMap(), "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()));
    when(componentConfigProviderService.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
    when(componentConfigProviderService.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
    when(componentConfigProviderService.getTelemetry(anyLong())).thenReturn(new Telemetry());
    Mockito.doAnswer(answer -> {
        StackV4Response result = answer.getArgument(1, StackV4Response.class);
        result.setSharedService(new SharedServiceV4Response());
        return null;
    }).when(datalakeService).addSharedServiceResponse(any(Stack.class), any(StackV4Response.class));
    when(serviceEndpointCollector.filterByStackType(any(StackType.class), any(List.class))).thenReturn(new ArrayList());
    credentialResponse = new CredentialResponse();
    credentialResponse.setName("cred-name");
    credentialResponse.setCrn("crn");
    when(loadBalancerService.findByStackId(any())).thenReturn(Set.of());
}
Also used : HashMap(java.util.HashMap) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) ArrayList(java.util.ArrayList) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackToStackV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.StackToStackV4ResponseConverter) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) List(java.util.List) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 4 with SharedServiceV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response in project cloudbreak by hortonworks.

the class DatalakeService method addSharedServiceResponse.

public void addSharedServiceResponse(ClusterApiView cluster, ClusterViewV4Response clusterResponse) {
    SharedServiceV4Response sharedServiceResponse = new SharedServiceV4Response();
    if (cluster.getStack().getDatalakeCrn() != null) {
        LOGGER.debug("Add shared service response by datalakeCrn");
        Optional<ResourceBasicView> datalakeStack = stackService.getResourceBasicViewByResourceCrn(cluster.getStack().getDatalakeCrn());
        datalakeStack.ifPresent(s -> {
            sharedServiceResponse.setSharedClusterId(s.getId());
            sharedServiceResponse.setSharedClusterName(s.getName());
        });
    }
    clusterResponse.setSharedServiceResponse(sharedServiceResponse);
}
Also used : ResourceBasicView(com.sequenceiq.cloudbreak.common.dal.ResourceBasicView) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)

Aggregations

SharedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)4 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)2 ResourceBasicView (com.sequenceiq.cloudbreak.common.dal.ResourceBasicView)2 List (java.util.List)2 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)1 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 StackTemplate (com.sequenceiq.cloudbreak.cloud.model.StackTemplate)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 StackToStackV4ResponseConverter (com.sequenceiq.cloudbreak.converter.v4.stacks.StackToStackV4ResponseConverter)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 SdxClientService (com.sequenceiq.cloudbreak.service.datalake.SdxClientService)1 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)1 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)1 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 Set (java.util.Set)1