Search in sources :

Example 1 with ExtendedPollingResult

use of com.sequenceiq.cloudbreak.polling.ExtendedPollingResult in project cloudbreak by hortonworks.

the class ClusterBootstrapper method collectAndCheckGateways.

private List<GatewayConfig> collectAndCheckGateways(Stack stack) {
    LOGGER.info("Collect and check gateways for {}", stack.getName());
    List<GatewayConfig> allGatewayConfig = new ArrayList<>();
    for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, isKnoxEnabled(stack));
        LOGGER.info("Add gateway config: {}", gatewayConfig);
        allGatewayConfig.add(gatewayConfig);
        ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
        validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
    }
    return allGatewayConfig;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ArrayList(java.util.ArrayList) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with ExtendedPollingResult

use of com.sequenceiq.cloudbreak.polling.ExtendedPollingResult in project cloudbreak by hortonworks.

the class ClusterBootstrapper method bootstrapNewNodesOnHost.

private void bootstrapNewNodesOnHost(Stack stack, List<GatewayConfig> allGatewayConfigs, Set<Node> nodes, Set<Node> allNodes) throws CloudbreakOrchestratorException {
    LOGGER.info("Bootstrap new nodes: {}", nodes);
    Cluster cluster = stack.getCluster();
    Boolean enableKnox = cluster.getGateway() != null;
    for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
        ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
        validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
    }
    byte[] stateZip = null;
    ClusterComponent stateComponent = clusterComponentProvider.getComponent(cluster.getId(), ComponentType.SALT_STATE);
    if (stateComponent != null) {
        String content = (String) stateComponent.getAttributes().getMap().getOrDefault(ComponentType.SALT_STATE.name(), "");
        if (!content.isEmpty()) {
            stateZip = Base64.decodeBase64(content);
        }
    }
    BootstrapParams params = createBootstrapParams(stack);
    hostOrchestrator.bootstrapNewNodes(allGatewayConfigs, nodes, allNodes, stateZip, params, clusterDeletionBasedModel(stack.getId(), null));
    InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
    GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
    ExtendedPollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
    validatePollingResultForCancellation(allNodesAvailabilityPolling.getPollingResult(), "Polling of new nodes availability was cancelled.");
    if (allNodesAvailabilityPolling.isTimeout()) {
        clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostOrchestratorClusterContext) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) BootstrapParams(com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 3 with ExtendedPollingResult

use of com.sequenceiq.cloudbreak.polling.ExtendedPollingResult in project cloudbreak by hortonworks.

the class PollBindUserCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<PollBindUserCreationEvent> event) {
    PollBindUserCreationEvent data = event.getData();
    FreeIpaOperationPollerObject operationPollerObject = new FreeIpaOperationPollerObject(data.getOperationId(), OperationType.BIND_USER_CREATE.name(), operationV1Endpoint, data.getAccountId(), regionAwareInternalCrnGeneratorFactory);
    ExtendedPollingResult result = freeIpaOperationChecker.pollWithAbsoluteTimeout(new FreeIpaOperationCheckerTask<>(), operationPollerObject, pollIntervalMilliSec, pollWaitTimeSec, pollMaxError);
    if (result.isSuccess()) {
        return new ValidateKerberosConfigEvent(VALIDATE_KERBEROS_CONFIG_EXISTS_EVENT.event(), data.getResourceId(), true);
    } else {
        StringBuilder errorMessage = new StringBuilder("Bind user creation failed");
        if (result.getException() != null) {
            errorMessage.append(" with: ");
            errorMessage.append(result.getException().getMessage());
        }
        return new StackFailureEvent(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), data.getResourceId(), new Exception(errorMessage.toString()));
    }
}
Also used : FreeIpaOperationPollerObject(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent)

Example 4 with ExtendedPollingResult

use of com.sequenceiq.cloudbreak.polling.ExtendedPollingResult in project cloudbreak by hortonworks.

the class ClouderaManagerModificationService method pollRefresh.

@VisibleForTesting
void pollRefresh(ApiCommand restartCommand) throws CloudbreakException {
    ExtendedPollingResult hostTemplatePollingResult = clouderaManagerPollingServiceProvider.startPollingCmConfigurationRefresh(stack, apiClient, restartCommand.getId());
    handlePollingResult(hostTemplatePollingResult, "Cluster was terminated while waiting for service refresh", "Timeout while Cloudera Manager was refreshing services.");
}
Also used : ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with ExtendedPollingResult

use of com.sequenceiq.cloudbreak.polling.ExtendedPollingResult in project cloudbreak by hortonworks.

the class ClouderaManagerModificationService method doRestartServicesIfNeeded.

