Search in sources :

Example 1 with CommandsResourceApi

use of com.cloudera.api.swagger.CommandsResourceApi in project cloudbreak by hortonworks.

the class ClouderaManagerCommissioner method abortRecommissionWithWarnMessage.

private void abortRecommissionWithWarnMessage(ApiCommand apiCommand, ApiClient client, String warningMessage) throws ApiException {
    LOGGER.warn(warningMessage, apiCommand.getId());
    CommandsResourceApi commandsResourceApi = clouderaManagerApiFactory.getCommandsResourceApi(client);
    commandsResourceApi.abortCommand(apiCommand.getId());
}
Also used : CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi)

Example 2 with CommandsResourceApi

use of com.cloudera.api.swagger.CommandsResourceApi in project cloudbreak by hortonworks.

the class ClouderaManagerCommandsService method retryApiCommand.

public ApiCommand retryApiCommand(ApiClient client, BigDecimal commandId) throws ApiException {
    CommandsResourceApi commandsResourceApi = clouderaManagerApiFactory.getCommandsResourceApi(client);
    ApiCommand retryApiCommand = commandsResourceApi.retry(commandId);
    LOGGER.debug("Retry Api command by id {} result is {}", commandId, retryApiCommand);
    return retryApiCommand;
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi)

Example 3 with CommandsResourceApi

use of com.cloudera.api.swagger.CommandsResourceApi in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandListCheckerTask method doStatusCheck.

protected boolean doStatusCheck(T pollerObject) throws ApiException {
    CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
    List<ApiCommand> apiCommands = collectApiCommands(pollerObject, commandsResourceApi);
    boolean allCommandsFinished = apiCommands.stream().noneMatch(ApiCommand::getActive);
    if (allCommandsFinished) {
        validateApiCommandResults(apiCommands, commandsResourceApi);
        return true;
    } else {
        return false;
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi)

Example 4 with CommandsResourceApi

use of com.cloudera.api.swagger.CommandsResourceApi in project cloudbreak by hortonworks.

the class ClouderaManagerRangerUtil method getApiCommand.

public ApiCommand getApiCommand(String stackCrn, long commandId) throws ApiException {
    ApiClient client = clouderaManagerProxiedClientFactory.getProxiedClouderaManagerClient(stackCrn);
    CommandsResourceApi commandsResourceApi = clouderaManagerApiFactory.getCommandsResourceApi(client);
    return commandsResourceApi.readCommand(BigDecimal.valueOf(commandId));
}
Also used : RoleCommandsResourceApi(com.cloudera.api.swagger.RoleCommandsResourceApi) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 5 with CommandsResourceApi

use of com.cloudera.api.swagger.CommandsResourceApi in project cloudbreak by hortonworks.

the class ClouderaManagerCommissionerTest method testRecommissionNodesTimeout.

@Test
public void testRecommissionNodesTimeout() throws ApiException {
    Set<String> hostNames = createHostnames(3);
    ApiHostList apiHostList = createGoodHealthApiHostList(hostNames);
    mockListClusterHosts(apiHostList);
    Map<String, InstanceMetaData> hostsToDecommission;
    Set<InstanceMetaData> instanceMetaDataSet = createRunningInstanceMetadata(hostNames);
    Map<String, InstanceMetaData> hostsToCommission = instanceMetaDataSet.stream().collect(Collectors.toMap(InstanceMetaData::getDiscoveryFQDN, e -> e));
    // TODO CB-15132: What are the other PollingResults that CM can return. How about entities like FAILURE?.
    // Is an explicit check for SUCCESS required?
    mockCommissionAndExitMaintenanceMode(new ExtendedPollingResult.ExtendedPollingResultBuilder().timeout().build());
    mockAbortCommission();
    assertThrows(CloudbreakServiceException.class, () -> underTest.recommissionNodes(getStack(), hostsToCommission, client));
    verify(commandsResourceApi).abortCommand(eq(BigDecimal.valueOf(1)));
}
Also used : ApiHostList(com.cloudera.api.swagger.model.ApiHostList) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ApiException(com.cloudera.api.swagger.client.ApiException) ClouderaManagerPollingServiceProvider(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider) HashSet(java.util.HashSet) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) BigDecimal(java.math.BigDecimal) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Map(java.util.Map) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) Set(java.util.Set) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test)

Aggregations

CommandsResourceApi (com.cloudera.api.swagger.CommandsResourceApi)10 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)7 ApiClient (com.cloudera.api.swagger.client.ApiClient)2 ApiException (com.cloudera.api.swagger.client.ApiException)2 ClouderaManagerOperationFailedException (com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)1 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)1 RoleCommandsResourceApi (com.cloudera.api.swagger.RoleCommandsResourceApi)1 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)1 ClouderaManagerApiFactory (com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory)1 ClouderaManagerPollingServiceProvider (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1