use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtLaunchServiceTest method testStartManagementServicesShouldSendStartCommandWhenTheManagementServicesAreNotStarted.
@Test
public void testStartManagementServicesShouldSendStartCommandWhenTheManagementServicesAreNotStarted() throws ApiException {
MgmtServiceResourceApi mgmtServiceResourceApi = mock(MgmtServiceResourceApi.class);
ApiService apiService = mock(ApiService.class);
ApiCommand apiCommand = getApiCommand();
when(clouderaManagerApiFactory.getMgmtServiceResourceApi(apiClient)).thenReturn(mgmtServiceResourceApi);
when(mgmtServiceResourceApi.readService(DataView.SUMMARY.name())).thenReturn(apiService);
when(apiService.getServiceState()).thenReturn(ApiServiceState.STOPPED);
when(mgmtServiceResourceApi.startCommand()).thenReturn(apiCommand);
underTest.startManagementServices(stack, apiClient);
verify(mgmtServiceResourceApi).readService(DataView.SUMMARY.name());
verify(mgmtServiceResourceApi).startCommand();
verify(clouderaManagerPollingServiceProvider).startPollingCmManagementServiceStartup(stack, apiClient, apiCommand.getId());
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtLaunchService method startManagementServices.
void startManagementServices(Stack stack, ApiClient apiClient) throws ApiException {
MgmtServiceResourceApi mgmtServiceResourceApi = getMgmtServiceResourceApi(apiClient);
ApiService mgmtService = getMgmtService(mgmtServiceResourceApi);
Optional<ApiCommand> startCommand = Optional.empty();
ApiServiceState serviceState = mgmtService.getServiceState();
if (serviceState != ApiServiceState.STARTED && serviceState != ApiServiceState.STARTING) {
startCommand = Optional.of(mgmtServiceResourceApi.startCommand());
}
startCommand.ifPresent(command -> startPolling(stack, apiClient, command));
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtSetupService method setupMgmtServices.
/**
* Sets up the management services using the given Cloudera Manager apiClient.
*
* @param stack the stack
* @param apiClient the CM API apiClient
* @param cmHostRef reference to the CM host
* @param telemetry telemetry (logging/workload/billing etc.) details
* @param sdxContextName sdx name holder
* @param sdxStackCrn sdx stack crn holder
* @param proxyConfig ccm proxy configuration holder
* @throws ApiException if there's a problem setting up management services
*/
public void setupMgmtServices(Stack stack, ApiClient apiClient, ApiHostRef cmHostRef, Telemetry telemetry, String sdxContextName, String sdxStackCrn, ProxyConfig proxyConfig) throws ApiException {
LOGGER.debug("Setting up Cloudera Management Services.");
licenseService.validateClouderaManagerLicense(Crn.safeFromString(stack.getResourceCrn()).getAccountId());
MgmtServiceResourceApi mgmtServiceResourceApi = clouderaManagerApiFactory.getMgmtServiceResourceApi(apiClient);
MgmtRolesResourceApi mgmtRolesResourceApi = clouderaManagerApiFactory.getMgmtRolesResourceApi(apiClient);
ApiService mgmtService = new ApiService();
mgmtService.setName(MGMT_SERVICE);
mgmtService.setType(MGMT_SERVICE);
setupCMS(mgmtServiceResourceApi, mgmtService);
ApiRoleList mgmtRoles = new ApiRoleList();
List<String> roleTypes = mgmtServiceResourceApi.listRoleTypes().getItems();
for (String roleType : roleTypes) {
if (!BLACKLISTED_ROLE_TYPES.contains(roleType)) {
LOGGER.debug("Role type {} is not on black list. Adding it to management roles for host {}.", roleType, cmHostRef.getHostname());
ApiRole apiRole = new ApiRole();
apiRole.setName(roleType);
apiRole.setType(roleType);
apiRole.setHostRef(cmHostRef);
mgmtRoles.addItemsItem(apiRole);
}
}
cmConfigService.setConfigs(stack, mgmtRoles);
telemetryService.setupTelemetryRole(stack, apiClient, cmHostRef, mgmtRoles, telemetry, sdxStackCrn);
createMgmtRoles(mgmtRolesResourceApi, mgmtRoles);
telemetryService.updateTelemetryConfigs(stack, apiClient, telemetry, sdxContextName, sdxStackCrn, proxyConfig);
telemetryService.updateServiceMonitorConfigs(stack, apiClient, telemetry);
waitForGenerateCredentialsToFinish(stack, apiClient);
setUpAutoConfiguration(mgmtServiceResourceApi);
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method restartMgmtServices.
private void restartMgmtServices() throws ApiException, CloudbreakException {
MgmtServiceResourceApi mgmtServiceResourceApi = clouderaManagerApiFactory.getMgmtServiceResourceApi(apiClient);
restartClouderaManagementServices(mgmtServiceResourceApi);
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method restartClouderaManagementServices.
private void restartClouderaManagementServices(MgmtServiceResourceApi mgmtServiceResourceApi) throws ApiException, CloudbreakException {
LOGGER.debug("Restarting Cloudera Management Services in Cloudera Manager.");
ApiCommandList apiCommandList = mgmtServiceResourceApi.listActiveCommands(SUMMARY);
Optional<ApiCommand> optionalRestartCommand = apiCommandList.getItems().stream().filter(cmd -> "Restart".equals(cmd.getName())).findFirst();
ApiCommand restartCommand;
if (optionalRestartCommand.isPresent()) {
restartCommand = optionalRestartCommand.get();
LOGGER.debug("Restart for CMS is already running with id: [{}]", restartCommand.getId());
} else {
restartCommand = mgmtServiceResourceApi.restartCommand();
}
pollRestart(restartCommand);
LOGGER.debug("Restarted Cloudera Management Services in Cloudera Manager.");
}
Aggregations