private int doRestartServicesIfNeeded(ClustersResourceApi clustersResourceApi, boolean waitForCommandExecutionOnly) throws ApiException, CloudbreakException {
    ApiCommandList apiCommandList = clustersResourceApi.listActiveCommands(stack.getName(), SUMMARY);
    Optional<ApiCommand> optionalRestartCommand = apiCommandList.getItems().stream().filter(cmd -> "Restart".equals(cmd.getName())).findFirst();
    ApiCommand restartCommand = null;
    if (optionalRestartCommand.isPresent()) {
        restartCommand = optionalRestartCommand.get();
        LOGGER.debug("Restart for Cluster services is already running with id: [{}]", restartCommand.getId());
    } else if (!waitForCommandExecutionOnly) {
        LOGGER.info("Restarting cluster services.");
        ApiRestartClusterArgs restartClusterArgs = new ApiRestartClusterArgs();
        restartClusterArgs.setRedeployClientConfiguration(true);
        restartCommand = clustersResourceApi.restartCommand(stack.getName(), restartClusterArgs);
        eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_RESTARTING);
    }
    if (restartCommand != null) {
        ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(stack, apiClient, restartCommand.getId());
        handlePollingResult(pollingResult, "Cluster was terminated while restarting services.", "Timeout happened while restarting services.");
    }
    return getCommandId(restartCommand);
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ApiBatchRequestElement(com.cloudera.api.swagger.model.ApiBatchRequestElement) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) LoggerFactory(org.slf4j.LoggerFactory) ApiService(com.cloudera.api.swagger.model.ApiService) ApiException(com.cloudera.api.swagger.client.ApiException) ClouderaManagerProductsProvider(com.sequenceiq.cloudbreak.cluster.service.ClouderaManagerProductsProvider) ParcelStatus(com.sequenceiq.cloudbreak.cm.model.ParcelStatus) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) BigDecimal(java.math.BigDecimal) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) BatchResourceApi(com.cloudera.api.swagger.BatchResourceApi) Locale(java.util.Locale) Map(java.util.Map) ApiHostRefList(com.cloudera.api.swagger.model.ApiHostRefList) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) HostTemplatesResourceApi(com.cloudera.api.swagger.HostTemplatesResourceApi) CLOUDERAMANAGER_VERSION_7_6_0(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_6_0) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Predicate(java.util.function.Predicate) Collection(java.util.Collection) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) PollingResultErrorHandler(com.sequenceiq.cloudbreak.cm.polling.PollingResultErrorHandler) Set(java.util.Set) ApiBatchResponse(com.cloudera.api.swagger.model.ApiBatchResponse) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Objects(java.util.Objects) List(java.util.List) ApiEntityTag(com.cloudera.api.swagger.model.ApiEntityTag) ApiRestartClusterArgs(com.cloudera.api.swagger.model.ApiRestartClusterArgs) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) PollingResult(com.sequenceiq.cloudbreak.polling.PollingResult) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) ClusterModificationService(com.sequenceiq.cloudbreak.cluster.api.ClusterModificationService) ApiCallback(com.cloudera.api.swagger.client.ApiCallback) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiConfigStalenessStatus(com.cloudera.api.swagger.model.ApiConfigStalenessStatus) CLUSTER_CM_CLUSTER_SERVICES_STARTING(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_CM_CLUSTER_SERVICES_STARTING) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) ClouderaManagerPollingServiceProvider(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider) Inject(javax.inject.Inject) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ClouderaManagerApiClientProvider(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerApiClientProvider) UPDATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS) Service(org.springframework.stereotype.Service) ApiHost(com.cloudera.api.swagger.model.ApiHost) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) CLUSTER_CM_CLUSTER_SERVICES_RESTARTING(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_CM_CLUSTER_SERVICES_RESTARTING) ApiBatchRequest(com.cloudera.api.swagger.model.ApiBatchRequest) CLOUDERAMANAGER_VERSION_7_5_1(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_5_1) ApiServiceState(com.cloudera.api.swagger.model.ApiServiceState) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CLUSTER_CM_UPDATED_REMOTE_DATA_CONTEXT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_CM_UPDATED_REMOTE_DATA_CONTEXT) Logger(org.slf4j.Logger) CLOUDERAMANAGER_VERSION_7_1_0(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_1_0) CLUSTER_CM_CLUSTER_SERVICES_STARTED(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_CM_CLUSTER_SERVICES_STARTED) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) URLUtils(com.sequenceiq.cloudbreak.util.URLUtils) ApplicationContext(org.springframework.context.ApplicationContext) Consumer(java.util.function.Consumer) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HTTPMethod(com.cloudera.api.swagger.model.HTTPMethod) CLUSTER_CM_UPDATING_REMOTE_DATA_CONTEXT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_CM_UPDATING_REMOTE_DATA_CONTEXT) ApiHostRef(com.cloudera.api.swagger.model.ApiHostRef) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) MgmtServiceResourceApi(com.cloudera.api.swagger.MgmtServiceResourceApi) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) ParcelsResourceApi(com.cloudera.api.swagger.ParcelsResourceApi) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ApiRestartClusterArgs(com.cloudera.api.swagger.model.ApiRestartClusterArgs)

Aggregations

ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)64 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)20 Test (org.junit.jupiter.api.Test)18 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 Environment (com.sequenceiq.environment.environment.domain.Environment)13 ApiException (com.cloudera.api.swagger.client.ApiException)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)8 Map (java.util.Map)8 Set (java.util.Set)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 ApiClient (com.cloudera.api.swagger.client.ApiClient)7 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)7 Inject (javax.inject.Inject)7 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)6 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)6 Credential (com.sequenceiq.environment.credential.domain.Credential)6