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;
}
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);
}
}
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()));
}
}
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.");
}
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);
}
Aggregations