Search in sources :

Example 6 with CommandsResourceApi

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

the class ClouderaManagerTemplateInstallationChecker method doStatusCheck.

@Override
protected boolean doStatusCheck(ClouderaManagerCommandPollerObject pollerObject) throws ApiException {
    CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
    ApiCommand apiCommand = commandsResourceApi.readCommand(pollerObject.getId());
    if (apiCommand.getActive()) {
        LOGGER.debug("Command [" + getCommandName() + "] with id [" + pollerObject.getId() + "] is active, so it hasn't finished yet");
        return false;
    } else if (apiCommand.getSuccess()) {
        return true;
    } else {
        fail("", apiCommand, commandsResourceApi, pollerObject.getStack().getType());
    }
    return false;
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi)

Example 7 with CommandsResourceApi

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

the class ClouderaManagerTemplateInstallationChecker method handleTimeout.

@Override
public void handleTimeout(ClouderaManagerCommandPollerObject pollerObject) {
    String msg = "Installation of CDP with Cloudera Manager has timed out (command id: " + pollerObject.getId() + ").";
    try {
        CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
        ApiCommand apiCommand = commandsResourceApi.readCommand(pollerObject.getId());
        fail(msg, apiCommand, commandsResourceApi, pollerObject.getStack().getType());
    } catch (ApiException e) {
        LOGGER.info("Cloudera Manager had run into a timeout, and we were unable to determine the failure reason", e);
    }
    throw new ClouderaManagerOperationFailedException(msg);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 8 with CommandsResourceApi

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

the class AbstractClouderaManagerCommandCheckerTask method doStatusCheck.

protected boolean doStatusCheck(T pollerObject) throws ApiException {
    CommandsResourceApi commandsResourceApi = clouderaManagerApiPojoFactory.getCommandsResourceApi(pollerObject.getApiClient());
    ApiCommand apiCommand = commandsResourceApi.readCommand(pollerObject.getId());
    if (apiCommand.getActive()) {
        LOGGER.debug("Command [{}] with id [{}] is active, so it hasn't finished yet", getCommandName(), pollerObject.getId());
        return false;
    } else if (apiCommand.getSuccess()) {
        return true;
    } else {
        List<CommandDetails> commandDetails = ClouderaManagerCommandUtil.getFailedOrActiveCommands(apiCommand, commandsResourceApi);
        String message = CommandDetailsFormatter.formatFailedCommands(commandDetails);
        LOGGER.debug("Top level command {}. Failed or active commands: {}", CommandDetails.fromApiCommand(apiCommand), commandDetails);
        throw new ClouderaManagerOperationFailedException(message);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandsResourceApi(com.cloudera.api.swagger.CommandsResourceApi) List(java.util.List)

Example 9 with CommandsResourceApi

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

the class ClouderaManagerDecomissioner method abortDecommissionWithWarningMessage.

private void abortDecommissionWithWarningMessage(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 10 with CommandsResourceApi

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

the class ClouderaManagerCommandsService method getApiCommand.

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

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