Search in sources :

Example 1 with ApiCallback

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

the class ClouderaManagerModificationService method asyncTagHost.

private void asyncTagHost(String hostname, HostsResourceApi hostsResourceApi, InstanceGroup instanceGroup) {
    ApiEntityTag tag = new ApiEntityTag().name(HOST_TEMPLATE_NAME_TAG).value(instanceGroup.getGroupName());
    try {
        ApiCallback<List<ApiEntityTag>> callback = new ApiCallback<>() {

            @Override
            public void onFailure(ApiException e, int i, Map<String, List<String>> map) {
                LOGGER.error("Tagging failed for host [{}]: {}. Response headers: {}", hostname, e.getMessage(), map, e);
                throw new ClouderaManagerOperationFailedException("Host tagging failed for host: " + hostname, e);
            }

            @Override
            public void onSuccess(List<ApiEntityTag> apiEntityTags, int i, Map<String, List<String>> map) {
                LOGGER.debug("Tagging successful for host: [{}]. Body: {}, headers: {}", hostname, apiEntityTags, map);
            }

            @Override
            public void onUploadProgress(long l, long l1, boolean b) {
            }

            @Override
            public void onDownloadProgress(long l, long l1, boolean b) {
            }
        };
        LOGGER.debug("Tagging host [{}] with [{}]", hostname, tag);
        hostsResourceApi.addTagsAsync(hostname, List.of(tag), callback);
    } catch (ApiException e) {
        LOGGER.error("Error while tagging host: [{}]", hostname, e);
        throw new ClouderaManagerOperationFailedException(e.getMessage(), e);
    }
}
Also used : ApiCallback(com.cloudera.api.swagger.client.ApiCallback) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) ApiHostRefList(com.cloudera.api.swagger.model.ApiHostRefList) List(java.util.List) ApiEntityTag(com.cloudera.api.swagger.model.ApiEntityTag) Map(java.util.Map) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

ApiCallback (com.cloudera.api.swagger.client.ApiCallback)1 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiCommandList (com.cloudera.api.swagger.model.ApiCommandList)1 ApiEntityTag (com.cloudera.api.swagger.model.ApiEntityTag)1 ApiHostRefList (com.cloudera.api.swagger.model.ApiHostRefList)1 List (java.util.List)1 Map (java.util.Map)1