Search in sources :

Example 6 with MgmtServiceResourceApi

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());
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiService(com.cloudera.api.swagger.model.ApiService) MgmtServiceResourceApi(com.cloudera.api.swagger.MgmtServiceResourceApi) Test(org.junit.Test)

Example 7 with MgmtServiceResourceApi

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));
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiServiceState(com.cloudera.api.swagger.model.ApiServiceState) ApiService(com.cloudera.api.swagger.model.ApiService) MgmtServiceResourceApi(com.cloudera.api.swagger.MgmtServiceResourceApi)

Example 8 with MgmtServiceResourceApi

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);
}
Also used : ApiRole(com.cloudera.api.swagger.model.ApiRole) ApiService(com.cloudera.api.swagger.model.ApiService) MgmtServiceResourceApi(com.cloudera.api.swagger.MgmtServiceResourceApi) ApiRoleList(com.cloudera.api.swagger.model.ApiRoleList) MgmtRolesResourceApi(com.cloudera.api.swagger.MgmtRolesResourceApi)

Example 9 with 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);
}
Also used : MgmtServiceResourceApi(com.cloudera.api.swagger.MgmtServiceResourceApi)

Example 10 with 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.");
}
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)

Aggregations

MgmtServiceResourceApi (com.cloudera.api.swagger.MgmtServiceResourceApi)10 ApiService (com.cloudera.api.swagger.model.ApiService)6 ApiClient (com.cloudera.api.swagger.client.ApiClient)4 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)4 ApiException (com.cloudera.api.swagger.client.ApiException)3 ApiServiceState (com.cloudera.api.swagger.model.ApiServiceState)3 BatchResourceApi (com.cloudera.api.swagger.BatchResourceApi)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)2 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)2 HostTemplatesResourceApi (com.cloudera.api.swagger.HostTemplatesResourceApi)2 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)2 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)2 ParcelsResourceApi (com.cloudera.api.swagger.ParcelsResourceApi)2 ServicesResourceApi (com.cloudera.api.swagger.ServicesResourceApi)2 ApiBatchRequest (com.cloudera.api.swagger.model.ApiBatchRequest)2 ApiBatchRequestElement (com.cloudera.api.swagger.model.ApiBatchRequestElement)2 ApiBatchResponse (com.cloudera.api.swagger.model.ApiBatchResponse)2 ApiCommandList (com.cloudera.api.swagger.model.ApiCommandList)2 ApiConfigStalenessStatus (com.cloudera.api.swagger.model.ApiConfigStalenessStatus)2 ApiEntityTag (com.cloudera.api.swagger.model.ApiEntityTag)2