use of com.cloudera.api.swagger.ClustersResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method startServices.
private int startServices() throws ApiException, CloudbreakException {
Cluster cluster = stack.getCluster();
ClustersResourceApi apiInstance = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
String clusterName = cluster.getName();
LOGGER.debug("Starting all services for cluster.");
configService.enableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, apiClient, stack.getName());
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_STARTING);
Collection<ApiService> apiServices = readServices(stack);
boolean anyServiceNotStarted = apiServices.stream().anyMatch(service -> !ApiServiceState.STARTED.equals(service.getServiceState()) && !ApiServiceState.STARTING.equals(service.getServiceState()) && !ApiServiceState.NA.equals(service.getServiceState()));
ApiCommand apiCommand = null;
if (anyServiceNotStarted) {
apiCommand = apiInstance.startCommand(clusterName);
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmStartup(stack, apiClient, apiCommand.getId());
handlePollingResult(pollingResult, "Cluster was terminated while waiting for Cloudera Runtime services to start", "Timeout while stopping Cloudera Manager services.");
}
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_STARTED);
return getCommandId(apiCommand);
}
use of com.cloudera.api.swagger.ClustersResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method upgradeClusterRuntime.
@Override
public void upgradeClusterRuntime(Set<ClusterComponent> components, boolean patchUpgrade, Optional<String> remoteDataContext) throws CloudbreakException {
try {
LOGGER.info("Starting to upgrade cluster runtimes. Patch upgrade: {}", patchUpgrade);
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
ParcelResourceApi parcelResourceApi = clouderaManagerApiFactory.getParcelResourceApi(apiClient);
ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
startClouderaManager();
startAgents();
tagHostsWithHostTemplateName();
checkParcelApiAvailability();
refreshRemoteDataContextFromDatalakeInCaseOfDatahub(remoteDataContext);
Set<ClouderaManagerProduct> products = getProducts(components);
setParcelRepo(products, clouderaManagerResourceApi);
refreshParcelRepos(clouderaManagerResourceApi);
restartMgmtServices();
if (patchUpgrade) {
downloadAndActivateParcels(products, parcelResourceApi, true);
startServices();
callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751(clustersResourceApi);
restartServices(clustersResourceApi);
} else {
ClouderaManagerProduct cdhProduct = clouderaManagerProductsProvider.getCdhProducts(products);
upgradeNonCdhProducts(products, cdhProduct.getName(), parcelResourceApi, true);
upgradeCdh(clustersResourceApi, parcelResourceApi, cdhProduct);
startServices();
deployConfigAndRefreshCMStaleServices(clustersResourceApi, false);
}
removeUnusedParcelVersions(parcelResourceApi, products);
configService.enableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, apiClient, stack.getName());
LOGGER.info("Cluster runtime upgrade finished");
} catch (ApiException e) {
LOGGER.info("Could not upgrade Cloudera Runtime services", e);
throw new ClouderaManagerOperationFailedException(e.getMessage(), e);
}
}
use of com.cloudera.api.swagger.ClustersResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerDeregisterService method deregisterServices.
public void deregisterServices(HttpClientConfig clientConfig, Stack stack, Optional<DatalakeDto> datalakeDto) {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
try {
CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
if (CMRepositoryVersionUtil.isRangerTearDownSupported(clouderaManagerRepoDetails)) {
if (datalakeDto.isPresent()) {
LOGGER.info("The current cluster {} is a Data Hub cluster so teardown REQUIRED.", stack.getName());
DatalakeDto datalake = datalakeDto.get();
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(datalakeClient(datalake));
clustersResourceApi.tearDownWorkloadCluster(datalake.getName(), stack.getName());
} else {
LOGGER.info("The current cluster {} is a Data Lake cluster so teardown NOT_REQUIRED.", stack.getName());
}
} else {
ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_REGISTRY_SERVER)) {
LOGGER.info("The current cluster {} contains NIFI_REGISTRY_SERVER and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFIREGISTRY);
}
if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_NODE)) {
LOGGER.info("The current cluster {} contains NIFI_NODE and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFI);
}
}
} catch (Exception e) {
LOGGER.warn("Couldn't remove services. This has to be done manually." + " It's possible that CM or the instance is not running. Notification is sent to the UI.", e);
cloudbreakEventService.fireCloudbreakEvent(stack.getId(), stack.getStatus().name(), ResourceEvent.CLUSTER_CM_SECURITY_GROUP_TOO_STRICT, List.of(e.getMessage()));
}
}
use of com.cloudera.api.swagger.ClustersResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerRoleRefreshService method refreshClusterRoles.
void refreshClusterRoles(ApiClient client, Stack stack) throws ApiException, CloudbreakException {
waitForGenerateCredentialsToFinish(stack, client);
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(client);
ApiCommand refreshCommand = clustersResourceApi.refresh(stack.getCluster().getName());
LOGGER.debug("Cluster role refresh has been started.");
pollingRefresh(refreshCommand, client, stack);
LOGGER.debug("Cluster role refresh finished successfully.");
}
Aggregations