Search in sources :

Example 26 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxDeleteInternalAction method action.

@Override
public SdxInternalTestDto action(TestContext testContext, SdxInternalTestDto testDto, SdxClient client) throws Exception {
    Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
    Log.whenJson(LOGGER, " SDX Internal delete request: ", testDto.getRequest());
    FlowIdentifier flowIdentifier = client.getDefaultClient().sdxEndpoint().delete(testDto.getName(), false);
    testDto.setFlow("SDX delete", flowIdentifier);
    SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
    testDto.setResponse(detailedResponse);
    Log.whenJson(LOGGER, " SDX Internal delete response: ", detailedResponse);
    return testDto;
}
Also used : SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 27 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxForceDeleteAction method action.

@Override
public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
    Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
    Log.whenJson(LOGGER, " SDX force delete request: ", testDto.getRequest());
    FlowIdentifier flowIdentifier = client.getDefaultClient().sdxEndpoint().delete(testDto.getName(), true);
    testDto.setFlow("SDX force delete", flowIdentifier);
    SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
    testDto.setResponse(detailedResponse);
    Log.whenJson(LOGGER, " SDX force delete response: ", detailedResponse);
    return testDto;
}
Also used : SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 28 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxForceDeleteInternalAction method action.

@Override
public SdxInternalTestDto action(TestContext testContext, SdxInternalTestDto testDto, SdxClient client) throws Exception {
    Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
    FlowIdentifier flowIdentifier = client.getDefaultClient().sdxEndpoint().delete(testDto.getName(), true);
    testDto.setFlow("SDX Internal force delete", flowIdentifier);
    SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
    testDto.setResponse(detailedResponse);
    Log.whenJson(LOGGER, " SDX Internal force delete response: ", detailedResponse);
    return testDto;
}
Also used : SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 29 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class LoadBalancerPollerService method updateStackWithLoadBalancer.

public void updateStackWithLoadBalancer(Long environmentId, String environmentCrn, String environmentName, PublicEndpointAccessGateway endpointAccessGateway) {
    Set<String> stackNames;
    if (PublicEndpointAccessGateway.ENABLED.equals(endpointAccessGateway)) {
        LOGGER.debug("Updating load balancers for endpoint gateway on Data Lake and Data Hubs.");
        stackNames = getDataLakeAndDataHubNames(environmentCrn, environmentName);
        LOGGER.debug("Found {} Data Lake and Data Hub clusters to update for environment {}.", stackNames.size(), environmentName);
    } else {
        LOGGER.debug("Updating load balancer for Data Lake cluster.");
        stackNames = getAttachedDatalakeClusters(environmentName);
    }
    if (stackNames.isEmpty()) {
        LOGGER.debug("No Data Lake or Data Hub clusters found for environment.");
    } else {
        try {
            List<FlowIdentifier> failedFlows = waitStackLoadBalancerUpdate(getPollingConfig(), stackNames, environmentName);
            LOGGER.debug("Data Lake and Data Hub load balancer update finished.");
            if (!failedFlows.isEmpty()) {
                LOGGER.error("Found failed flows for Data Lake or Data Hub load balancer updates: " + failedFlows);
                throw new UpdateFailedException("Data Lake or Data Hub update flows failed: " + failedFlows);
            }
        } catch (PollerStoppedException e) {
            throw new UpdateFailedException("Stack update poller reached timeout.", e);
        }
    }
}
Also used : FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 30 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class StackService method updateLoadBalancer.

public List<FlowIdentifier> updateLoadBalancer(Set<String> names) {
    String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
    List<FlowIdentifier> flowIdentifiers = new ArrayList<>();
    for (String name : names) {
        try {
            ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> {
                FlowIdentifier flowidentifier = stackV4Endpoint.updateLoadBalancersInternal(0L, name, initiatorUserCrn);
                flowIdentifiers.add(flowidentifier);
            });
        } catch (WebApplicationException e) {
            String errorMessage = messageExtractor.getErrorMessage(e);
            LOGGER.error(String.format("Failed update load balancer for stack %s due to: '%s'.", name, errorMessage), e);
            throw e;
        }
    }
    return flowIdentifiers;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ArrayList(java.util.ArrayList) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Aggregations

FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)150 Test (org.junit.jupiter.api.Test)55 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)37 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)15 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)14 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)14 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)10 Supplier (java.util.function.Supplier)10 ImageChangeDto (com.sequenceiq.cloudbreak.service.image.ImageChangeDto)9 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)7 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)7 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)7 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)7