use of com.cloudera.api.swagger.model.ApiCommand in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method deployConfig.
private void deployConfig() throws ApiException, CloudbreakException {
LOGGER.debug("Deploying client configs and refreshing services in Cloudera Manager.");
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_UPDATING_REMOTE_DATA_CONTEXT);
ApiCommand deployCommand = clustersResourceApi.deployClientConfig(stack.getName());
pollRefresh(deployCommand);
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_UPDATED_REMOTE_DATA_CONTEXT);
LOGGER.debug("Deployed client configs and refreshed services in Cloudera Manager.");
}
use of com.cloudera.api.swagger.model.ApiCommand 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);
}
use of com.cloudera.api.swagger.model.ApiCommand in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method refreshServices.
private void refreshServices(ClustersResourceApi clustersResourceApi, boolean forced, List<ApiCommand> commands) throws ApiException, CloudbreakException {
try {
ApiCommand refreshServicesCmd = clouderaManagerCommonCommandService.getApiCommand(commands, "RefreshCluster", stack.getName(), clustersResourceApi::refresh);
pollRefresh(refreshServicesCmd);
} catch (Exception e) {
LOGGER.error("Error occured during refreshing stale services, forced: {}", forced, e);
if (!forced) {
throw e;
}
}
}
use of com.cloudera.api.swagger.model.ApiCommand in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method applyHostGroupRolesOnUpscaledHosts.
private void applyHostGroupRolesOnUpscaledHosts(ApiHostRefList body, String hostGroupName) throws ApiException, CloudbreakException {
LOGGER.debug("Applying host template on upscaled hosts. Host group: [{}]", hostGroupName);
HostTemplatesResourceApi templatesResourceApi = clouderaManagerApiFactory.getHostTemplatesResourceApi(apiClient);
ApiCommand applyHostTemplateCommand = templatesResourceApi.applyHostTemplate(stack.getName(), hostGroupName, START_ROLES_ON_UPSCALED_NODES, body);
ExtendedPollingResult hostTemplatePollingResult = clouderaManagerPollingServiceProvider.startPollingCmApplyHostTemplate(stack, apiClient, applyHostTemplateCommand.getId());
handlePollingResult(hostTemplatePollingResult, "Cluster was terminated while waiting for host template to apply", "Timeout while Cloudera Manager was applying host template.");
LOGGER.debug("Applied host template on upscaled hosts. Host group: [{}]", hostGroupName);
}
use of com.cloudera.api.swagger.model.ApiCommand in project cloudbreak by hortonworks.
the class ClouderaManagerParcelManagementService method refreshParcelRepos.
public void refreshParcelRepos(ClouderaManagerResourceApi clouderaManagerResourceApi, Stack stack, ApiClient apiClient) {
try {
LOGGER.info("Refreshing parcel repos.");
ApiCommand apiCommand = clouderaManagerResourceApi.refreshParcelRepos();
clouderaManagerPollingServiceProvider.startPollingCmParcelRepositoryRefresh(stack, apiClient, apiCommand.getId());
} catch (ApiException e) {
LOGGER.info("Unable to refresh parcel repo", e);
throw new ClouderaManagerOperationFailedException(e.getMessage(), e);
}
}
Aggregations