From cad743473f102bcd9ea94a770bddf06840f9546c Mon Sep 17 00:00:00 2001 From: Jenkins Date: Fri, 12 Feb 2016 17:07:34 -0800 Subject: [PATCH 01/11] [CLOUDERA-BUILD] Bump up version number to 5.7.0 --- java/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/pom.xml b/java/pom.xml index cf70e775..f6243fbf 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -5,7 +5,7 @@ com.cloudera.api cloudera-manager-api Cloudera Manager API - 5.7.0-SNAPSHOT + 5.7.0 2.7.5 From 2ea63bf46f302e4fa3871fc44419258962304b6f Mon Sep 17 00:00:00 2001 From: Vivek Chaudhary Date: Mon, 1 Feb 2016 15:07:57 -0800 Subject: [PATCH 02/11] [cm_api] OPSAPS-22366 Python API changes for cluster template import (cherry picked from commit d6c83987655a19846c09528be21c769029176c8a) (cherry picked from commit 4a47d5491e9ad682a8ee2769f262f014ebcd1cb5) --- python/setup.py | 2 +- python/src/cm_api/api_client.py | 2 +- python/src/cm_api/endpoints/clusters.py | 15 ++++ python/src/cm_api/endpoints/cms.py | 10 +++ python/src/cm_api/endpoints/types.py | 87 ++++++++++++++++++++++++ python/src/cm_api_tests/test_clusters.py | 12 +++- python/src/cm_api_tests/test_cms.py | 15 +++- 7 files changed, 139 insertions(+), 4 deletions(-) diff --git a/python/setup.py b/python/setup.py index 489dbf89..46a2da34 100644 --- a/python/setup.py +++ b/python/setup.py @@ -38,7 +38,7 @@ setup( name = 'cm_api', - version = '11.0.0', # Compatible with API v11 (CM 5.5) + version = '12.0.0', # Compatible with API v12 (CM 5.7) packages = find_packages('src', exclude=['cm_api_tests']), package_dir = {'cm_api': 'src/cm_api', 'cm_shell': 'src/cm_shell'}, diff --git a/python/src/cm_api/api_client.py b/python/src/cm_api/api_client.py index 2d4c94ee..fc8caa0b 100644 --- a/python/src/cm_api/api_client.py +++ b/python/src/cm_api/api_client.py @@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__) API_AUTH_REALM = "Cloudera Manager" -API_CURRENT_VERSION = 11 +API_CURRENT_VERSION = 12 class ApiException(RestException): """ diff --git a/python/src/cm_api/endpoints/clusters.py b/python/src/cm_api/endpoints/clusters.py index 6463a8a8..f267ce71 100644 --- a/python/src/cm_api/endpoints/clusters.py +++ b/python/src/cm_api/endpoints/clusters.py @@ -16,6 +16,7 @@ from cm_api.endpoints.types import * from cm_api.endpoints import services, parcels, host_templates +from sys import api_version __docformat__ = "epytext" @@ -605,3 +606,17 @@ def configure_for_kerberos(self, datanode_transceiver_port=None, if datanode_web_port: args['datanodeWebPort'] = datanode_web_port return self._cmd('configureForKerberos', data=args, api_version=11) + + def export(self, export_auto_config=False): + """ + Export the cluster template for the given cluster. ccluster must have host + templates defined. It cluster does not have host templates defined it will + export host templates based on roles assignment. + + @param export_auto_config: Also export auto configured configs + @return: Return cluster template + @since: API v12 + """ + + return self._get("export", ApiClusterTemplate, False, + params=dict(exportAutoConfig=export_auto_config), api_version=12) diff --git a/python/src/cm_api/endpoints/cms.py b/python/src/cm_api/endpoints/cms.py index 1d25bd43..f715ca87 100644 --- a/python/src/cm_api/endpoints/cms.py +++ b/python/src/cm_api/endpoints/cms.py @@ -482,3 +482,13 @@ def end_trial(self): @since: API v6 """ self._post("trial/end", None, api_version=6) + + def import_cluster_template(self, api_cluster_template): + """ + Create a cluster according to the provided template + + @param api_cluster_template: cluster template to import + @return: Command handing cluster import + @since: API v12 + """ + return self._post("importClusterTemplate", ApiCommand, False, api_cluster_template, api_version=12) diff --git a/python/src/cm_api/endpoints/types.py b/python/src/cm_api/endpoints/types.py index 8f6cac62..fd7d14fa 100644 --- a/python/src/cm_api/endpoints/types.py +++ b/python/src/cm_api/endpoints/types.py @@ -1140,6 +1140,93 @@ class ApiTimeSeriesRequest(BaseApiObject): def __str__(self): return ": %s" % (self.query) +class ApiProductVersion(BaseApiObject): + _ATTRIBUTES = { + 'version' : None, + 'product' : None, + } + +class ApiClusterTemplateConfig(BaseApiObject): + _ATTRIBUTES = { + 'name' : None, + 'value' : None, + 'ref' : None, + 'variable' : None, + 'autoConfig' : None, + } + +class ApiClusterTemplateRoleConfigGroup(BaseApiObject): + _ATTRIBUTES = { + 'refName' : None, + 'roleType' : None, + 'base' : None, + 'displayName' : None, + 'configs' : Attr(ApiClusterTemplateConfig), + } + +class ApiClusterTemplateRole(BaseApiObject): + _ATTRIBUTES = { + 'refName' : None, + 'roleType' : None, + } + +class ApiClusterTemplateHostTemplate(BaseApiObject): + _ATTRIBUTES = { + 'refName' : None, + 'roleConfigGroupsRefNames' : None, + } + +class ApiClusterTemplateHostInfo(BaseApiObject): + _ATTRIBUTES = { + 'hostName' : None, + 'hostNameRange' : None, + 'rackId' : None, + 'hostTemplateRefName' : None, + 'roleRefNames' : None, + } + +class ApiClusterTemplateVariable(BaseApiObject): + _ATTRIBUTES = { + 'name' : None, + 'value' : None, + } + +class ApiClusterTemplateRoleConfigGroupInfo(BaseApiObject): + _ATTRIBUTES = { + 'rcgRefName' : None, + 'name' : None, + } + +class ApiClusterTemplateInstantiator(BaseApiObject): + _ATTRIBUTES = { + 'clusterName' : None, + 'hosts' : Attr(ApiClusterTemplateHostInfo), + 'variables' : Attr(ApiClusterTemplateVariable), + 'roleConfigGroups' : Attr(ApiClusterTemplateRoleConfigGroupInfo), + } + +class ApiClusterTemplateService(BaseApiObject): + _ATTRIBUTES = { + 'refName' : None, + 'serviceType' : None, + 'serviceConfigs' : Attr(ApiClusterTemplateConfig), + 'roleConfigGroups' : Attr(ApiClusterTemplateRoleConfigGroup), + 'displayName' : None, + 'roles' : Attr(ApiClusterTemplateRole), + } + +class ApiClusterTemplate(BaseApiObject): + _ATTRIBUTES = { + 'cdhVersion' : None, + 'displayName' : None, + 'cmVersion' : None, + "repositories" : None, + 'products' : Attr(ApiProductVersion), + 'services' : Attr(ApiClusterTemplateService), + 'hostTemplates' : Attr(ApiClusterTemplateHostTemplate), + 'instantiator' : Attr(ApiClusterTemplateInstantiator), + } + def config_to_api_list(dic): """ Converts a python dictionary into a list containing the proper diff --git a/python/src/cm_api_tests/test_clusters.py b/python/src/cm_api_tests/test_clusters.py index 4998d645..57fb52aa 100644 --- a/python/src/cm_api_tests/test_clusters.py +++ b/python/src/cm_api_tests/test_clusters.py @@ -42,7 +42,7 @@ def test_update_cdh_version(self): data=data, retdata={ 'name' : 'foo'}) cluster.update_cdh_version('4.2.1') - + def test_upgrade_cdh(self): resource = utils.MockResource(self) cluster = ApiCluster(resource, name="foo") @@ -104,3 +104,13 @@ def test_configure_for_kerberos(self): data=data, retdata={ 'name' : 'foo'}) cluster.configure_for_kerberos(23456, 12345) + + def test_export_cluster_template(self): + resource = utils.MockResource(self) + cluster = ApiCluster(resource, name="foo") + resource.expect( + method="GET", + reqpath="/clusters/foo/export", + params=dict(exportAutoConfig=True), + retdata=ApiClusterTemplate(resource).to_json_dict()) + cluster.export(export_auto_config=True) diff --git a/python/src/cm_api_tests/test_cms.py b/python/src/cm_api_tests/test_cms.py index 2d14da26..1f6b36eb 100644 --- a/python/src/cm_api_tests/test_cms.py +++ b/python/src/cm_api_tests/test_cms.py @@ -16,7 +16,8 @@ import unittest from cm_api.endpoints.cms import ClouderaManager -from cm_api.endpoints.types import config_to_json, ApiConfig, ApiCmPeer +from cm_api.endpoints.types import config_to_json, ApiConfig, ApiCmPeer,\ + ApiCommand, ApiClusterTemplate from cm_api_tests import utils try: @@ -278,3 +279,15 @@ def test_peer_v11(self): params=params_status_aggregation, retdata=json.loads(SAMPLE_COMMAND_JSON)) cms.test_peer_connectivity("peer2", peer_type="STATUS_AGGREGATION") + + def test_import_cluster_v12(self): + resource = utils.MockResource(self, version=12) + cms = ClouderaManager(resource) + data = ApiClusterTemplate(resource).to_json_dict() + resource.expect( + method="POST", + reqpath="/cm/importClusterTemplate", + data = data, + retdata=ApiCommand(resource).to_json_dict()) + cms.import_cluster_template(data) + From cd1204be0295e7d69c1e88c0b328bd88365ea2e5 Mon Sep 17 00:00:00 2001 From: Jayesh Seshadri Date: Fri, 19 Feb 2016 11:27:45 -0800 Subject: [PATCH 03/11] OPSAPS-31990 Add dfsServices to the python API Added list_dfs_services to endpoints/cluster.py's ApiCluster, to match API addition in OPSAPS-31495. Testing: - new unit test - verified with manual test against CM via a simple test script: --- from cm_api.api_client import ApiResource api=ApiResource("nightly-1.vpc.cloudera.com", username="foo", password="bar") cluster=api.get_cluster("Cluster 1") apiList=cluster.list_dfs_services(view="export") print ("%s" %(apiList)) --- (cherry picked from commit adef14dab858094d72173e2e5c1afee2ef81ebed) (cherry picked from commit e40c6259f119cc9067db9d03b092ad0e72ac5f14) --- python/src/cm_api/endpoints/clusters.py | 12 ++++++++++++ python/src/cm_api_tests/test_clusters.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/python/src/cm_api/endpoints/clusters.py b/python/src/cm_api/endpoints/clusters.py index f267ce71..3f926f9f 100644 --- a/python/src/cm_api/endpoints/clusters.py +++ b/python/src/cm_api/endpoints/clusters.py @@ -620,3 +620,15 @@ def export(self, export_auto_config=False): return self._get("export", ApiClusterTemplate, False, params=dict(exportAutoConfig=export_auto_config), api_version=12) + + def list_dfs_services(self, view=None): + """ + List available DFS (distributed file system) services in a cluster. + @param view: View to materialize + @return: List of available distributed file system services in the cluster. + @since: API v12 + """ + if view: + return self._get_resource_root().get("%s/%s?view=%s" % (self._path(), 'dfsServices', view)) + else: + return self._get_resource_root().get("%s/%s" % (self._path(), 'dfsServices')) diff --git a/python/src/cm_api_tests/test_clusters.py b/python/src/cm_api_tests/test_clusters.py index 57fb52aa..096df0f9 100644 --- a/python/src/cm_api_tests/test_clusters.py +++ b/python/src/cm_api_tests/test_clusters.py @@ -114,3 +114,18 @@ def test_export_cluster_template(self): params=dict(exportAutoConfig=True), retdata=ApiClusterTemplate(resource).to_json_dict()) cluster.export(export_auto_config=True) + + def test_list_dfs_services(self): + resource = utils.MockResource(self) + cluster = ApiCluster(resource, name="foo") + data = None + resource.expect("GET", "/clusters/foo/dfsServices", + data=data, + retdata={ 'name' : 'foo'}) + cluster.list_dfs_services() + + data = None + resource.expect("GET", "/clusters/foo/dfsServices?view=EXPORT", + data=data, + retdata={ 'name' : 'foo'}) + cluster.list_dfs_services(view="EXPORT") From b5b56c6683c96f8403ae937eb40a187a536c3f21 Mon Sep 17 00:00:00 2001 From: Vivek Chaudhary Date: Tue, 23 Feb 2016 17:25:21 -0800 Subject: [PATCH 04/11] [scm] OPSAPS-31656 ClusterTemplates: Cardinality needs to be described in the exported template Added cardinality attribute to host template in cluster template (cherry picked from commit 0c8595db3519e94c9a78acaebe176007ccbd3e83) (cherry picked from commit 5fd588f77b0300c2bc25e6ebf508f66e338d1f22) --- python/src/cm_api/endpoints/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/src/cm_api/endpoints/types.py b/python/src/cm_api/endpoints/types.py index fd7d14fa..17c34602 100644 --- a/python/src/cm_api/endpoints/types.py +++ b/python/src/cm_api/endpoints/types.py @@ -1173,6 +1173,7 @@ class ApiClusterTemplateRole(BaseApiObject): class ApiClusterTemplateHostTemplate(BaseApiObject): _ATTRIBUTES = { 'refName' : None, + 'cardinality' : None, 'roleConfigGroupsRefNames' : None, } From 70c171665e2cd7604fe0497ab5fea854c9b7c19c Mon Sep 17 00:00:00 2001 From: Vikram Srivastava Date: Tue, 8 Mar 2016 14:18:20 -0800 Subject: [PATCH 05/11] [yamon] OPSAPS-32606 Add the new fields for YARN apps (cherry picked from commit e6bc8282f7092a260541730ce27da45bcefcf5a0) (cherry picked from commit 44c479034092ff51c6f206f4101a156b086f7757) --- python/src/cm_api/endpoints/types.py | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/python/src/cm_api/endpoints/types.py b/python/src/cm_api/endpoints/types.py index 17c34602..f71ac13f 100644 --- a/python/src/cm_api/endpoints/types.py +++ b/python/src/cm_api/endpoints/types.py @@ -1084,16 +1084,27 @@ def __str__(self): class ApiYarnApplication(BaseApiObject): _ATTRIBUTES = { - 'applicationId' : ROAttr(), - 'name' : ROAttr(), - 'user' : ROAttr(), - 'startTime' : ROAttr(datetime.datetime), - 'endTime' : ROAttr(datetime.datetime), - 'pool' : ROAttr(), - 'state' : ROAttr(), - 'progress' : ROAttr(), - 'mr2AppInformation' : ROAttr(ApiMr2AppInformation), - 'attributes' : ROAttr(), + 'applicationId' : ROAttr(), + 'name' : ROAttr(), + 'user' : ROAttr(), + 'startTime' : ROAttr(datetime.datetime), + 'endTime' : ROAttr(datetime.datetime), + 'pool' : ROAttr(), + 'state' : ROAttr(), + 'progress' : ROAttr(), + 'mr2AppInformation' : ROAttr(ApiMr2AppInformation), + 'attributes' : ROAttr(), + 'allocatedMB' : ROAttr(), + 'allocatedVCores' : ROAttr(), + 'runningContainers' : ROAttr(), + 'applicationTags' : ROAttr(), + 'allocatedMemorySeconds' : ROAttr(), + 'allocatedVcoreSeconds' : ROAttr(), + 'containerUsedMemorySeconds' : ROAttr(), + 'containerUsedCpuSeconds' : ROAttr(), + 'containerUsedVcoreSeconds' : ROAttr(), + 'containerAllocatedMemorySeconds' : ROAttr(), + 'containerAllocatedVcoreSeconds' : ROAttr(), } def __str__(self): From 1ff5863683480099bb5ae0eec1ee8eb7284d4431 Mon Sep 17 00:00:00 2001 From: Vivek Chaudhary Date: Wed, 9 Mar 2016 14:51:47 -0800 Subject: [PATCH 06/11] [scm] OPSAPS-32644 addRepositories argument is not present in python API - Fixed the api (cherry picked from commit 2151df03593d14038345a423da8fd4120f82f236) (cherry picked from commit 47531a5d9c4670aac1c8089d4c76774ec5c5e73a) --- python/src/cm_api/endpoints/cms.py | 5 +++-- python/src/cm_api_tests/test_cms.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/src/cm_api/endpoints/cms.py b/python/src/cm_api/endpoints/cms.py index f715ca87..870145f1 100644 --- a/python/src/cm_api/endpoints/cms.py +++ b/python/src/cm_api/endpoints/cms.py @@ -483,12 +483,13 @@ def end_trial(self): """ self._post("trial/end", None, api_version=6) - def import_cluster_template(self, api_cluster_template): + def import_cluster_template(self, api_cluster_template, add_repositories=False): """ Create a cluster according to the provided template @param api_cluster_template: cluster template to import + @param add_repositories: if true the parcels repositories in the cluster template will be added. @return: Command handing cluster import @since: API v12 """ - return self._post("importClusterTemplate", ApiCommand, False, api_cluster_template, api_version=12) + return self._post("importClusterTemplate", ApiCommand, False, api_cluster_template, params=dict(addRepositories=add_repositories), api_version=12) diff --git a/python/src/cm_api_tests/test_cms.py b/python/src/cm_api_tests/test_cms.py index 1f6b36eb..4240dd79 100644 --- a/python/src/cm_api_tests/test_cms.py +++ b/python/src/cm_api_tests/test_cms.py @@ -287,7 +287,8 @@ def test_import_cluster_v12(self): resource.expect( method="POST", reqpath="/cm/importClusterTemplate", + params=dict(addRepositories=True), data = data, retdata=ApiCommand(resource).to_json_dict()) - cms.import_cluster_template(data) + cms.import_cluster_template(data, True) From 71146baa170bd609ab914fd18a31be6b98767a12 Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Thu, 10 Mar 2016 11:25:40 -0800 Subject: [PATCH 07/11] [api] OPSAPS-32658. Add pools refresh endpoint Nothing special. It's been MIA for a while. >>> from cm_api.api_client import ApiResource >>> api=ApiResource("nightly-1.gce.cloudera.com", username="admin", password="admin") >>> cluster=api.get_cluster("Cluster 1") >>> cmd = cluster.pools_refresh() (cherry picked from commit c38553988a42a25732d5cf499a044194072ee1d1) (cherry picked from commit 3b6cb12bb0ff730d14bf847d3b4c2f96a4c39d17) --- python/src/cm_api/endpoints/clusters.py | 9 +++++++++ python/src/cm_api_tests/test_clusters.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/python/src/cm_api/endpoints/clusters.py b/python/src/cm_api/endpoints/clusters.py index 3f926f9f..d802086b 100644 --- a/python/src/cm_api/endpoints/clusters.py +++ b/python/src/cm_api/endpoints/clusters.py @@ -621,6 +621,15 @@ def export(self, export_auto_config=False): return self._get("export", ApiClusterTemplate, False, params=dict(exportAutoConfig=export_auto_config), api_version=12) + def pools_refresh(self): + """ + Refresh Dynamic Pools configurations for relevant services.. + + @return: Reference to the submitted command. + @since: API v12 + """ + return self._cmd('poolsRefresh') + def list_dfs_services(self, view=None): """ List available DFS (distributed file system) services in a cluster. diff --git a/python/src/cm_api_tests/test_clusters.py b/python/src/cm_api_tests/test_clusters.py index 096df0f9..164660ac 100644 --- a/python/src/cm_api_tests/test_clusters.py +++ b/python/src/cm_api_tests/test_clusters.py @@ -115,6 +115,15 @@ def test_export_cluster_template(self): retdata=ApiClusterTemplate(resource).to_json_dict()) cluster.export(export_auto_config=True) + def test_pools_refresh(self): + resource = utils.MockResource(self) + cluster = ApiCluster(resource, name="foo") + + resource.expect("POST", "/clusters/foo/commands/poolsRefresh", + data=None, + retdata={ 'name' : 'foo'}) + cluster.pools_refresh() + def test_list_dfs_services(self): resource = utils.MockResource(self) cluster = ApiCluster(resource, name="foo") From 13dc99663f1583c4ab439fc37fe4879d41a8b07e Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Thu, 10 Mar 2016 12:24:19 -0800 Subject: [PATCH 08/11] [api] OPSAPS-32658. Support pools refresh starting v6 Since it's actually been around for a while. (cherry picked from commit ff09be867c01827d465eb8e8b3075245493aac90) (cherry picked from commit 8846594073fe12823afb3ef17757dd8cc823debd) --- python/src/cm_api/endpoints/clusters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/src/cm_api/endpoints/clusters.py b/python/src/cm_api/endpoints/clusters.py index d802086b..9f0b578c 100644 --- a/python/src/cm_api/endpoints/clusters.py +++ b/python/src/cm_api/endpoints/clusters.py @@ -626,9 +626,9 @@ def pools_refresh(self): Refresh Dynamic Pools configurations for relevant services.. @return: Reference to the submitted command. - @since: API v12 + @since: API v6 """ - return self._cmd('poolsRefresh') + return self._cmd('poolsRefresh', api_version=6) def list_dfs_services(self, view=None): """ From 1591b8216ab28bbe2063a2056bdb990c92eec12a Mon Sep 17 00:00:00 2001 From: mthakkar Date: Fri, 6 May 2016 17:54:25 -0700 Subject: [PATCH 09/11] [java] Updated with v12 java source --- java/api-docs.fmt | 207 +++++++++++++---- java/enunciate.xml | 6 +- java/pom.xml | 36 ++- .../com/cloudera/api/ApiRootResource.java | 17 +- .../main/java/com/cloudera/api/ApiUtils.java | 11 + .../api/ClouderaManagerClientBuilder.java | 85 ++++++- .../main/java/com/cloudera/api/DataView.java | 6 + .../java/com/cloudera/api/Parameters.java | 3 + .../com/cloudera/api/model/ApiCluster.java | 35 ++- .../api/model/ApiClusterTemplate.java | 137 ++++++++++++ .../api/model/ApiClusterTemplateConfig.java | 96 ++++++++ .../api/model/ApiClusterTemplateHostInfo.java | 95 ++++++++ .../model/ApiClusterTemplateHostTemplate.java | 70 ++++++ .../model/ApiClusterTemplateInstantiator.java | 86 +++++++ .../api/model/ApiClusterTemplateRole.java | 54 +++++ .../ApiClusterTemplateRoleConfigGroup.java | 93 ++++++++ ...ApiClusterTemplateRoleConfigGroupInfo.java | 51 +++++ .../api/model/ApiClusterTemplateService.java | 104 +++++++++ .../api/model/ApiClusterTemplateVariable.java | 52 +++++ .../com/cloudera/api/model/ApiCmPeer.java | 107 ++++++++- .../com/cloudera/api/model/ApiCmPeerType.java | 24 ++ .../com/cloudera/api/model/ApiCommand.java | 27 ++- .../com/cloudera/api/model/ApiConfig.java | 46 +++- .../ApiConfigureForKerberosArguments.java | 78 +++++++ .../cloudera/api/model/ApiEntityStatus.java | 53 +++++ .../model/ApiHdfsReplicationArguments.java | 31 ++- .../api/model/ApiHdfsReplicationResult.java | 36 ++- .../cloudera/api/model/ApiHealthCheck.java | 42 ++++ .../api/model/ApiHiveReplicationResult.java | 21 +- .../java/com/cloudera/api/model/ApiHost.java | 32 +++ .../api/model/ApiHostInstallArguments.java | 8 +- .../api/model/ApiMrUsageReportRow.java | 210 +++++++++++++++++- .../cloudera/api/model/ApiProductVersion.java | 53 +++++ ...iReplicationDiagnosticsCollectionArgs.java | 88 ++++++++ .../api/model/ApiReplicationSchedule.java | 14 ++ .../ApiReplicationScheduleDataLimits.java | 56 +++++ .../api/model/ApiRestartClusterArgs.java | 28 ++- .../java/com/cloudera/api/model/ApiRole.java | 15 ++ .../com/cloudera/api/model/ApiService.java | 34 ++- .../cloudera/api/model/ApiSnapshotPolicy.java | 18 +- .../ApiTimeSeriesCrossEntityMetadata.java | 32 +++ .../model/ApiTimeSeriesEntityAttribute.java | 97 ++++++++ .../ApiTimeSeriesEntityAttributeList.java | 46 ++++ .../api/model/ApiTimeSeriesEntityType.java | 184 +++++++++++++++ .../model/ApiTimeSeriesEntityTypeList.java | 44 ++++ .../api/model/ApiTimeSeriesRequest.java | 188 ++++++++++++++++ .../java/com/cloudera/api/model/ApiUser.java | 1 + .../cloudera/api/model/ApiUserSession.java | 112 ++++++++++ .../api/model/ApiUserSessionList.java | 45 ++++ .../api/model/ApiYarnApplication.java | 205 ++++++++++++++++- .../cloudera/api/v1/MgmtServiceResource.java | 8 + .../cloudera/api/v10/AuditsResourceV10.java | 7 +- .../api/v11/ClouderaManagerResourceV11.java | 35 +++ .../cloudera/api/v11/ClustersResourceV11.java | 60 +++++ .../cloudera/api/v11/CmPeersResourceV11.java | 91 ++++++++ .../cloudera/api/v11/CommandsResourceV11.java | 38 ++++ .../cloudera/api/v11/HostsResourceV11.java | 52 +++++ .../api/v11/NameservicesResourceV11.java | 51 +++++ .../api/v11/ReplicationsResourceV11.java | 78 +++++++ .../cloudera/api/v11/RolesResourceV11.java | 63 ++++++ .../com/cloudera/api/v11/RootResourceV11.java | 46 ++++ .../cloudera/api/v11/ServicesResourceV11.java | 66 ++++++ .../api/v11/TimeSeriesResourceV11.java | 67 ++++++ .../cloudera/api/v11/UsersResourceV11.java | 42 ++++ .../com/cloudera/api/v11/package-info.java | 21 ++ .../api/v12/ClouderaManagerResourceV12.java | 34 +++ .../cloudera/api/v12/ClustersResourceV12.java | 69 ++++++ .../com/cloudera/api/v12/RootResourceV12.java | 33 +++ .../com/cloudera/api/v12/package-info.java | 21 ++ .../api/v2/ClouderaManagerResourceV2.java | 2 +- .../com/cloudera/api/v3/CmPeersResource.java | 6 + .../com/cloudera/api/v4/AuditsResource.java | 10 +- .../api/v4/ImpalaQueriesResource.java | 6 +- .../cloudera/api/v4/ServicesResourceV4.java | 12 +- .../cloudera/api/v4/TimeSeriesResource.java | 7 +- .../cloudera/api/v6/DashboardsResource.java | 4 +- .../cloudera/api/v6/ServicesResourceV6.java | 24 +- .../cloudera/api/v6/TimeSeriesResourceV6.java | 14 +- .../api/v6/YarnApplicationsResource.java | 7 +- .../com/cloudera/api/v8/AuditsResourceV8.java | 11 +- .../api/ClouderaManagerClientBuilderTest.java | 67 ++++++ .../com/cloudera/api/model/ApiModelTest.java | 45 +++- 82 files changed, 4141 insertions(+), 175 deletions(-) create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplate.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateConfig.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostInfo.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostTemplate.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateInstantiator.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRole.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroup.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroupInfo.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateService.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiClusterTemplateVariable.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiCmPeerType.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiConfigureForKerberosArguments.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiEntityStatus.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiProductVersion.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiReplicationDiagnosticsCollectionArgs.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiReplicationScheduleDataLimits.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttribute.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttributeList.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityType.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityTypeList.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiTimeSeriesRequest.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiUserSession.java create mode 100644 java/src/main/java/com/cloudera/api/model/ApiUserSessionList.java create mode 100644 java/src/main/java/com/cloudera/api/v11/ClouderaManagerResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/ClustersResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/CmPeersResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/HostsResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/NameservicesResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/ReplicationsResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/RolesResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/RootResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/ServicesResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/TimeSeriesResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/UsersResourceV11.java create mode 100644 java/src/main/java/com/cloudera/api/v11/package-info.java create mode 100644 java/src/main/java/com/cloudera/api/v12/ClouderaManagerResourceV12.java create mode 100644 java/src/main/java/com/cloudera/api/v12/ClustersResourceV12.java create mode 100644 java/src/main/java/com/cloudera/api/v12/RootResourceV12.java create mode 100644 java/src/main/java/com/cloudera/api/v12/package-info.java diff --git a/java/api-docs.fmt b/java/api-docs.fmt index 6c49f15a..188eb6e9 100644 --- a/java/api-docs.fmt +++ b/java/api-docs.fmt @@ -1064,10 +1064,10 @@ A service is an abstract entity providing a capability in a cluster. Examples of services are HDFS, MapReduce, YARN, and HBase. A service is usually distributed, and contains a set of roles that physically - run on the cluster. A service has its own configuration, status, - metrics, and roles. You may issue commands against a service, or - against a set of roles in bulk. Additionally, an HDFS service has - nameservices, and a MapReduce service has activities. + run on the cluster. A service has its own configuration, status and + roles. You may issue commands against a service, or against a set + of roles in bulk. Additionally, an HDFS service has nameservices, + and a MapReduce service has activities.

All services belong to a cluster (except for the Cloudera Management Service), and is uniquely identified by its name within a Cloudera @@ -1083,8 +1083,8 @@ processes.) Once created, a role cannot be reassigned to a different host. You need to delete and re-create it.

- A role has its own configuration, status and metrics. API commands on - roles are always issued in bulk at the service level. + A role has its own configuration and status. API commands on roles + are always issued in bulk at the service level.

Role Type
@@ -1119,6 +1119,18 @@ The operation of this service is similar to other Hadoop services, except that the Management Service does not belong to a cluster.
+
Metrics
+
+

+ A metric is a property that can be measured to quantify the state of an + entity or activity, such as the number of open file descriptors or CPU + utilization percentage. Full list of metric schema is available through + Cloudera Manager API /timeseries/schema endpoint. +

+ Cloudera Manager enables retrieving of metric data using a launguage + called tsquery. Please see tsquery documentation for more details on + how to write a tsquery. +

Debugging the API

@@ -1504,56 +1516,157 @@ } } -

Metrics

+

Querying metric data

-

In the Enterprise Edition, you can get metrics related to hosts, - services, roles and activities. The call by default fetches data points from - the last 5 minutes. +

+ Getting dfs capacity metric data for service HDFS-1. $ curl -u admin:admin \ - 'http://localhost:7180/api/v1/clusters/Cluster%201%20-%20CDH4/services/hdfs1/metrics?metrics=dfs_capacity_used_non_hdfs&metrics=dfs_capacity' + 'http://localhost:7180/api/v11/timeseries?query=select%20dfs_capacity,%20dfs_capacity_used,%20dfs_capacity_used_non_hdfs%20where%20entityName=HDFS-1' { "items" : [ { - "name" : "dfs_capacity_used_non_hdfs", - "context" : "hdfs1:nameservice1", - "data" : [ { - "value" : 0.0, - "timestamp" : "2012-05-06T10:25:46.000Z" - }, { - "value" : 0.0, - "timestamp" : "2012-05-06T10:26:46.000Z" - }, { - "value" : 0.0, - "timestamp" : "2012-05-06T10:27:46.000Z" - }, { - "value" : 0.0, - "timestamp" : "2012-05-06T10:28:46.000Z" - }, { - "value" : 0.0, - "timestamp" : "2012-05-06T10:29:46.000Z" - } ], - "unit" : "bytes" - }, { - "name" : "dfs_capacity", - "context" : "hdfs1:nameservice1", - "data" : [ { - "value" : 3.2103841792E10, - "timestamp" : "2012-05-06T10:25:46.000Z" - }, { - "value" : 3.2103841792E10, - "timestamp" : "2012-05-06T10:26:46.000Z" - }, { - "value" : 3.2103841792E10, - "timestamp" : "2012-05-06T10:27:46.000Z" + "timeSeries": [ { + "metadata": { + "metricName": "dfs_capacity", + "entityName": "HDFS-1", + "startTime": "2015-09-17T23:42:22.533Z", + "endTime": "2015-09-17T23:47:22.533Z", + "attributes": { + "clusterName": "Cluster 1", + "category": "SERVICE", + "clusterDisplayName": "Cluster 1", + "active": "true", + "serviceType": "HDFS", + "serviceDisplayName": "HDFS-1", + "version": "CDH 5.7.0", + "serviceName": "HDFS-1", + "entityName": "HDFS-1" + }, + "unitNumerators": [ + "bytes" + ], + "unitDenominators": [], + "expression": "SELECT dfs_capacity WHERE entityName = \"HDFS-1\" AND category = SERVICE", + "metricCollectionFrequencyMs": 60000, + "rollupUsed": "RAW" + }, + "data": [ { + "timestamp": "2015-09-17T23:43:10.599Z", + "value": 86909397813, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:44:10.605Z", + "value": 86909397813, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:45:10.608Z", + "value": 86909397813, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:46:10.615Z", + "value": 86909397813, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:47:15.613Z", + "value": 86909397813, + "type": "SAMPLE" + } ] }, { - "value" : 3.2103841792E10, - "timestamp" : "2012-05-06T10:28:46.000Z" + "metadata": { + "metricName": "dfs_capacity_used", + "entityName": "HDFS-1", + "startTime": "2015-09-17T23:42:22.533Z", + "endTime": "2015-09-17T23:47:22.533Z", + "attributes": { + "clusterName": "Cluster 1", + "category": "SERVICE", + "clusterDisplayName": "Cluster 1", + "active": "true", + "serviceType": "HDFS", + "serviceDisplayName": "HDFS-1", + "version": "CDH 5.7.0", + "serviceName": "HDFS-1", + "entityName": "HDFS-1" + }, + "unitNumerators": [ + "bytes" + ], + "unitDenominators": [], + "expression": "SELECT dfs_capacity_used WHERE entityName = \"HDFS-1\" AND category = SERVICE", + "metricCollectionFrequencyMs": 60000, + "rollupUsed": "RAW" + }, + "data": [ { + "timestamp": "2015-09-17T23:43:10.599Z", + "value": 1728884736, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:44:10.605Z", + "value": 1728884736, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:45:10.608Z", + "value": 1728884736, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:46:10.615Z", + "value": 1728884736, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:47:15.613Z", + "value": 1728884736, + "type": "SAMPLE" + } ] }, { - "value" : 3.2103841792E10, - "timestamp" : "2012-05-06T10:29:46.000Z" + "metadata": { + "metricName": "dfs_capacity_used_non_hdfs", + "entityName": "HDFS-1", + "startTime": "2015-09-17T23:42:22.533Z", + "endTime": "2015-09-17T23:47:22.533Z", + "attributes": { + "clusterName": "Cluster 1", + "category": "SERVICE", + "clusterDisplayName": "Cluster 1", + "active": "true", + "serviceType": "HDFS", + "serviceDisplayName": "HDFS-1", + "version": "CDH 5.7.0", + "serviceName": "HDFS-1", + "entityName": "HDFS-1" + }, + "unitNumerators": [ + "bytes" + ], + "unitDenominators": [], + "expression": "SELECT dfs_capacity_used_non_hdfs WHERE entityName = \"HDFS-1\" AND category = SERVICE", + "metricCollectionFrequencyMs": 60000, + "rollupUsed": "RAW" + }, + "data": [ { + "timestamp": "2015-09-17T23:43:10.599Z", + "value": 1610609973, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:44:10.605Z", + "value": 1610609973, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:45:10.608Z", + "value": 1610609973, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:46:10.615Z", + "value": 1610609973, + "type": "SAMPLE" + }, { + "timestamp": "2015-09-17T23:47:15.613Z", + "value": 1610609973, + "type": "SAMPLE" + } ] } ], - "unit" : "bytes" + "warnings": [], + "timeSeriesQuery": "select dfs_capacity, dfs_capacity_used, dfs_capacity_used_non_hdfs where entityName=HDFS-1" } ] [/@boilerplate] diff --git a/java/enunciate.xml b/java/enunciate.xml index b8f56f4e..42eb3a95 100644 --- a/java/enunciate.xml +++ b/java/enunciate.xml @@ -2,18 +2,18 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd"> - + - + 5.7.0 - 2.7.5 + 2.7.7 14.0 2.1.0 2.1 @@ -21,7 +21,7 @@ cdh.releases.repo - http://maven.jenkins.cloudera.com:8081/artifactory/libs-release-local + http://maven.jenkins.cloudera.com:8081/artifactory/cdh-staging-local CDH Releases Repository @@ -114,6 +114,36 @@ + + + clover + + 4.0.3 + true + true + + + + com.atlassian.clover + clover + ${clover.version} + + + + + + + com.atlassian.maven.plugins + maven-clover2-plugin + ${clover.version} + + ${clover.generateHtml} + ${clover.generateXml} + + + + + @@ -153,7 +183,7 @@ com. ${privateClassPath}.com. - com.google.guava.** + com.google.common.** com.fasterxml.jackson.** diff --git a/java/src/main/java/com/cloudera/api/ApiRootResource.java b/java/src/main/java/com/cloudera/api/ApiRootResource.java index f3029e20..912efea3 100644 --- a/java/src/main/java/com/cloudera/api/ApiRootResource.java +++ b/java/src/main/java/com/cloudera/api/ApiRootResource.java @@ -16,6 +16,9 @@ package com.cloudera.api; import com.cloudera.api.v1.RootResourceV1; +import com.cloudera.api.v10.RootResourceV10; +import com.cloudera.api.v11.RootResourceV11; +import com.cloudera.api.v12.RootResourceV12; import com.cloudera.api.v2.RootResourceV2; import com.cloudera.api.v3.RootResourceV3; import com.cloudera.api.v4.RootResourceV4; @@ -24,7 +27,7 @@ import com.cloudera.api.v7.RootResourceV7; import com.cloudera.api.v8.RootResourceV8; import com.cloudera.api.v9.RootResourceV9; -import com.cloudera.api.v10.RootResourceV10; +import com.cloudera.api.v12.RootResourceV12; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -101,6 +104,18 @@ public interface ApiRootResource { @Path("/v10") RootResourceV10 getRootV10(); + /** + * @return The v11 root resource. + */ + @Path("/v11") + RootResourceV11 getRootV11(); + + /** + * @return The v12 root resource. + */ + @Path("/v12") + RootResourceV12 getRootV12(); + /** * Fetch the current API version supported by the server. *

diff --git a/java/src/main/java/com/cloudera/api/ApiUtils.java b/java/src/main/java/com/cloudera/api/ApiUtils.java index 1a4909ca..1e59ab9a 100644 --- a/java/src/main/java/com/cloudera/api/ApiUtils.java +++ b/java/src/main/java/com/cloudera/api/ApiUtils.java @@ -135,6 +135,17 @@ public static void checkOffsetAndLimit(int offset, int limit) { "Limit should be greater than 0."); } + + /** + * Check that the given limit is positive. + * + * @param limit Value to use as limit of a list's size. + */ + public static void checkLimit(int limit) { + Preconditions.checkArgument(limit > 0, + "Limit should be greater than 0."); + } + private ApiUtils() { } } diff --git a/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java b/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java index 1b6721d8..f071bc4b 100644 --- a/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java +++ b/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java @@ -35,13 +35,16 @@ import org.apache.cxf.configuration.jsse.TLSClientParameters; import org.apache.cxf.feature.AbstractFeature; import org.apache.cxf.feature.LoggingFeature; +import org.apache.cxf.jaxrs.client.Client; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.message.Message; import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; public class ClouderaManagerClientBuilder { + public static final int DEFAULT_TCP_PORT = 7180; public static final long DEFAULT_CONNECTION_TIMEOUT = 0; public static final TimeUnit DEFAULT_CONNECTION_TIMEOUT_UNITS = @@ -53,8 +56,8 @@ public class ClouderaManagerClientBuilder { private URL baseUrl; private String hostname; private int port = DEFAULT_TCP_PORT; - private boolean enableTLS = false; - private boolean enableLogging = false; + private boolean enableTLS; + private boolean enableLogging; private String username; private String password; private long connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; @@ -63,7 +66,11 @@ public class ClouderaManagerClientBuilder { private TimeUnit receiveTimeoutUnits = DEFAULT_RECEIVE_TIMEOUT_UNITS; private boolean validateCerts = true; private boolean validateCn = true; - private TrustManager[] trustManagers = null; + private boolean threadSafe; + private boolean maintainSessionAcrossRequests; + private boolean streamAutoClosure; + private TrustManager[] trustManagers; + private String acceptLanguage; /** * Cache JAXRSClientFactoryBean per proxyType. @@ -97,6 +104,12 @@ public JAXRSClientFactoryBean load(Class proxyType) throws Exception { } }); + public ClouderaManagerClientBuilder withAcceptLanguage( + String acceptLaunguage) { + this.acceptLanguage = acceptLaunguage; + return this; + } + public ClouderaManagerClientBuilder withBaseURL(URL baseUrl) { this.baseUrl = baseUrl; return this; @@ -122,6 +135,28 @@ public ClouderaManagerClientBuilder enableLogging() { return this; } + /** + * @param threadSafe Set if to create a thread safe client. + * @return + */ + public ClouderaManagerClientBuilder setThreadSafe(boolean threadSafe) { + this.threadSafe = threadSafe; + return this; + } + + /** + * @param maintainSessionAcrossRequests If set to true, created client will + * maintain HTTP session across multiple requests. Setting this to true also + * means that login attempt will be made for the 1st request for a new client + * or when the previous session has time out. + * @return + */ + public ClouderaManagerClientBuilder setMaintainSessionAcrossRequests( + boolean maintainSessionAcrossRequests) { + this.maintainSessionAcrossRequests = maintainSessionAcrossRequests; + return this; + } + public ClouderaManagerClientBuilder withUsernamePassword(String username, String password) { this.username = username; @@ -155,6 +190,18 @@ public ClouderaManagerClientBuilder disableTlsCnValidation() { return this; } + /** + * By default, ClouderaManagerClientBuilder disables auto-closure of response + * streams when generated client are making requests. This method enables + * this. If this is not enabled, caller of the client is responsible for + * closing the response streams. + * @return ClouderaManagerClientBuilder + */ + public ClouderaManagerClientBuilder enableStreamAutoClosure() { + this.streamAutoClosure = true; + return this; + } + @VisibleForTesting String generateAddress() { final String apiRootPath = "api/"; @@ -220,11 +267,21 @@ protected T build(Class proxyType) { if (enableLogging) { bean.setFeatures(Arrays.asList(new LoggingFeature())); } + bean.setThreadSafe(threadSafe); rootResource = bean.create(proxyType); } boolean isTlsEnabled = address.startsWith("https://"); ClientConfiguration config = WebClient.getConfig(rootResource); + if (maintainSessionAcrossRequests) { + config.getRequestContext().put(Message.MAINTAIN_SESSION, + Boolean.TRUE); + } + if (streamAutoClosure) { + config.getRequestContext().put("response.stream.auto.close", + Boolean.TRUE); + } + HTTPConduit conduit = (HTTPConduit) config.getConduit(); if (isTlsEnabled) { TLSClientParameters tlsParams = new TLSClientParameters(); @@ -239,6 +296,9 @@ else if (trustManagers != null) { } HTTPClientPolicy policy = conduit.getClient(); + if (acceptLanguage != null) { + policy.setAcceptLanguage(acceptLanguage); + } policy.setConnectionTimeout( connectionTimeoutUnits.toMillis(connectionTimeout)); policy.setReceiveTimeout( @@ -249,26 +309,24 @@ else if (trustManagers != null) { private static JAXRSClientFactoryBean cleanFactory(JAXRSClientFactoryBean bean) { bean.setUsername(null); bean.setPassword(null); + bean.setInitialState(null); bean.setFeatures(Arrays.asList()); return bean; } /** - * Closes the transport level conduit in the client. Reopening a new - * connection, requires creating a new client object using the build() - * method in this builder. + * Releases the internal state and configuration associated with this client. + * Reopening a new connection requires creating a new client object using the + * build() method in this builder. * * @param root The resource returned by the build() method of this * builder class */ public static void closeClient(ApiRootResource root) { - ClientConfiguration config = WebClient.getConfig(root); - HTTPConduit conduit = config.getHttpConduit(); - if (conduit == null) { - throw new IllegalArgumentException( - "Client is not using the HTTP transport"); + Client client = WebClient.client(root); + if (client != null) { + client.close(); } - conduit.close(); } /** @@ -289,14 +347,17 @@ public static void clearCachedResources() { /** A trust manager that will accept all certificates. */ private static class AcceptAllTrustManager implements X509TrustManager { + @Override public void checkClientTrusted(X509Certificate[] chain, String authType) { // no op. } + @Override public void checkServerTrusted(X509Certificate[] chain, String authType) { // no op. } + @Override public X509Certificate[] getAcceptedIssuers() { return null; } diff --git a/java/src/main/java/com/cloudera/api/DataView.java b/java/src/main/java/com/cloudera/api/DataView.java index 25737c98..b41b6c01 100644 --- a/java/src/main/java/com/cloudera/api/DataView.java +++ b/java/src/main/java/com/cloudera/api/DataView.java @@ -21,6 +21,12 @@ public enum DataView { SUMMARY, FULL, + /** + * Entities with health test results and health test explanation. + * Generating and transferring health check explanation for entities can be + * very expensive. + **/ + FULL_WITH_HEALTH_CHECK_EXPLANATION, EXPORT, /** All passwords and other sensitive fields are marked as REDACTED. */ EXPORT_REDACTED; diff --git a/java/src/main/java/com/cloudera/api/Parameters.java b/java/src/main/java/com/cloudera/api/Parameters.java index 64893610..9e8ed805 100644 --- a/java/src/main/java/com/cloudera/api/Parameters.java +++ b/java/src/main/java/com/cloudera/api/Parameters.java @@ -31,6 +31,7 @@ public final class Parameters { static public final String USER_NAME = "userName"; static public final String ACTIVITY_ID = "activityId"; static public final String PEER_NAME = "peerName"; + static public final String PEER_TYPE = "type"; static public final String SCHEDULE_ID = "scheduleId"; static public final String PRODUCT = "product"; static public final String VERSION = "version"; @@ -57,9 +58,11 @@ public final class Parameters { /* Default values. */ static public final String DATA_VIEW_DEFAULT = "summary"; static public final String DATA_VIEW_EXPORT = "export"; + static public final String DATA_VIEW_FULL = "full"; static public final String DATE_TIME_NOW = "now"; static public final String DAILY_AGGREGATION = "daily"; static public final String FILTER_DEFAULT = ""; + static public final String ROLLUP_DEFAULT = "RAW"; /* Common filtering properties. */ static public final String HOSTNAME = "hostname"; diff --git a/java/src/main/java/com/cloudera/api/model/ApiCluster.java b/java/src/main/java/com/cloudera/api/model/ApiCluster.java index 1874ce08..f7f16397 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCluster.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCluster.java @@ -33,18 +33,21 @@ */ @XmlRootElement(name = "cluster") @XmlType(propOrder = {"name", "displayName", "version", "fullVersion", - "maintenanceMode", "maintenanceOwners", "services", "parcels", "clusterUrl"}) + "maintenanceMode", "maintenanceOwners", "services", "parcels", "clusterUrl", + "hostsUrl", "entityStatus"}) public class ApiCluster { private String name; private String displayName; private String clusterUrl; + private String hostsUrl; private ApiClusterVersion version; private String fullVersion; private Boolean maintenanceMode; private List maintenanceOwners; private List services; private List parcels; + private ApiEntityStatus entityStatus; public ApiCluster() { // For JAX-B @@ -102,8 +105,7 @@ public void setDisplayName(String displayName) { } /** - * Read only. - * Link into the Cloudera Manager web UI for this specific cluster. + * Readonly. Link into the Cloudera Manager web UI for this specific cluster. *

* Available since API v10. */ @@ -116,6 +118,20 @@ public void setClusterUrl(String clusterUrl) { this.clusterUrl = clusterUrl; } + /** + * Readonly. Link into the Cloudera Manager web UI for host table for this cluster. + *

+ * Available since API v11. + */ + @XmlElement + public String getHostsUrl() { + return hostsUrl; + } + + public void setHostsUrl(String hostsUrl) { + this.hostsUrl = hostsUrl; + } + /** The CDH version of the cluster. */ @XmlElement public ApiClusterVersion getVersion() { @@ -193,4 +209,17 @@ public List getParcels() { public void setParcels(List parcels) { this.parcels = parcels; } + + /** + * Readonly. The entity status for this cluster. + * Available since API v11. + */ + @XmlElement + public ApiEntityStatus getEntityStatus() { + return entityStatus; + } + + public void setEntityStatus(ApiEntityStatus entityStatus) { + this.entityStatus = entityStatus; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplate.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplate.java new file mode 100644 index 00000000..0a978b1c --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplate.java @@ -0,0 +1,137 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Lists; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Details of cluster template + */ + +@XmlRootElement(name = "clusterTemplate") +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplate { + + /** + * CDH version + */ + private String cdhVersion; + /** + * Cluster display name + */ + private String displayName; + /** + * CM version for which the template + */ + private String cmVersion; + /** + * List of all repositories registered with CM + */ + @JsonInclude(Include.NON_EMPTY) + private List repositories = Lists.newArrayList(); + /** + * All the parcels that needs to be deployed and activated + */ + private List products = Lists.newArrayList(); + /** + * All the services that needs to be deployed + */ + @JsonInclude(Include.NON_EMPTY) + private List services = Lists.newArrayList(); + /** + * All host templates + */ + @JsonInclude(Include.NON_EMPTY) + private List hostTemplates = Lists.newArrayList(); + + /** + * A constructor listing all the variables and references that needs to be + * resolved for this template + */ + private ApiClusterTemplateInstantiator instantiator; + + public String getCdhVersion() { + return this.cdhVersion; + } + + public void setCdhVersion(String cdhVersion) { + this.cdhVersion = cdhVersion; + } + + public List getProducts() { + return this.products; + } + + public void setProducts(List products) { + this.products = products; + } + + public List getServices() { + return this.services; + } + + public void setServices(List services) { + this.services = services; + } + + public List getHostTemplates() { + return this.hostTemplates; + } + + public void setHostTemplates(List hostTemplates) { + this.hostTemplates = hostTemplates; + } + + public String getDisplayName() { + return this.displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getCmVersion() { + return this.cmVersion; + } + + public void setCmVersion(String cmVersion) { + this.cmVersion = cmVersion; + } + + public ApiClusterTemplateInstantiator getInstantiator() { + return this.instantiator; + } + + public void setInstantiator(ApiClusterTemplateInstantiator instantiator) { + this.instantiator = instantiator; + } + + public List getRepositories() { + return this.repositories; + } + + public void setRepositories(List repositories) { + this.repositories = repositories; + } + +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateConfig.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateConfig.java new file mode 100644 index 00000000..4fa0637b --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateConfig.java @@ -0,0 +1,96 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * Config Details: The config can either have a value or ref or variable. + */ +public class ApiClusterTemplateConfig { + /** + * Config name + */ + private String name; + /** + * Config value + */ + @JsonInclude(Include.NON_NULL) + private String value; + /** + * Name of the reference. If referring to a service then it will be replaced + * with actual service name at import time. If referring to a role then it + * will be replaced with the host name containing that role at import time. + */ + @JsonInclude(Include.NON_EMPTY) + private String ref; + /** + * Referring a variable. The variable value will be provided by the user at + * import time. Variable name for this config. At import time the value of + * this variable will be provided by the + * {@link #ApiClusterTemplateInstantiator.Variable} + */ + @JsonInclude(Include.NON_EMPTY) + private String variable; + /** + * This indicates that the value was automatically configured. + */ + @JsonInclude(Include.NON_DEFAULT) + private boolean autoConfig; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getRef() { + return this.ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getVariable() { + return this.variable; + } + + public void setVariable(String variable) { + this.variable = variable; + } + + public boolean isAutoConfig() { + return this.autoConfig; + } + + public void setAutoConfig(boolean autoConfig) { + this.autoConfig = autoConfig; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostInfo.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostInfo.java new file mode 100644 index 00000000..12cd2e6b --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostInfo.java @@ -0,0 +1,95 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Sets; + +import java.util.Set; + +/** + * This contains information about the host or host range on which provided + * host template will be applied. + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateHostInfo { + /** + * Host name + */ + private String hostName; + /** + * Host range. Either this this or host name must be provided. + */ + private String hostNameRange; + /** + * Rack Id + */ + private String rackId; + /** + * Pointing to the host template reference in the cluster template. + */ + private String hostTemplateRefName; + /** + * This will used to resolve the roles defined in the cluster template. This + * roleRefName will be used to connect this host with that a role referrence + * defined in cluster template. + */ + private Set roleRefNames = Sets.newHashSet(); + + public String getHostName() { + return this.hostName; + } + + public ApiClusterTemplateHostInfo setHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public String getHostNameRange() { + return this.hostNameRange; + } + + public void setHostNameRange(String hostNameRange) { + this.hostNameRange = hostNameRange; + } + + public String getRackId() { + return this.rackId; + } + + public void setRackId(String rackId) { + this.rackId = rackId; + } + + public String getHostTemplateRefName() { + return this.hostTemplateRefName; + } + + public void setHostTemplateRefName(String hostTemplateRefName) { + this.hostTemplateRefName = hostTemplateRefName; + } + + public Set getRoleRefNames() { + return this.roleRefNames; + } + + public void setRoleRefNames(Set roleRefNames) { + this.roleRefNames = roleRefNames; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostTemplate.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostTemplate.java new file mode 100644 index 00000000..98415e4f --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateHostTemplate.java @@ -0,0 +1,70 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Host templates will contain information about the role config groups that + * should be applied to a host. This basically means a host will have a role + * corresponding to each config group. + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateHostTemplate { + /** + * Reference name + */ + private String refName; + /** + * Represent the cardinality of this host template on source + */ + private int cardinality; + /** + * List of role config groups + */ + private List roleConfigGroupsRefNames = Lists.newArrayList(); + + public String getRefName() { + return this.refName; + } + + public void setRefName(String refName) { + this.refName = refName; + } + + public List getRoleConfigGroupsRefNames() { + return this.roleConfigGroupsRefNames; + } + + public void setRoleConfigGroupsRefNames( + List roleConfigGroupsRefNames) { + this.roleConfigGroupsRefNames = roleConfigGroupsRefNames; + } + + public int getCardinality() { + return this.cardinality; + } + + public void setCardinality(int cardinality) { + this.cardinality = cardinality; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateInstantiator.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateInstantiator.java new file mode 100644 index 00000000..2562859e --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateInstantiator.java @@ -0,0 +1,86 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Lists; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Details of cluster template + */ + +@XmlRootElement(name = "clusterTemplateInstantiator") +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateInstantiator { + + /** + * Cluster name + */ + private String clusterName; + /** + * All the hosts that are part of that cluster + */ + private List hosts = Lists.newArrayList(); + /** + * All the variables the are referred by the cluster template + */ + private List variables = Lists.newArrayList(); + /** + * All the role config group informations for non-base RCGs. + */ + private List roleConfigGroups = Lists.newArrayList(); + + public String getClusterName() { + return this.clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public List getHosts() { + return this.hosts; + } + + public void setHosts(List hosts) { + this.hosts = hosts; + } + + public List getVariables() { + return this.variables; + } + + public void setVariables( + List variables) { + this.variables = variables; + } + + public List getRoleConfigGroups() { + return roleConfigGroups; + } + + public void setRoleConfigGroups( + List roleConfigGroups) { + this.roleConfigGroups = roleConfigGroups; + } + +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRole.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRole.java new file mode 100644 index 00000000..cffaa6f9 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRole.java @@ -0,0 +1,54 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * Role info: This will contain information related to a role referred by some + * configuration. During import type this role must be materizalized. + * + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateRole { + /** + * Role reference name + */ + private String refName; + /** + * Role type + */ + private String roleType; + + public String getRefName() { + return this.refName; + } + + public void setRefName(String refName) { + this.refName = refName; + } + + public String getRoleType() { + return this.roleType; + } + + public void setRoleType(String roleType) { + this.roleType = roleType; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroup.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroup.java new file mode 100644 index 00000000..a8a4ec16 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroup.java @@ -0,0 +1,93 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Role config group info. + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateRoleConfigGroup { + /** + * The reference name of the role config. + */ + private String refName; + /** + * Role type + */ + private String roleType; + /** + * If true then it is the base config group for that role. There can only be + * one base role config group for a given role type. + */ + @JsonInclude(Include.NON_DEFAULT) + private boolean isBase; + /** + * Role config group display name + */ + private String displayName; + /** + * List of configurations + */ + private List configs = Lists.newArrayList(); + + public String getRefName() { + return this.refName; + } + + public void setRefName(String refName) { + this.refName = refName; + } + + public String getRoleType() { + return this.roleType; + } + + public void setRoleType(String roleType) { + this.roleType = roleType; + } + + public boolean isBase() { + return this.isBase; + } + + public void setBase(boolean isBase) { + this.isBase = isBase; + } + + public String getDisplayName() { + return this.displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public List getConfigs() { + return this.configs; + } + + public void setConfigs(List configs) { + this.configs = configs; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroupInfo.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroupInfo.java new file mode 100644 index 00000000..009bc61c --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateRoleConfigGroupInfo.java @@ -0,0 +1,51 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + + +/** + * During import time information related to all the non-base config groups + * must be provided. + */ +public class ApiClusterTemplateRoleConfigGroupInfo { + /** + * Role config group reference name. This much match the reference name from + * the template. + */ + private String rcgRefName; + /** + * Role config group name. + */ + private String name; + + public String getRcgRefName() { + return this.rcgRefName; + } + + public void setRcgRefName(String rcgRefName) { + this.rcgRefName = rcgRefName; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateService.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateService.java new file mode 100644 index 00000000..d646269a --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateService.java @@ -0,0 +1,104 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Service information + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateService { + /** + * Reference name of the service. This could be referred by some + * configuration. + */ + private String refName; + /** + * Service type + */ + private String serviceType; + /** + * Service level configuration + */ + private List serviceConfigs = Lists.newArrayList(); + /** + * All role config groups for that service + */ + private List roleConfigGroups = Lists.newArrayList(); + /** + * Service display name. + */ + private String displayName; + /** + * List of roles for this service that are referred by some configuration. + */ + private List roles = Lists.newArrayList(); + + public String getRefName() { + return this.refName; + } + + public void setRefName(String refName) { + this.refName = refName; + } + + public String getServiceType() { + return this.serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public List getServiceConfigs() { + return this.serviceConfigs; + } + + public void setServiceConfigs(List serviceConfigs) { + this.serviceConfigs = serviceConfigs; + } + + public List getRoleConfigGroups() { + return this.roleConfigGroups; + } + + public void setRoleConfigGroups(List roleConfigGroups) { + this.roleConfigGroups = roleConfigGroups; + } + + public List getRoles() { + return this.roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getDisplayName() { + return this.displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateVariable.java b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateVariable.java new file mode 100644 index 00000000..bec72eaa --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiClusterTemplateVariable.java @@ -0,0 +1,52 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * Variable that is referred in cluster template. + */ +@JsonInclude(Include.NON_EMPTY) +public class ApiClusterTemplateVariable { + /** + * Variable name that are referred in cluster template + */ + private String name; + /** + * This value will be placed whereever the variable is referred in the + * cluster template + */ + private String value; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiCmPeer.java b/java/src/main/java/com/cloudera/api/model/ApiCmPeer.java index 865bc69b..42a3102c 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCmPeer.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCmPeer.java @@ -24,22 +24,34 @@ /** * Information about a Cloudera Manager peer instance. *

- * The username and password properties are only used when - * creating peers. They should be the credentials of a user with administrator - * privileges on the remote Cloudera Manager being linked. These credentials are - * not stored; they're just used to create the peer. + * The requirement and usage of username and password properties + * are dependent on the clouderaManagerCreatedUser flag. *

- * When retrieving peer information, neither of the above fields are populated. + * When creating peers, if 'clouderaManagerCreatedUser' is true, the + * username/password should be the credentials of a user with administrator + * privileges on the remote Cloudera Manager. These credentials are not stored, + * they are used to connect to the peer and create a user in that peer. The + * newly created user is stored and used for communication with that peer. + * If 'clouderaManagerCreatedUser' is false, which is not applicable to + * REPLICATION peer type, the username/password to the remote Cloudera Manager + * are directly stored and used for all communications with that peer. + *

+ * When updating peers, if 'clouderaManagerCreatedUser' is true and + * username/password are set, a new remote user will be created. If + * 'clouderaManagerCreatedUser' is false and username/password are set, the + * stored username/password will be updated. */ @XmlRootElement(name = "cmPeer") public class ApiCmPeer { private String name; + private ApiCmPeerType type; private String url; private String username; private String password; + private Boolean clouderaManagerCreatedUser; - /** The name of the link. */ + /** The name of the remote CM instance. Immutable during update.*/ @XmlElement public String getName() { return name; @@ -49,7 +61,21 @@ public void setName(String name) { this.name = name; } - /** The URL of the remote CM instance. */ + /** + * The type of the remote CM instance. Immutable during update. + * + * Available since API v11. + **/ + @XmlElement + public ApiCmPeerType getType() { + return type; + } + + public void setType(ApiCmPeerType type) { + this.type = type; + } + + /** The URL of the remote CM instance. Mutable during update.*/ @XmlElement public String getUrl() { return url; @@ -59,7 +85,22 @@ public void setUrl(String url) { this.url = url; } - /** The remote admin username, for setting up the link. */ + /** + * When creating peers, if 'clouderaManagerCreatedUser' is true, this should be + * the remote admin username for creating a user in remote Cloudera Manager. The + * created remote user will then be stored in the local Cloudera Manager DB and + * used in later communication. If 'clouderaManagerCreatedUser' is false, which + * is not applicable to REPLICATION peer type, Cloudera Manager will store this + * username in the local DB directly and use it together with 'password' for + * communication. + * + * Mutable during update. + * When set during update, if 'clouderaManagerCreatedUser' is true, a new user + * in remote Cloudera Manager is created, the newly created remote user will be + * stored in the local DB. An attempt to delete the previously created remote + * user will be made; If 'clouderaManagerCreatedUser' is false, the + * username/password in the local DB will be updated. + **/ @XmlElement public String getUsername() { return username; @@ -69,7 +110,22 @@ public void setUsername(String username) { this.username = username; } - /** The remote admin password, for setting up the link. */ + /** + * When creating peers, if 'clouderaManagerCreatedUser' is true, this should be + * the remote admin password for creating a user in remote Cloudera Manager. The + * created remote user will then be stored in the local Cloudera Manager DB and + * used in later communication. If 'clouderaManagerCreatedUser' is false, which + * is not applicable to REPLICATION peer type, Cloudera Manager will store this + * password in the local DB directly and use it together with 'username' for + * communication. + * + * Mutable during update. + * When set during update, if 'clouderaManagerCreatedUser' is true, a new user + * in remote Cloudera Manager is created, the newly created remote user will be + * stored in the local DB. An attempt to delete the previously created remote + * user will be made; If 'clouderaManagerCreatedUser' is false, the + * username/password in the local DB will be updated. + **/ @XmlElement public String getPassword() { return password; @@ -79,11 +135,36 @@ public void setPassword(String password) { this.password = password; } + /** + * If true, Cloudera Manager creates a remote user using the given + * username/password and stores the created user in local DB for use in later + * communication. Cloudera Manager will also try to delete the created remote + * user when deleting such peers. + * + * If false, Cloudera Manager will store the provided username/password in + * the local DB and use them in later communication. 'false' value on this + * field is not applicable to REPLICATION peer type. + * + * Available since API v11. + * + * Immutable during update. Should not be set when updating peers. + **/ + @XmlElement + public Boolean getClouderaManagerCreatedUser() { + return clouderaManagerCreatedUser; + } + + public void setClouderaManagerCreatedUser(Boolean clouderaManagerCreatedUser) { + this.clouderaManagerCreatedUser = clouderaManagerCreatedUser; + } + @Override public String toString() { return Objects.toStringHelper(this) .add("name", name) .add("url", url) + .add("type", type) + .add("clouderaManagerCreatedUser", clouderaManagerCreatedUser) .toString(); } @@ -92,12 +173,14 @@ public boolean equals(Object o) { ApiCmPeer other = ApiUtils.baseEquals(this, o); return this == other || (other != null && Objects.equal(name, other.getName()) && - Objects.equal(url, other.getUrl())); + Objects.equal(url, other.getUrl()) && + Objects.equal(type, other.getType()) && + Objects.equal(clouderaManagerCreatedUser, + other.getClouderaManagerCreatedUser())); } @Override public int hashCode() { - return Objects.hashCode(name, url); + return Objects.hashCode(name, url, type, clouderaManagerCreatedUser); } - } diff --git a/java/src/main/java/com/cloudera/api/model/ApiCmPeerType.java b/java/src/main/java/com/cloudera/api/model/ApiCmPeerType.java new file mode 100644 index 00000000..f3232062 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiCmPeerType.java @@ -0,0 +1,24 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +/** + * Enum for CM peer types. + */ +public enum ApiCmPeerType { + REPLICATION, // Remote CM is used in replication. + STATUS_AGGREGATION // Remote CM is used in status aggregation. +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiCommand.java b/java/src/main/java/com/cloudera/api/model/ApiCommand.java index f9dc78d0..f31c6fa8 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCommand.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCommand.java @@ -40,7 +40,8 @@ @XmlType(propOrder = { "id", "name", "startTime", "endTime", "active", "success", "resultMessage", "resultDataUrl", - "clusterRef", "serviceRef", "roleRef", "hostRef", "parent", "children" + "clusterRef", "serviceRef", "roleRef", "hostRef", "parent", "children", + "canRetry" }) public class ApiCommand { @@ -59,11 +60,12 @@ public class ApiCommand { private ApiHostRef hostRef; private ApiCommandList children; private ApiCommand parent; + private Boolean canRetry; public ApiCommand() { // For JAX-B this(null, null, null, null, false, null, null, null, null, null, null, null, - null, null); + null, null, null); } public ApiCommand(Long id, String name, Date startTime, Date endTime, @@ -71,7 +73,8 @@ public ApiCommand(Long id, String name, Date startTime, Date endTime, String resultDataUrl, ApiClusterRef clusterRef, ApiServiceRef serviceRef, ApiRoleRef roleRef, ApiHostRef hostRef, - ApiCommandList children, ApiCommand parent) { + ApiCommandList children, ApiCommand parent, + Boolean canRetry) { this.id = id; this.name = name; this.startTime = startTime; @@ -86,6 +89,7 @@ public ApiCommand(Long id, String name, Date startTime, Date endTime, this.hostRef = hostRef; this.children = children; this.parent = parent; + this.canRetry = canRetry; } @Override @@ -254,6 +258,18 @@ public void setChildren(ApiCommandList children) { this.children = children; } + /** + * Available since V11 + */ + @XmlElement + public Boolean isCanRetry() { + return this.canRetry; + } + + public void setCanRetry(Boolean canRetry) { + this.canRetry = canRetry; + } + @Override public boolean equals(Object o) { ApiCommand that = ApiUtils.baseEquals(this, o); @@ -270,14 +286,15 @@ public boolean equals(Object o) { Objects.equal(roleRef, that.getRoleRef()) && Objects.equal(hostRef, that.getHostRef()) && Objects.equal(clusterRef, that.getClusterRef()) && - Objects.equal(parent, that.getParent())); + Objects.equal(parent, that.getParent()) && + Objects.equal(canRetry, that.isCanRetry())); } @Override public int hashCode() { return Objects.hashCode(id, name, startTime, endTime, active, success, resultMessage, resultDataUrl, serviceRef, roleRef, hostRef, clusterRef, - parent); + parent, canRetry); } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiConfig.java b/java/src/main/java/com/cloudera/api/model/ApiConfig.java index 99dc6e6a..ca4931d3 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiConfig.java +++ b/java/src/main/java/com/cloudera/api/model/ApiConfig.java @@ -33,9 +33,16 @@ * the default value (if any). */ @XmlRootElement(name = "config") -@XmlType(propOrder = { "name", "value", "required", "defaultValue", - "displayName", "description", "relatedName", "validationState", - "validationMessage" }) +@XmlType(propOrder = { "name", + "value", + "required", + "defaultValue", + "displayName", + "description", + "relatedName", + "validationState", + "validationMessage", + "validationWarningsSuppressed" }) public class ApiConfig { private String name; @@ -47,6 +54,7 @@ public class ApiConfig { private Boolean required; private ValidationState validationState; private String validationMessage; + private Boolean validationWarningsSuppressed; public static enum ValidationState { OK, @@ -65,9 +73,16 @@ public static enum ValidationState { * @param validationState State of the parameter's validation. * @param validationMessage Message describing any validation issues. */ - public ApiConfig(String name, String value, Boolean required, - String defaultValue, String displayName, String description, - String relatedName, ValidationState validationState, String validationMessage) { + public ApiConfig( + String name, + String value, + Boolean required, + String defaultValue, + String displayName, + String description, + String relatedName, + ValidationState validationState, + String validationMessage) { this.name = name; this.value = value; this.required = required; @@ -77,6 +92,7 @@ public ApiConfig(String name, String value, Boolean required, this.relatedName = relatedName; this.validationState = validationState; this.validationMessage = validationMessage; + this.validationWarningsSuppressed = null; } public ApiConfig(String name, String value) { @@ -93,6 +109,7 @@ public ApiConfig() { this.relatedName = null; this.validationState = null; this.validationMessage = null; + this.validationWarningsSuppressed = null; } public String toString() { @@ -238,4 +255,21 @@ public String getValidationMessage() { public void setValidationMessage(String validationMessage) { this.validationMessage = validationMessage; } + + /** + * Readonly. Requires "full" view. + * Whether validation warnings associated with this parameter are suppressed. + * In general, suppressed validation warnings are hidden in the Cloudera + * Manager UI. Configurations that do not produce warnings will not contain + * this field. + **/ + @XmlElement + public Boolean getValidationWarningsSuppressed() { + return validationWarningsSuppressed; + } + + public void setValidationWarningsSuppressed( + Boolean validationWarningsSuppressed) { + this.validationWarningsSuppressed = validationWarningsSuppressed; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiConfigureForKerberosArguments.java b/java/src/main/java/com/cloudera/api/model/ApiConfigureForKerberosArguments.java new file mode 100644 index 00000000..a837c55d --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiConfigureForKerberosArguments.java @@ -0,0 +1,78 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Arguments used to configure a cluster for Kerberos. + */ +@XmlRootElement(name="configureForKerberosArgs") +public class ApiConfigureForKerberosArguments { + private Long datanodeTransceiverPort; + private Long datanodeWebPort; + + /** + * The HDFS DataNode transceiver port to use. This will be applied to all DataNode + * role configuration groups. If not specified, this will default to 1004. + */ + @XmlElement + public Long getDatanodeTransceiverPort() { + return datanodeTransceiverPort; + } + + public void setDatanodeTransceiverPort(Long datanodeTransceiverPort) { + this.datanodeTransceiverPort = datanodeTransceiverPort; + } + + /** + * The HDFS DataNode web port to use. This will be applied to all DataNode + * role configuration groups. If not specified, this will default to 1006. + */ + @XmlElement + public Long getDatanodeWebPort() { + return datanodeWebPort; + } + + public void setDatanodeWebPort(Long datanodeWebPort) { + this.datanodeWebPort = datanodeWebPort; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("datanodeTransceiverPort", datanodeTransceiverPort) + .add("datanodeWebPort", datanodeWebPort) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiConfigureForKerberosArguments other = ApiUtils.baseEquals(this, o); + return this == other || (other != null && + Objects.equal(this.datanodeTransceiverPort, other.datanodeTransceiverPort) && + Objects.equal(this.datanodeWebPort, other.datanodeWebPort)); + } + + @Override + public int hashCode() { + return Objects.hashCode(datanodeTransceiverPort, datanodeWebPort); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiEntityStatus.java b/java/src/main/java/com/cloudera/api/model/ApiEntityStatus.java new file mode 100644 index 00000000..992077bb --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiEntityStatus.java @@ -0,0 +1,53 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +/** + * The single value used by the Cloudera Manager UI to represent the status of + * the entity. It is computed from a variety of other entity-specific states, + * not all values apply to all entities. For example, STARTING/STOPPING do not + * apply to a host. + */ +public enum ApiEntityStatus { + // There is not enough information to determine the entity status. + UNKNOWN, + // The entity in question does not have a entity status. For example, it is + // not something that can be running and it cannot have health. + NONE, + // The entity in question is not running, as expected. + STOPPED, + // The entity in question is not running, but it is expected to be running. + DOWN, + // The entity in question is running, but we do not have enough information + // to determine its health. + UNKNOWN_HEALTH, + // The entity in question is running, but all of its health checks are + // disabled. + DISABLED_HEALTH, + // The entity in question is running with concerning health. + CONCERNING_HEALTH, + // The entity in question is running with bad health. + BAD_HEALTH, + // The entity in question is running with good health. + GOOD_HEALTH, + // The entity in question is starting. + STARTING, + // The entity in question is stopping. + STOPPING, + // The application is in historical mode, and the entity in question does not + // have historical monitoring support. + HISTORY_NOT_AVAILABLE; +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java index 29b4a61b..5892abb4 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java @@ -15,11 +15,14 @@ // limitations under the License. package com.cloudera.api.model; +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import java.util.List; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.cloudera.api.ApiUtils; -import com.google.common.base.Objects; /** * Replication arguments for HDFS. @@ -45,6 +48,7 @@ public class ApiHdfsReplicationArguments { private Boolean skipTrash; private ReplicationStrategy replicationStrategy; private Boolean preserveXAttrs; + private List exclusionFilters; /** * The strategy for distributing the file replication tasks among the mappers @@ -277,7 +281,7 @@ public void setSkipTrash(Boolean skipTrash) { /** * The strategy for distributing the file replication tasks among the mappers * of the MR job associated with a replication. Default is - * {@link ReplicationStrategy.STATIC}. + * {@link ReplicationStrategy#STATIC}. */ @XmlElement public ReplicationStrategy getReplicationStrategy() { @@ -303,6 +307,21 @@ public void setPreserveXAttrs(Boolean preserveXAttrs) { this.preserveXAttrs = preserveXAttrs; } + /** + * Specify regular expression strings to match full paths of files and directories + * matching source paths and exclude them from the replication. Optional. + * Available since V11. + * @return exclusion paths, if set; null if no exclusion paths are specified. + */ + @XmlElement + public List getExclusionFilters() { + return exclusionFilters; + } + + public void setExclusionFilters(List exclusionFilters) { + this.exclusionFilters = exclusionFilters; + } + @Override public String toString() { return Objects.toStringHelper(this) @@ -324,6 +343,7 @@ public String toString() { .add("skipTrash", skipTrash) .add("replicationStrategy", replicationStrategy) .add("preserveXAttrs", preserveXAttrs) + .add("exclusionFilters", exclusionFilters) .toString(); } @@ -348,7 +368,8 @@ public boolean equals(Object o) { skipChecksumChecks == other.getSkipChecksumChecks() && Objects.equal(skipTrash, other.getSkipTrash()) && Objects.equal(replicationStrategy, other.getReplicationStrategy()) && - Objects.equal(preserveXAttrs, other.getPreserveXAttrs())); + Objects.equal(preserveXAttrs, other.getPreserveXAttrs())) && + Objects.equal(exclusionFilters, other.getExclusionFilters()); } @Override @@ -358,6 +379,6 @@ public int hashCode() { bandwidthPerMap, abortOnError, removeMissingFiles, preserveReplicationCount, preserveBlockSize, preservePermissions, logPath, skipChecksumChecks, skipTrash, replicationStrategy, - preserveXAttrs); + preserveXAttrs, exclusionFilters); } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationResult.java b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationResult.java index 50fe8479..91ecaded 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationResult.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationResult.java @@ -48,6 +48,8 @@ public class ApiHdfsReplicationResult { private String jobDetailsUri; private boolean dryRun; private List snapshottedDirs; + private List failedFiles; + private String runAsUser; /** The file copy progress percentage. */ @XmlElement @@ -257,6 +259,32 @@ public void setSnapshottedDirs(List snapshottedDirs) { this.snapshottedDirs = snapshottedDirs; } + /** + * Returns run-as user name. + * Available since API v11. + */ + @XmlElement + public String getRunAsUser() { + return runAsUser; + } + + public void setRunAsUser(String runAsUser) { + this.runAsUser = runAsUser; + } + + /** + * The list of files that failed during replication. + * Available since API v11. + */ + @XmlElement + public List getFailedFiles() { + return failedFiles; + } + + public void setFailedFiles(List failedFiles) { + this.failedFiles = failedFiles; + } + @Override public boolean equals(Object o) { ApiHdfsReplicationResult that = ApiUtils.baseEquals(this, o); @@ -265,13 +293,15 @@ public boolean equals(Object o) { Objects.equal(counters, that.getCounters()) && Objects.equal(setupError, that.getSetupError()) && dryRun == that.isDryRun() && - Objects.equal(snapshottedDirs, that.getSnapshottedDirs())); + Objects.equal(snapshottedDirs, that.getSnapshottedDirs())) && + Objects.equal(failedFiles, that.getFailedFiles()) && + Objects.equal(runAsUser, that.getRunAsUser()); } @Override public int hashCode() { return Objects.hashCode(progress, counters, setupError, dryRun, - snapshottedDirs); + snapshottedDirs, failedFiles, runAsUser); } @Override @@ -282,6 +312,8 @@ public String toString() { .add("setupError", setupError) .add("dryRun", dryRun) .add("snapshottedDirs", snapshottedDirs) + .add("failedFiles", failedFiles) + .add("runAsUser", runAsUser) .toString(); } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHealthCheck.java b/java/src/main/java/com/cloudera/api/model/ApiHealthCheck.java index 04772591..f78cdfcd 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHealthCheck.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHealthCheck.java @@ -19,10 +19,16 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +/** + * Represents a result from a health test performed by Cloudera Manager for an + * entity. + */ @XmlRootElement(name = "healthCheck") public class ApiHealthCheck { private String name; private ApiHealthSummary summary; + private String explanation; + private Boolean suppressed; public ApiHealthCheck() { // For JAX-B @@ -33,6 +39,15 @@ public ApiHealthCheck(String name, ApiHealthSummary summary) { this.summary = summary; } + public ApiHealthCheck(String name, + ApiHealthSummary summary, + String explanation, + boolean suppressed) { + this(name, summary); + this.explanation = explanation; + this.suppressed = suppressed; + } + /** Unique name of this health check. */ @XmlElement public String getName() { @@ -52,4 +67,31 @@ public ApiHealthSummary getSummary() { public void setSummary(ApiHealthSummary summary) { this.summary = summary; } + + /** + * The explanation of this health check. + * Available since v11. + **/ + @XmlElement + public String getExplanation() { + return explanation; + } + + public void setExplanation(String explanation) { + this.explanation = explanation; + } + + /** + * Whether this health test is suppressed. A suppressed health test is not + * considered when computing an entity's overall health. + * Available since v11. + **/ + @XmlElement + public Boolean getSuppressed() { + return suppressed; + } + + public void setSuppressed(Boolean suppressed) { + this.suppressed = suppressed; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java index 72c12dd8..49ef2872 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java @@ -38,6 +38,7 @@ public class ApiHiveReplicationResult { private List errors; private ApiHdfsReplicationResult dataReplicationResult; private boolean dryRun; + private String runAsUser; public ApiHiveReplicationResult() { // For JAX-B @@ -164,6 +165,19 @@ public void setDryRun(boolean dryRun) { this.dryRun = dryRun; } + /** + * Name of the of proxy user, if any. + * Available since API v11. + */ + @XmlElement + public String getRunAsUser() { + return runAsUser; + } + + public void setRunAsUser(String runAsUser) { + this.runAsUser = runAsUser; + } + @Override public boolean equals(Object o) { ApiHiveReplicationResult that = ApiUtils.baseEquals(this, o); @@ -172,12 +186,14 @@ public boolean equals(Object o) { Objects.equal(tables, that.getTables()) && Objects.equal(impalaUDFs, that.getImpalaUDFs()) && Objects.equal(errors, that.getErrors()) && - dryRun == that.isDryRun()); + dryRun == that.isDryRun() && + Objects.equal(runAsUser, that.getRunAsUser())); } @Override public int hashCode() { - return Objects.hashCode(phase, tables, impalaUDFs, errors, dryRun); + return Objects.hashCode(phase, tables, impalaUDFs, errors, dryRun, + runAsUser); } @Override @@ -188,6 +204,7 @@ public String toString() { .add("impalaUDFs", impalaUDFs) .add("errors", errors) .add("dryRun", dryRun) + .add("runAsUser", runAsUser) .toString(); } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHost.java b/java/src/main/java/com/cloudera/api/model/ApiHost.java index ed727278..7c145ba3 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHost.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHost.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; + import java.util.Date; import java.util.List; @@ -49,6 +50,8 @@ public class ApiHost { private Long numCores; private Long numPhysicalCores; private Long totalPhysMemBytes; + private ApiEntityStatus entityStatus; + private ApiClusterRef clusterRef; public ApiHost() { // for JAX-B @@ -81,6 +84,7 @@ public ApiHost(ApiHost host) { this.numCores = host.getNumCores(); this.numPhysicalCores = host.getNumPhysicalCores(); this.totalPhysMemBytes = host.getTotalPhysMemBytes(); + this.clusterRef = host.clusterRef; } @Override @@ -94,6 +98,7 @@ public String toString() { .add("healthSummary", healthSummary) .add("healthChecks", healthChecks) .add("roleRefs", roleRefs) + .add("clusterRef", clusterRef) .toString(); } @@ -308,4 +313,31 @@ public Long getTotalPhysMemBytes() { public void setTotalPhysMemBytes(Long totalPhysMemBytes) { this.totalPhysMemBytes = totalPhysMemBytes; } + + /** + * Readonly. The entity status for this host. + * Available since API v11. + */ + @XmlElement + public ApiEntityStatus getEntityStatus() { + return entityStatus; + } + + public void setEntityStatus(ApiEntityStatus entityStatus) { + this.entityStatus = entityStatus; + } + + /** + * Readonly. A reference to the enclosing cluster. This might be null if the + * host is not yet assigned to a cluster. + * Available since API v11. + */ + @XmlElement + public ApiClusterRef getClusterRef() { + return clusterRef; + } + + public void setClusterRef(ApiClusterRef clusterRef) { + this.clusterRef = clusterRef; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHostInstallArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHostInstallArguments.java index d632f756..c7b22420 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHostInstallArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHostInstallArguments.java @@ -192,9 +192,9 @@ public void setParallelInstallCount(Integer parallelInstallCount) { /** * The Cloudera Manager repository URL to use (optional). * Example for SLES, Redhat or other RPM based distributions: - * http://archive.cloudera.com/cm5/redhat/5/x86_64/cm/5/ + * https://archive.cloudera.com/cm5/redhat/5/x86_64/cm/5/ * Example for Ubuntu or other Debian based distributions: - * "deb http://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm lucid-cm5 contrib" + * "deb https://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm lucid-cm5 contrib" */ @XmlElement public String getCmRepoUrl() { @@ -208,9 +208,9 @@ public void setCmRepoUrl(String cmRepoUrl) { /** * The Cloudera Manager public GPG key (optional). * Example for SLES, Redhat or other RPM based distributions: - * http://archive.cloudera.com/cm5/redhat/5/x86_64/cm/RPM-GPG-KEY-cloudera + * https://archive.cloudera.com/cm5/redhat/5/x86_64/cm/RPM-GPG-KEY-cloudera * Example for Ubuntu or other Debian based distributions: - * http://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm/archive.key + * https://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm/archive.key */ @XmlElement public String getGpgKeyCustomUrl() { diff --git a/java/src/main/java/com/cloudera/api/model/ApiMrUsageReportRow.java b/java/src/main/java/com/cloudera/api/model/ApiMrUsageReportRow.java index 5dd0d578..35770ea0 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiMrUsageReportRow.java +++ b/java/src/main/java/com/cloudera/api/model/ApiMrUsageReportRow.java @@ -23,11 +23,23 @@ public class ApiMrUsageReportRow { private String timePeriod; private String user; private String group; - private long cpuSec; - private long memoryBytes; - private long jobCount; - private long taskCount; - private long durationSec; + private Long cpuSec; + private Long memoryBytes; + private Long jobCount; + private Long taskCount; + private Long durationSec; + private Long failedMaps; + private Long totalMaps; + private Long failedReduces; + private Long totalReduces; + private Long mapInputBytes; + private Long mapOutputBytes; + private Long hdfsBytesRead; + private Long hdfsBytesWritten; + private Long localBytesRead; + private Long localBytesWritten; + private Long dataLocalMaps; + private Long rackLocalMaps; public ApiMrUsageReportRow() { } @@ -45,6 +57,28 @@ public ApiMrUsageReportRow(String timePeriod, String user, String group, this.durationSec = durationSec; } + public ApiMrUsageReportRow(String timePeriod, String user, String group, + long cpuSec, long memoryBytes, long jobCount, long taskCount, + long durationSec, long failedMaps, long totalMaps, long failedReduces, + long totalReduces, long mapInputBytes, long mapOutputBytes, + long hdfsBytesRead, long hdfsBytesWritten, long localBytesRead, + long localBytesWritten, long dataLocalMaps, long rackLocalMaps) { + this(timePeriod, user, group, cpuSec, memoryBytes, jobCount, taskCount, + durationSec); + this.failedMaps = failedMaps; + this.totalMaps = totalMaps; + this.failedReduces = failedReduces; + this.totalReduces = totalReduces; + this.mapInputBytes = mapInputBytes; + this.mapOutputBytes = mapOutputBytes; + this.hdfsBytesRead = hdfsBytesRead; + this.hdfsBytesWritten = hdfsBytesWritten; + this.localBytesRead = localBytesRead; + this.localBytesWritten = localBytesWritten; + this.dataLocalMaps = dataLocalMaps; + this.rackLocalMaps = rackLocalMaps; + } + /** * The time period over which this report is generated. */ @@ -86,7 +120,7 @@ public void setGroup(String group) { * jobs. */ @XmlElement - public long getCpuSec() { + public Long getCpuSec() { return cpuSec; } @@ -99,7 +133,7 @@ public void setCpuSec(long cpuSec) { * MapReduce jobs. */ @XmlElement - public long getMemoryBytes() { + public Long getMemoryBytes() { return memoryBytes; } @@ -111,7 +145,7 @@ public void setMemoryBytes(long memoryBytes) { * Number of jobs. */ @XmlElement - public long getJobCount() { + public Long getJobCount() { return jobCount; } @@ -123,7 +157,7 @@ public void setJobCount(long jobCount) { * Number of tasks. */ @XmlElement - public long getTaskCount() { + public Long getTaskCount() { return taskCount; } @@ -135,11 +169,167 @@ public void setTaskCount(long taskCount) { * Total duration of this user's MapReduce jobs. */ @XmlElement - public long getDurationSec() { + public Long getDurationSec() { return durationSec; } public void setDurationSec(long durationSec) { this.durationSec = durationSec; } + + /** + * Failed maps of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getFailedMaps() { + return failedMaps; + } + + public void setFailedMaps(long failedMaps) { + this.failedMaps = failedMaps; + } + + /** + * Total maps of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getTotalMaps() { + return totalMaps; + } + + public void setTotalMaps(long totalMaps) { + this.totalMaps = totalMaps; + } + + /** + * Failed reduces of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getFailedReduces() { + return failedReduces; + } + + public void setFailedReduces(long failedReduces) { + this.failedReduces = failedReduces; + } + + /** + * Total reduces of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getTotalReduces() { + return totalReduces; + } + + public void setTotalReduces(long totalReduces) { + this.totalReduces = totalReduces; + } + + /** + * Map input bytes of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getMapInputBytes() { + return mapInputBytes; + } + + public void setMapInputBytes(long mapInputBytes) { + this.mapInputBytes = mapInputBytes; + } + + /** + * Map output bytes of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getMapOutputBytes() { + return mapOutputBytes; + } + + public void setMapOutputBytes(long mapOutputBytes) { + this.mapOutputBytes = mapOutputBytes; + } + + /** + * HDFS bytes read of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getHdfsBytesRead() { + return hdfsBytesRead; + } + + public void setHdfsBytesRead(long hdfsBytesRead) { + this.hdfsBytesRead = hdfsBytesRead; + } + + /** + * HDFS bytes written of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getHdfsBytesWritten() { + return hdfsBytesWritten; + } + + public void setHdfsBytesWritten(long hdfsBytesWritten) { + this.hdfsBytesWritten = hdfsBytesWritten; + } + + /** + * Local bytes read of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getLocalBytesRead() { + return localBytesRead; + } + + public void setLocalBytesRead(long localBytesRead) { + this.localBytesRead = localBytesRead; + } + + /** + * Local bytes written of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getLocalBytesWritten() { + return localBytesWritten; + } + + public void setLocalBytesWritten(long localBytesWritten) { + this.localBytesWritten = localBytesWritten; + } + + /** + * Data local maps of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getDataLocalMaps() { + return dataLocalMaps; + } + + public void setDataLocalMaps(long dataLocalMaps) { + this.dataLocalMaps = dataLocalMaps; + } + + /** + * Rack local maps of this user's MapReduce jobs. + * Available since v11. + */ + @XmlElement + public Long getRackLocalMaps() { + return rackLocalMaps; + } + + public void setRackLocalMaps(long rackLocalMaps) { + this.rackLocalMaps = rackLocalMaps; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiProductVersion.java b/java/src/main/java/com/cloudera/api/model/ApiProductVersion.java new file mode 100644 index 00000000..0a537a85 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiProductVersion.java @@ -0,0 +1,53 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import javax.xml.bind.annotation.XmlRootElement; + +@JsonInclude(Include.NON_EMPTY) +@XmlRootElement(name = "productVersion") +public class ApiProductVersion { + /** + * Product version + */ + private String version; + + /** + * Product name + */ + private String product; + + public String getVersion() { + return this.version; + } + + public String getProduct() { + return this.product; + } + + public void setVersion(String version) { + this.version = version; + } + + public void setProduct(String product) { + this.product = product; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiReplicationDiagnosticsCollectionArgs.java b/java/src/main/java/com/cloudera/api/model/ApiReplicationDiagnosticsCollectionArgs.java new file mode 100644 index 00000000..3c31a366 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiReplicationDiagnosticsCollectionArgs.java @@ -0,0 +1,88 @@ +// Copyright (c) 2015 Cloudera, Inc. All rights reserved. +package com.cloudera.api.model; + +import com.google.common.base.Objects; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Optional arguments for diagnostics collection. + */ +@XmlRootElement(name = "replicationDiagnosticsCollectionArgs") +public class ApiReplicationDiagnosticsCollectionArgs { + private ApiCommandList commands; + private String ticketNumber; + private String comments; + private Boolean phoneHome; + + // For jackson/JAXB. + public ApiReplicationDiagnosticsCollectionArgs() { + } + + /** + * Commands to limit diagnostics to. + * By default, the most recent 10 commands on the schedule will be used. + */ + @XmlElement + public ApiCommandList getCommands() { + return commands; + } + + public void setCommands(ApiCommandList commands) { + this.commands = commands; + } + + /** + * Ticket number to which this bundle must be associated with. + */ + @XmlElement + public String getTicketNumber() { + return ticketNumber; + } + + public void setTicketNumber(String ticketNumber) { + this.ticketNumber = ticketNumber; + } + + /** + * Additional comments for the bundle. + */ + @XmlElement + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + /** + * Whether the diagnostics bundle must be uploaded to Cloudera. + */ + @XmlElement + public Boolean getPhoneHome() { + return phoneHome; + } + + public void setPhoneHome(Boolean phoneHome) { + this.phoneHome = phoneHome; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ApiReplicationDiagnosticsCollectionArgs that = (ApiReplicationDiagnosticsCollectionArgs) o; + return Objects.equal(this.commands, that.commands) && + Objects.equal(this.phoneHome, that.phoneHome) && + Objects.equal(this.comments, that.comments) && + Objects.equal(this.ticketNumber, that.ticketNumber); + } + + @Override + public int hashCode() { + return 31 * Objects.hashCode( + this.commands, this.phoneHome, this.comments, this.ticketNumber); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java b/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java index f8d925e9..e24b01a6 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java +++ b/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java @@ -42,6 +42,7 @@ public class ApiReplicationSchedule extends ApiSchedule { private ApiHdfsReplicationArguments hdfsArguments; private ApiHiveReplicationArguments hiveArguments; private List history; + private Boolean active; public ApiReplicationSchedule() { // For JAX-B. @@ -82,6 +83,19 @@ public void setHistory(List history) { this.history = history; } + /** + * Read-only field that is true if this schedule is currently active, false if not. + * Available since API v11. + */ + @XmlElement + public Boolean isActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + @Override public boolean equals(Object o) { if (!super.equals(o)) { diff --git a/java/src/main/java/com/cloudera/api/model/ApiReplicationScheduleDataLimits.java b/java/src/main/java/com/cloudera/api/model/ApiReplicationScheduleDataLimits.java new file mode 100644 index 00000000..e7cb026b --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiReplicationScheduleDataLimits.java @@ -0,0 +1,56 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.model; + +/** + * This class encapsulates the data limits that we want to put on ApiReplicationSchedule to + * avoid potential OOME. It is currently used when archiving replication history. + * Available since v11. + */ +public class ApiReplicationScheduleDataLimits { + private final int maxCommandsPerSchedule; + private final int maxTablesPerResult; + private final int maxErrorsPerResult; + + public ApiReplicationScheduleDataLimits(int maxCommandsPerSchedule, int maxTablesPerResult, + int maxErrorsPerResult) { + this.maxCommandsPerSchedule = maxCommandsPerSchedule; + this.maxTablesPerResult = maxTablesPerResult; + this.maxErrorsPerResult = maxErrorsPerResult; + } + + /** + * @return Max number of ApiReplicationCommands per ApiReplicationSchedule. + */ + public int getMaxCommandsPerSchedule() { + return maxCommandsPerSchedule; + } + + /** + * @return Max number of ApiHiveTable per ApiHiveReplicationResult. + */ + public int getMaxTablesPerResult() { + return maxTablesPerResult; + } + + /** + * @return Max number of ApiHiveReplicationError per ApiHiveReplicationResult. + */ + public int getMaxErrorsPerResult() { + return maxErrorsPerResult; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiRestartClusterArgs.java b/java/src/main/java/com/cloudera/api/model/ApiRestartClusterArgs.java index 03dd7c99..cc5f8e36 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiRestartClusterArgs.java +++ b/java/src/main/java/com/cloudera/api/model/ApiRestartClusterArgs.java @@ -15,6 +15,8 @@ // limitations under the License. package com.cloudera.api.model; +import java.util.List; + import com.cloudera.api.ApiUtils; import com.google.common.base.Objects; @@ -23,12 +25,18 @@ /** * Arguments used for Cluster Restart command. + * + * Since V11: + * If both restartOnlyStaleServices and restartServiceNames are specified, + * a service must be specified in restartServiceNames and also be stale, + * in order to be restarted. */ @XmlRootElement(name="restartClusterArgs") public class ApiRestartClusterArgs { private Boolean restartOnlyStaleServices; private Boolean redeployClientConfiguration; + private List restartServiceNames; /** * Only restart services that have stale configuration and their dependent @@ -55,11 +63,25 @@ public void setRedeployClientConfiguration(Boolean redeployClientConfiguration) this.redeployClientConfiguration = redeployClientConfiguration; } + /** + * Only restart services that are specified and their dependent services. + * Available since V11. + */ + @XmlElement + public List getRestartServiceNames() { + return restartServiceNames; + } + + public void setRestartServiceNames(List restartServiceNames) { + this.restartServiceNames = restartServiceNames; + } + @Override public String toString() { return Objects.toStringHelper(this) .add("restartOnlyStaleServices", restartOnlyStaleServices) .add("redeployClientConfiguration", redeployClientConfiguration) + .add("restartServiceNames", restartServiceNames) .toString(); } @@ -68,11 +90,13 @@ public boolean equals(Object o) { ApiRestartClusterArgs other = ApiUtils.baseEquals(this, o); return this == other || (other != null && Objects.equal(restartOnlyStaleServices, other.restartOnlyStaleServices)) && - Objects.equal(redeployClientConfiguration, other.redeployClientConfiguration); + Objects.equal(redeployClientConfiguration, other.redeployClientConfiguration) && + Objects.equal(restartServiceNames, other.restartServiceNames); } @Override public int hashCode() { - return Objects.hashCode(restartOnlyStaleServices, redeployClientConfiguration); + return Objects.hashCode(restartOnlyStaleServices, redeployClientConfiguration, + restartServiceNames); } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiRole.java b/java/src/main/java/com/cloudera/api/model/ApiRole.java index baf33c23..0ef0f14c 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiRole.java +++ b/java/src/main/java/com/cloudera/api/model/ApiRole.java @@ -52,6 +52,7 @@ public class ApiRole { private ApiConfigList config; private ApiRoleConfigGroupRef roleConfigGroupRef; private ZooKeeperServerMode zooKeeperServerMode; + private ApiEntityStatus entityStatus; public enum HaStatus { ACTIVE, @@ -93,6 +94,7 @@ public ApiRole() { // For JAX-B } + @Override public String toString() { return Objects.toStringHelper(this) .add("name", name) @@ -340,4 +342,17 @@ public ZooKeeperServerMode getZooKeeperServerMode() { public void setZooKeeperServerMode(ZooKeeperServerMode zooKeeperServerMode) { this.zooKeeperServerMode = zooKeeperServerMode; } + + /** + * Readonly. The entity status for this role. + * Available since API v11. + */ + @XmlElement + public ApiEntityStatus getEntityStatus() { + return entityStatus; + } + + public void setEntityStatus(ApiEntityStatus entityStatus) { + this.entityStatus = entityStatus; + } } \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiService.java b/java/src/main/java/com/cloudera/api/model/ApiService.java index 3e617a74..1152942b 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiService.java +++ b/java/src/main/java/com/cloudera/api/model/ApiService.java @@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; + import java.util.List; /** @@ -46,6 +47,7 @@ public class ApiService { private String type; private ApiClusterRef clusterRef; private String serviceUrl; + private String roleInstancesUrl; private ApiServiceState serviceState; private ApiHealthSummary healthSummary; private List healthChecks; @@ -60,11 +62,13 @@ public class ApiService { private List roleConfigGroups; private List replicationSchedules; private List snapshotPolicies; + private ApiEntityStatus entityStatus; public ApiService() { // For JAX-B } + @Override public String toString() { return Objects.toStringHelper(this) .add("name", name) @@ -211,8 +215,7 @@ public void setHealthChecks(List healthChecks) { } /** - * Readonly. - * Link into the Cloudera Manager web UI for this specific service. + * Readonly. Link into the Cloudera Manager web UI for this specific service. */ @XmlElement public String getServiceUrl() { @@ -223,6 +226,20 @@ public void setServiceUrl(String serviceUrl) { this.serviceUrl = serviceUrl; } + /** + * Readonly. Link into the Cloudera Manager web UI for role instances table for + * this specific service. + * Available since API v11. + */ + @XmlElement + public String getRoleInstancesUrl() { + return roleInstancesUrl; + } + + public void setRoleInstancesUrl(String roleInstancesUrl) { + this.roleInstancesUrl = roleInstancesUrl; + } + /** * Readonly. Whether the service is in maintenance mode. * Available since API v2. @@ -321,4 +338,17 @@ public List getSnapshotPolicies() { public void setSnapshotPolicies(List snapshotPolicies) { this.snapshotPolicies = snapshotPolicies; } + + /** + * Readonly. The entity status for this service. + * Available since API v11. + */ + @XmlElement + public ApiEntityStatus getEntityStatus() { + return entityStatus; + } + + public void setEntityStatus(ApiEntityStatus entityStatus) { + this.entityStatus = entityStatus; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiSnapshotPolicy.java b/java/src/main/java/com/cloudera/api/model/ApiSnapshotPolicy.java index 4108d073..6030912f 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiSnapshotPolicy.java +++ b/java/src/main/java/com/cloudera/api/model/ApiSnapshotPolicy.java @@ -58,6 +58,7 @@ public class ApiSnapshotPolicy { private boolean alertOnSuccess; private boolean alertOnFail; private boolean alertOnAbort; + private Boolean paused; private ApiHBaseSnapshotPolicyArguments hbaseArguments; private ApiHdfsSnapshotPolicyArguments hdfsArguments; @@ -340,6 +341,16 @@ public void setLastSuccessfulCommand(ApiSnapshotCommand lastSuccessfulCommand) { this.lastSuccessfulCommand = lastSuccessfulCommand; } + /** Whether to pause a snapshot policy, available since V11. */ + @XmlElement + public Boolean getPaused() { + return paused; + } + + public void setPaused(Boolean paused) { + this.paused = paused; + } + @Override public String toString() { return Objects.toStringHelper(this) @@ -364,6 +375,7 @@ public String toString() { .add("hdfsArguments", hdfsArguments) .add("lastCommand", lastCommand) .add("lastSuccessfulCommand", lastSuccessfulCommand) + .add("paused", paused) .toString(); } @@ -392,7 +404,8 @@ public boolean equals(Object o) { Objects.equal(hbaseArguments, other.getHBaseArguments()) && Objects.equal(hdfsArguments, other.getHdfsArguments()) && Objects.equal(lastCommand, other.lastCommand) && - Objects.equal(lastSuccessfulCommand, other.lastSuccessfulCommand); + Objects.equal(lastSuccessfulCommand, other.lastSuccessfulCommand) && + Objects.equal(paused, other.paused); } @Override @@ -401,6 +414,7 @@ public int hashCode() { weeklySnapshots, monthlySnapshots, yearlySnapshots, minuteOfHour, hourOfDay, dayOfWeek, dayOfMonth, monthOfYear, hoursForHourlySnapshots, alertOnStart, alertOnSuccess, alertOnFail, alertOnAbort, - hbaseArguments, hdfsArguments, lastCommand, lastSuccessfulCommand); + hbaseArguments, hdfsArguments, lastCommand, lastSuccessfulCommand, + paused); } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesCrossEntityMetadata.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesCrossEntityMetadata.java index ead1cc18..8d8b0dac 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesCrossEntityMetadata.java +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesCrossEntityMetadata.java @@ -26,7 +26,9 @@ public class ApiTimeSeriesCrossEntityMetadata { private String maxEntityDisplayName; + private String maxEntityName; private String minEntityDisplayName; + private String minEntityName; private Double numEntities; /** @@ -42,6 +44,21 @@ public void setMaxEntityDisplayName(String maxEntityDisplayName) { this.maxEntityDisplayName = maxEntityDisplayName; } + /** + * The name of the entity that had the maximum value for the + * cross-entity aggregate metric. + *

+ * Available since API v11. + */ + @XmlElement + public String getMaxEntityName() { + return maxEntityName; + } + + public void setMaxEntityName(String maxEntityName) { + this.maxEntityName = maxEntityName; + } + /** * The display name of the entity that had the minimum value for the * cross-entity aggregate metric. @@ -55,6 +72,21 @@ public void setMinEntityDisplayName(String minEntityDisplayName) { this.minEntityDisplayName = minEntityDisplayName; } + /** + * The name of the entity that had the minimum value for the + * cross-entity aggregate metric. + *

+ * Available since API v11. + */ + @XmlElement + public String getMinEntityName() { + return minEntityName; + } + + public void setMinEntityName(String minEntityName) { + this.minEntityName = minEntityName; + } + /** * The number of entities covered by this point. For a raw cross-entity point * this number is exact. For a rollup point this number is an average, since diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttribute.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttribute.java new file mode 100644 index 00000000..2f1e9afb --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttribute.java @@ -0,0 +1,97 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A time series entity attribute represents a possible attribute of a time + * series entity type monitored by the Cloudera Management Services. + *

+ * Available since API v11. + */ +@XmlRootElement(name = "timeSeriesEntityAttribute") +public class ApiTimeSeriesEntityAttribute { + private String name; + private String displayName; + private String description; + private boolean isValueCaseSensitive; + + public ApiTimeSeriesEntityAttribute() { + // For JAX-B + } + + public ApiTimeSeriesEntityAttribute( + String name, + String displayName, + String description, + boolean isValueCaseSensitive) { + this.name = name; + this.displayName = displayName; + this.description = description; + this.isValueCaseSensitive = isValueCaseSensitive; + } + + /** + * Name of the of the attribute. + * This name uniquely identifies this attribute. + **/ + @XmlElement + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Display name of the attribute. + **/ + @XmlElement + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Description of the attribute. + **/ + @XmlElement + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns whether to treat attribute values as case-sensitive. + **/ + @XmlElement + public boolean getIsValueCaseSensitive() { + return isValueCaseSensitive; + } + + public void setIsValueCaseSensitive(boolean isValueCaseSensitive) { + this.isValueCaseSensitive = isValueCaseSensitive; + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttributeList.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttributeList.java new file mode 100644 index 00000000..24973a77 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityAttributeList.java @@ -0,0 +1,46 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A list of ApiTimeSeriesEntityAttribute objects + */ +@XmlRootElement(name = "timeSeriesEntityAttributeList") +public class ApiTimeSeriesEntityAttributeList extends + ApiListBase { + public ApiTimeSeriesEntityAttributeList() { + // For JAX-B + } + + public ApiTimeSeriesEntityAttributeList(List attrs) { + super(attrs); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getMetricEntityTypeAttributes() { + return values; + } + + public void setMetricEntityTypeAttributes( + List values) { + this.values = values; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityType.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityType.java new file mode 100644 index 00000000..6ed2db92 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityType.java @@ -0,0 +1,184 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Describe a time series entity type and attributes associated with + * this entity type. + *

+ * Available since API v11. + */ +@XmlRootElement(name = "timeSeriesEntityType") +public class ApiTimeSeriesEntityType { + private String name; + private String category; + private String nameForCrossEntityAggregateMetrics; + private String displayName; + private String description; + private List immutableAttributeNames; + private List mutableAttributeNames; + private List entityNameFormat; + private String entityDisplayNameFormat; + private List parentMetricEntityTypeNames; + + public ApiTimeSeriesEntityType() { + // For JAX-B + } + + /** + * Returns the name of the entity type. This name uniquely identifies this + * entity type. + */ + @XmlElement + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Returns the category of the entity type. + */ + @XmlElement + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + /** + * Returns the string to use to pluralize the name of the entity for cross + * entity aggregate metrics. + */ + @XmlElement + public String getNameForCrossEntityAggregateMetrics() { + return nameForCrossEntityAggregateMetrics; + } + + public void setNameForCrossEntityAggregateMetrics(String value) { + this.nameForCrossEntityAggregateMetrics = value; + } + + /** + * Returns the display name of the entity type. + */ + @XmlElement + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Returns the description of the entity type. + */ + @XmlElement + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the list of immutable attributes for this entity type. Immutable + * attributes values for an entity may not change over its lifetime. + */ + @XmlElement + public List getImmutableAttributeNames() { + return immutableAttributeNames; + } + + public void setImmutableAttributeNames(List value) { + this.immutableAttributeNames = value; + } + + /** + * Returns the list of mutable attributes for this entity type. Mutable + * attributes for an entity may change over its lifetime. + */ + @XmlElement + public List getMutableAttributeNames() { + return mutableAttributeNames; + } + + public void setMutableAttributeNames(List value) { + this.mutableAttributeNames = value; + } + + /** + * Returns a list of attribute names that will be used to construct entity + * names for entities of this type. The attributes named here must be immutable + * attributes of this type or a parent type. + */ + @XmlElement + public List getEntityNameFormat() { + return entityNameFormat; + } + + public void setEntityNameFormat(List value) { + this.entityNameFormat = value; + } + + /** + * Returns a format string that will be used to construct the display name of + * entities of this type. If this returns null the entity name would be used + * as the display name. + * + * The entity attribute values are used to replace $attribute name portions of + * this format string. For example, an entity with roleType "DATANODE" and + * hostname "foo.com" will have a display name "DATANODE (foo.com)" if the + * format is "$roleType ($hostname)". + */ + @XmlElement + public String getEntityDisplayNameFormat() { + return entityDisplayNameFormat; + } + + public void setEntityDisplayNameFormat(String entityDisplayNameFormat) { + this.entityDisplayNameFormat = entityDisplayNameFormat; + } + + /** + * Returns a list of metric entity type names which are parents of this + * metric entity type. A metric entity type inherits the attributes of + * its ancestors. For example a role metric entity type has its service as a + * parent. A service metric entity type has a cluster as a parent. The role + * type inherits its cluster name attribute through its service parent. Only + * parent ancestors should be returned here. In the example given, only the + * service metric entity type should be specified in the parent list. + */ + @XmlElement + public List getParentMetricEntityTypeNames() { + return parentMetricEntityTypeNames; + } + + public void setParentMetricEntityTypeNames(List value) { + this.parentMetricEntityTypeNames = value; + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityTypeList.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityTypeList.java new file mode 100644 index 00000000..36dc3e01 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesEntityTypeList.java @@ -0,0 +1,44 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A list of ApiTimeSeriesEntityType objects + */ +@XmlRootElement(name = "timeSeriesEntityTypeList") +public class ApiTimeSeriesEntityTypeList extends ApiListBase { + public ApiTimeSeriesEntityTypeList() { + // For JAX-B + } + + public ApiTimeSeriesEntityTypeList(List attrs) { + super(attrs); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getMetricEntityTypes() { + return values; + } + + public void setMetricEntityTypes(List values) { + this.values = values; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesRequest.java b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesRequest.java new file mode 100644 index 00000000..ada9e9dc --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiTimeSeriesRequest.java @@ -0,0 +1,188 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import static com.cloudera.api.Parameters.ROLLUP_DEFAULT; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import javax.ws.rs.core.MediaType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Request object containing information needed for querying timeseries data. + * + * Available since API v11. + */ +@XmlRootElement(name = "timeSeriesQuery") +public class ApiTimeSeriesRequest { + + String query; + String from; + String to; + String contentType; + String desiredRollup; + Boolean mustUseDesiredRollup; + + public ApiTimeSeriesRequest(String query, String from, String to) { + this(query, + from, + to, + MediaType.APPLICATION_JSON, + ROLLUP_DEFAULT, + false); + } + + public ApiTimeSeriesRequest( + String query, + String from, + String to, + String contentType, + String desiredRollup, + Boolean mustUseDesiredRollup) { + this.query = query; + this.from = from; + this.to = to; + this.contentType = contentType; + this.desiredRollup = desiredRollup; + this.mustUseDesiredRollup = mustUseDesiredRollup; + } + + public ApiTimeSeriesRequest() { + this.contentType = MediaType.APPLICATION_JSON; + this.desiredRollup = ROLLUP_DEFAULT; + this.mustUseDesiredRollup = false; + } + + /** + * tsquery to run against the CM time-series data store. + * Please see the + * tsquery language documentation.

+ */ + @XmlElement + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** + * Start of the period to query in ISO 8601 format (defaults to 5 minutes + * before the end of the period). + */ + @XmlElement + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + /** + * End of the period to query in ISO 8601 format (defaults to current time). + */ + @XmlElement + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + /** + * contentType to return the response in. The content types "application/json" + * and "text/csv" are supported. This defaults to "application/json". If + * "text/csv" is specified then we return one row per time series data point, + * and we don't return any of the metadata. + */ + @XmlElement + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * Aggregate rollup level desired for the response data. + * Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. + * Note that if the mustUseDesiredRollup parameter is not set, then the + * monitoring server can decide to return a different rollup level. + */ + @XmlElement + public String getDesiredRollup() { + return desiredRollup; + } + + public void setDesiredRollup(String desiredRollup) { + this.desiredRollup = desiredRollup; + } + + /** + * If set to true, then the tsquery will return data with the desired + * aggregate rollup level. + */ + @XmlElement + public Boolean getMustUseDesiredRollup() { + return mustUseDesiredRollup; + } + + public void setMustUseDesiredRollup(Boolean mustUseDesiredRollup) { + this.mustUseDesiredRollup = mustUseDesiredRollup; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("query", query) + .add("from", from) + .add("to", to) + .add("contentType", contentType) + .add("desiredRollup", desiredRollup) + .add("mustUseDesiredRollup", mustUseDesiredRollup) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiTimeSeriesRequest other = ApiUtils.baseEquals(this, o); + return this == other || (other != null && + Objects.equal(query, other.getQuery()) && + Objects.equal(from, other.getFrom()) && + Objects.equal(to, other.getTo()) && + Objects.equal(contentType, other.getContentType()) && + Objects.equal(desiredRollup, other.getDesiredRollup()) && + Objects.equal(mustUseDesiredRollup, other.getMustUseDesiredRollup())); + } + + @Override + public int hashCode() { + return Objects.hashCode( + query, + from, + to, + contentType, + desiredRollup, + mustUseDesiredRollup); + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiUser.java b/java/src/main/java/com/cloudera/api/model/ApiUser.java index 6cc4874a..9cddad19 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiUser.java +++ b/java/src/main/java/com/cloudera/api/model/ApiUser.java @@ -121,6 +121,7 @@ public void setPassword(String password) { *

  • ROLE_BDR_ADMIN: Added in Cloudera Manager 5.2
  • *
  • ROLE_NAVIGATOR_ADMIN: Added in Cloudera Manager 5.2
  • *
  • ROLE_USER_ADMIN: Added in Cloudera Manager 5.2
  • + *
  • ROLE_KEY_ADMIN: Added in Cloudera Manager 5.5
  • * * An empty list implies ROLE_USER. *

    diff --git a/java/src/main/java/com/cloudera/api/model/ApiUserSession.java b/java/src/main/java/com/cloudera/api/model/ApiUserSession.java new file mode 100644 index 00000000..7b65755f --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiUserSession.java @@ -0,0 +1,112 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * This is the model for interactive user session information in the API. + *

    + * A user may have more than one active session. Each such session will have + * its own session object. + */ +@XmlRootElement(name = "userSession") +public class ApiUserSession { + + private String name; + private String remoteAddr; + private Date lastRequest; + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("name", name) + .add("remoteAddr", remoteAddr) + .add("expiration", lastRequest.toString()) + .toString(); + } + + public boolean equals(Object o) { + ApiUserSession other = ApiUtils.baseEquals(this, o); + return this == other || (other != null && + Objects.equal(name, other.getName()) && + Objects.equal(remoteAddr, other.getRemoteAddr()) && + Objects.equal(lastRequest, other.getLastRequest())); + } + + public int hashCode() { + return Objects.hashCode(name, remoteAddr, lastRequest); + } + + /** + * The username associated with the session. + *

    + * This will be the same value shown to the logged in user in the UI, which + * will normally be the same value they typed when logging in, but it is + * possible that in certain external authentication scenarios, it will differ + * from that value. + * + * @return the username + * */ + @XmlElement + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * The remote IP address for the session. + *

    + * This will be the remote IP address for the last request made as part of + * this session. It is not guaranteed to be the same IP address as was + * previously used, or the address used to initiate the session. + * + * @return The remote IP address. + */ + @XmlElement + public String getRemoteAddr() { + return remoteAddr; + } + + public void setRemoteAddr(String remoteAddr) { + this.remoteAddr = remoteAddr; + } + + /** + * The date and time of the last request received as part of this session. + *

    + * This will be returned in ISO 8601 format from the REST API. + * + * @return The date/time. + */ + @XmlElement + public Date getLastRequest() { + return lastRequest; + } + + public void setLastRequest(Date lastRequest) { + this.lastRequest = lastRequest; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiUserSessionList.java b/java/src/main/java/com/cloudera/api/model/ApiUserSessionList.java new file mode 100644 index 00000000..aeecbc46 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiUserSessionList.java @@ -0,0 +1,45 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +/** + * A list of user sessions. + */ +@XmlRootElement(name = "userSessionList") +public class ApiUserSessionList extends ApiListBase { + + public ApiUserSessionList() { + // For JAX-B + } + + public ApiUserSessionList(List users) { + super(users); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getUserSessions() { + return values; + } + + public void setUserSessions(List values) { + this.values = values; + } + +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java b/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java index 885d31e6..81f29ac5 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java +++ b/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java @@ -15,15 +15,16 @@ // limitations under the License. package com.cloudera.api.model; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; + import java.util.Date; +import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; - /** * Represents a Yarn application */ @@ -31,6 +32,8 @@ public class ApiYarnApplication { private String applicationId; + + private String name; private Date startTime; private Date endTime; @@ -40,6 +43,18 @@ public class ApiYarnApplication { private Double progress; private ApiMr2AppInformation mr2AppInfo; private Map attributes; + private List applicationTags; + private Long allocatedMemorySeconds; + private Long allocatedVcoreSeconds; + private Integer allocatedMB; + private Integer allocatedVCores; + private Integer runningContainers; + + private Double containerUsedMemorySeconds; + private Double containerUsedCpuSeconds; + private Double containerUsedVcoreSeconds; + private Double containerAllocatedMemorySeconds; + private Double containerAllocatedVcoreSeconds; public ApiYarnApplication() { // For JAX-B @@ -55,7 +70,18 @@ public ApiYarnApplication( String state, Double progress, ApiMr2AppInformation mr2AppInfo, - Map attributes) { + Map attributes, + List applicationTags, + Long allocatedMemorySeconds, + Long allocatedVcoreSeconds, + Integer allocatedMB, + Integer allocatedVCores, + Integer runningContainers, + Double containerUsedMemorySeconds, + Double containerUsedCpuSeconds, + Double containerUsedVcoreSeconds, + Double containerAllocatedMemorySeconds, + Double containerAllocatedVcoreSeconds) { Preconditions.checkNotNull(applicationId); Preconditions.checkNotNull(name); Preconditions.checkNotNull(startTime); @@ -71,6 +97,89 @@ public ApiYarnApplication( this.progress = progress; this.attributes = attributes; this.mr2AppInfo = mr2AppInfo; + this.applicationTags = applicationTags; + this.allocatedMemorySeconds = allocatedMemorySeconds; + this.allocatedVcoreSeconds = allocatedVcoreSeconds; + this.allocatedMB = allocatedMB; + this.allocatedVCores = allocatedVCores; + this.runningContainers = runningContainers; + this.containerUsedMemorySeconds = containerUsedMemorySeconds; + this.containerUsedCpuSeconds = containerUsedCpuSeconds; + this.containerUsedVcoreSeconds = containerUsedVcoreSeconds; + this.containerAllocatedMemorySeconds = containerAllocatedMemorySeconds; + this.containerAllocatedVcoreSeconds = containerAllocatedVcoreSeconds; + } + + /** + The sum of memory in MB allocated to the application's running containers + Available since v12. + */ + @XmlElement + public Integer getAllocatedMB() { + return allocatedMB; + } + + public void setAllocatedMB(Integer allocatedMB) { + this.allocatedMB = allocatedMB; + } + + /** + The sum of virtual cores allocated to the application's running containers + Available since v12. + */ + @XmlElement + public Integer getAllocatedVCores() { + return allocatedVCores; + } + + public void setAllocatedVCores(Integer allocatedVCores) { + this.allocatedVCores = allocatedVCores; + } + + /** + The number of containers currently running for the application + Available since v12. + */ + @XmlElement + public Integer getRunningContainers() { + return runningContainers; + } + + public void setRunningContainers(Integer runningContainers) { + this.runningContainers = runningContainers; + } + + /** List of YARN application tags. Available since v12. */ + @XmlElement + public List getApplicationTags() { + return applicationTags; + } + + public void setApplicationTags(List applicationTags) { + this.applicationTags = applicationTags; + } + + /** + Allocated memory to the application in units of mb-secs. + Available since v12. + */ + @XmlElement + public Long getAllocatedMemorySeconds() { + return allocatedMemorySeconds; + } + + public void setAllocatedMemorySeconds(Long allocatedMemorySeconds) { + this.allocatedMemorySeconds = allocatedMemorySeconds; + } + + /** Allocated vcore-secs to the application. Available since v12. */ + @XmlElement + public Long getAllocatedVcoreSeconds() { + return allocatedVcoreSeconds; + } + + public void setAllocatedVcoreSeconds(Long allocatedVcoreSeconds) { + this.allocatedVcoreSeconds = allocatedVcoreSeconds; } /** The application id. */ @@ -179,6 +288,83 @@ public void setState(String state) { this.state = state; } + /** + * Actual memory (in MB-secs) used by containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics. + * Available since v12. + */ + @XmlElement + public Double getContainerUsedMemorySeconds() { + return containerUsedMemorySeconds; + } + + public void setContainerUsedMemorySeconds(Double containerUsedMemorySeconds) { + this.containerUsedMemorySeconds = containerUsedMemorySeconds; + } + + /** + * Actual CPU (in percent-secs) used by containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics. + * Available since v12. + */ + @XmlElement + public Double getContainerUsedCpuSeconds() { + return containerUsedCpuSeconds; + } + + public void setContainerUsedCpuSeconds(Double containerUsedCpuSeconds) { + this.containerUsedCpuSeconds = containerUsedCpuSeconds; + } + + /** + * Actual VCore-secs used by containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics. + * Available since v12. + */ + @XmlElement + public Double getContainerUsedVcoreSeconds() { + return containerUsedVcoreSeconds; + } + + public void setContainerUsedVcoreSeconds(Double containerUsedVcoreSeconds) { + this.containerUsedVcoreSeconds = containerUsedVcoreSeconds; + } + + /** + * Total memory (in mb-secs) allocated to containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics. + * Available since v12. + */ + @XmlElement + public Double getContainerAllocatedMemorySeconds() { + return containerAllocatedMemorySeconds; + } + + public void setContainerAllocatedMemorySeconds( + Double containerAllocatedMemorySeconds) { + this.containerAllocatedMemorySeconds = containerAllocatedMemorySeconds; + } + + /** + * Total vcore-secs allocated to containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics. + * Available since v12. + */ + @XmlElement + public Double getContainerAllocatedVcoreSeconds() { + return containerAllocatedVcoreSeconds; + } + + public void setContainerAllocatedVcoreSeconds( + Double containerAllocatedVcoreSeconds) { + this.containerAllocatedVcoreSeconds = containerAllocatedVcoreSeconds; + } + @Override public String toString() { return Objects.toStringHelper(this) @@ -191,6 +377,17 @@ public String toString() { .add("progress", progress) .add("attributes", attributes) .add("mr2AppInfo", mr2AppInfo) + .add("applicationTags", applicationTags) + .add("allocatedMemorySeconds", allocatedMemorySeconds) + .add("allocatedVcoreSeconds", allocatedVcoreSeconds) + .add("allocatedMB", allocatedMB) + .add("allocatedVCores", allocatedVCores) + .add("runningContainers", runningContainers) + .add("containerUsedMemorySeconds", containerUsedMemorySeconds) + .add("containerUsedCpuSeconds", containerUsedCpuSeconds) + .add("containerUsedVcoreSeconds", containerUsedVcoreSeconds) + .add("containerAllocatedMemorySeconds", containerAllocatedMemorySeconds) + .add("containerAllocatedVcoreSeconds", containerAllocatedVcoreSeconds) .toString(); } } diff --git a/java/src/main/java/com/cloudera/api/v1/MgmtServiceResource.java b/java/src/main/java/com/cloudera/api/v1/MgmtServiceResource.java index 84f09e8d..2ed84cbe 100644 --- a/java/src/main/java/com/cloudera/api/v1/MgmtServiceResource.java +++ b/java/src/main/java/com/cloudera/api/v1/MgmtServiceResource.java @@ -42,6 +42,7 @@ public interface MgmtServiceResource { /** * Retrieve information about the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @return Details about the management service. */ @GET @@ -51,6 +52,7 @@ public interface MgmtServiceResource { /** * Retrieve the configuration of the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @param dataView The view of the data to materialize, * either "summary" or "full". * @return List with configured and available configuration options. @@ -72,6 +74,7 @@ public ApiServiceConfig readServiceConfig( * Attributes that are not listed in the input will maintain their * current values in the configuration. * + * @throws javax.ws.rs.ClientErrorException if no service exists. * @param message Optional message describing the changes. * @param config Configuration changes. * @return The new service configuration. @@ -85,6 +88,7 @@ public ApiServiceConfig updateServiceConfig( /** * List the supported role types for the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @return List of role types the service supports. */ @GET @@ -94,6 +98,7 @@ public ApiServiceConfig updateServiceConfig( /** * List active Cloudera Management Services commands. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @param dataView The view of the data to materialize, * either "summary" or "full". * @return A list of active role commands. @@ -107,6 +112,7 @@ public ApiCommandList listActiveCommands( /** * Start the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @return A reference to the submitted command. */ @POST @@ -117,6 +123,7 @@ public ApiCommandList listActiveCommands( /** * Stop the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @return A reference to the submitted command. */ @POST @@ -127,6 +134,7 @@ public ApiCommandList listActiveCommands( /** * Restart the Cloudera Management Services. * + * @throws javax.ws.rs.NotFoundException if no service exists. * @return A reference to the submitted command. */ @POST diff --git a/java/src/main/java/com/cloudera/api/v10/AuditsResourceV10.java b/java/src/main/java/com/cloudera/api/v10/AuditsResourceV10.java index 4b30c50b..02b6a140 100644 --- a/java/src/main/java/com/cloudera/api/v10/AuditsResourceV10.java +++ b/java/src/main/java/com/cloudera/api/v10/AuditsResourceV10.java @@ -31,9 +31,10 @@ * * @param maxResults Maximum number of audits to return * @param resultOffset Offset of audits to return - * @param startTime Start of the period to query (defaults to 1 day ago - * relative to endTime) - * @param endTime End of the period to query (defaults to current time) + * @param startTime Start of the period to query in ISO 8601 format (defaults + * to 1 day ago relative to endTime). + * @param endTime End of the period to query in ISO 8601 format. (defaults to + * current time). * @param query * The query to filter out audits in the system. It accepts * querying the intersection of a list of constraints, diff --git a/java/src/main/java/com/cloudera/api/v11/ClouderaManagerResourceV11.java b/java/src/main/java/com/cloudera/api/v11/ClouderaManagerResourceV11.java new file mode 100644 index 00000000..25a5426f --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/ClouderaManagerResourceV11.java @@ -0,0 +1,35 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import com.cloudera.api.v8.ClouderaManagerResourceV8; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public interface ClouderaManagerResourceV11 extends ClouderaManagerResourceV8 { + + /** + * Only available with Cloudera Manager Enterprise Edition. + */ + @Override + @Path("/peers") + public CmPeersResourceV11 getCmPeersResource(); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v11/ClustersResourceV11.java b/java/src/main/java/com/cloudera/api/v11/ClustersResourceV11.java new file mode 100644 index 00000000..a213fd29 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/ClustersResourceV11.java @@ -0,0 +1,60 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.CLUSTER_NAME; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.model.ApiConfigureForKerberosArguments; +import com.cloudera.api.v10.ClustersResourceV10; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV11 extends ClustersResourceV10 { + + /** + * Command to configure the cluster to use Kerberos for authentication. + * + * This command will configure all relevant services on a cluster for + * Kerberos usage. This command will trigger a GenerateCredentials command + * to create Kerberos keytabs for all roles in the cluster. + * + * @param clusterName The name of the cluster. + * @param args Arguments for the configure for kerberos command. + * @return Information about the submitted command. + */ + @POST + @Consumes + @Path("/{clusterName}/commands/configureForKerberos") + public ApiCommand configureForKerberos( + @PathParam(CLUSTER_NAME) String clusterName, + ApiConfigureForKerberosArguments args); + + /** + * @return The services resource handler. + */ + @Override + @Path("/{clusterName}/services") + public ServicesResourceV11 getServicesResource( + @PathParam(CLUSTER_NAME) String clusterName); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v11/CmPeersResourceV11.java b/java/src/main/java/com/cloudera/api/v11/CmPeersResourceV11.java new file mode 100644 index 00000000..24137b6b --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/CmPeersResourceV11.java @@ -0,0 +1,91 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.PEER_NAME; +import static com.cloudera.api.Parameters.PEER_TYPE; + +import com.cloudera.api.model.ApiCmPeer; +import com.cloudera.api.model.ApiCmPeerType; +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v3.CmPeersResource; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface CmPeersResourceV11 extends CmPeersResource { + /** + * Fetch information about an existing Cloudera Manager peer. + *

    + * Available since API v11. Only available with Cloudera Manager Enterprise + * Edition. + * + * @param peerName Name of peer to retrieve. + * @param peerType Type of peer to retrieve. If null, REPLICATION peer type + * will be returned. + * @return Peer information. + */ + @GET + @Path("/{peerName}") + public ApiCmPeer readPeer(@PathParam(PEER_NAME) String peerName, + @QueryParam(PEER_TYPE) ApiCmPeerType peerType); + + /** + * Delete Cloudera Manager peer. + *

    + * An attempt will be made to contact the peer server, so that the configured + * user can be deleted.. Errors while contacting the remote server are + * non-fatal. + *

    + * Available since API v11. Only available with Cloudera Manager Enterprise + * Edition. + * + * @param peerName Name of peer to delete. + * @param peerType Type of peer to delete. If null, REPLICATION peer type will + * be deleted. + * @return Information about the deleted peer. + */ + @DELETE + @Path("/{peerName}") + public ApiCmPeer deletePeer(@PathParam(PEER_NAME) String peerName, + @QueryParam(PEER_TYPE) ApiCmPeerType peerType); + + /** + * Test the connectivity of a peer. + *

    + * Available since API v11. Only available with Cloudera Manager Enterprise + * Edition. + * + * @param peerName Name of peer to test. + * @param peerType Type of peer to test. If null, REPLICATION peer type will + * be tested. + * @return Information about the submitted command. + */ + @POST + @Consumes + @Path("/{peerName}/commands/test") + public ApiCommand testPeer(@PathParam(PEER_NAME) String peerName, + @QueryParam(PEER_TYPE) ApiCmPeerType peerType); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java b/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java new file mode 100644 index 00000000..c6a78c1e --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java @@ -0,0 +1,38 @@ +// Copyright (c) 2015 Cloudera, Inc. All rights reserved. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.COMMAND_ID; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v1.CommandsResource; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + + +@Produces({ MediaType.APPLICATION_JSON }) +@Consumes({ MediaType.APPLICATION_JSON }) +public interface CommandsResourceV11 extends CommandsResource { + + /** + * Try to rerun a command. + * + *

    + * Note: Only command that supports retry is UpgradeCluster. + * {@link ApiCommand#isCanRetry()} will be true for only + * UpgradeCluster command. + *

    + * + * @param commandId ID of the command that needs to be run. + * @return Command that represents the retry attempt. + */ + @Consumes() + @POST + @Path("/{commandId}/retry") + public ApiCommand retry(@PathParam(COMMAND_ID) long commandId); + +} diff --git a/java/src/main/java/com/cloudera/api/v11/HostsResourceV11.java b/java/src/main/java/com/cloudera/api/v11/HostsResourceV11.java new file mode 100644 index 00000000..62b28124 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/HostsResourceV11.java @@ -0,0 +1,52 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_FULL; +import static com.cloudera.api.Parameters.HOST_ID; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiHost; +import com.cloudera.api.v10.HostsResourceV10; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface HostsResourceV11 extends HostsResourceV10 { + + /** + * Returns a specific Host in the system. + * + * @param hostId The ID of the host to read. + * @param dataView The view to materialize. Defaults to 'full'. + * @return The Host object with the specified hostId. + */ + @GET + @Path("/{hostId}") + public ApiHost readHost( + @PathParam(HOST_ID) String hostId, + @DefaultValue(DATA_VIEW_FULL) @QueryParam(DATA_VIEW) DataView dataView); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v11/NameservicesResourceV11.java b/java/src/main/java/com/cloudera/api/v11/NameservicesResourceV11.java new file mode 100644 index 00000000..21172c2d --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/NameservicesResourceV11.java @@ -0,0 +1,51 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; +import static com.cloudera.api.Parameters.NAMESERVICE_NAME; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiNameservice; +import com.cloudera.api.v1.NameservicesResource; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface NameservicesResourceV11 extends NameservicesResource { + + /** + * Retrieve information about a nameservice. + * + * @param nameservice The nameservice to retrieve. + * @param dataView The view to materialize. Defaults to 'full'. + * @return Details of the nameservice. + */ + @GET + @Path("/{nameservice}") + public ApiNameservice readNameservice( + @PathParam(NAMESERVICE_NAME) String nameservice, + @QueryParam(DATA_VIEW) @DefaultValue(DATA_VIEW_DEFAULT) DataView dataView); +} diff --git a/java/src/main/java/com/cloudera/api/v11/ReplicationsResourceV11.java b/java/src/main/java/com/cloudera/api/v11/ReplicationsResourceV11.java new file mode 100644 index 00000000..0760a750 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/ReplicationsResourceV11.java @@ -0,0 +1,78 @@ +package com.cloudera.api.v11; +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; +import static com.cloudera.api.Parameters.SCHEDULE_ID; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.model.ApiReplicationDiagnosticsCollectionArgs; +import com.cloudera.api.model.ApiReplicationScheduleDataLimits; +import com.cloudera.api.model.ApiReplicationScheduleList; +import com.cloudera.api.v4.ReplicationsResourceV4; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ReplicationsResourceV11 extends ReplicationsResourceV4 { + + /** + * Returns information for all replication schedules. + *

    + * Available since API v11. + * + * @param limits Various limits on contents of returned schedules. + * @return List of replication schedules. + */ + @GET + @Path("/") + public ApiReplicationScheduleList readSchedules( + @QueryParam("limits") ApiReplicationScheduleDataLimits limits); + + + /** + * Collect diagnostic data for a schedule, optionally for a subset of commands + * on that schedule, matched by schedule ID. + * + * The returned command's resultDataUrl property, upon the commands completion, + * will refer to the generated diagnostic data. + * Available since API v11. + * + * @param scheduleId Schedule ID + * @param replicationCollectionArgs Replication collection arguments + * @param view view to materialize + * @return Command generated to collect the diagnostics data. + */ + @POST + @Path("/{scheduleId}/collectDiagnosticData") + public ApiCommand collectDiagnosticData( + @PathParam(SCHEDULE_ID) long scheduleId, + ApiReplicationDiagnosticsCollectionArgs replicationCollectionArgs, + @QueryParam(DATA_VIEW) @DefaultValue(DATA_VIEW_DEFAULT) DataView view); +} diff --git a/java/src/main/java/com/cloudera/api/v11/RolesResourceV11.java b/java/src/main/java/com/cloudera/api/v11/RolesResourceV11.java new file mode 100644 index 00000000..7b490dd9 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/RolesResourceV11.java @@ -0,0 +1,63 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; +import static com.cloudera.api.Parameters.DATA_VIEW_FULL; +import static com.cloudera.api.Parameters.ROLE_NAME; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiRole; +import com.cloudera.api.model.ApiRoleList; +import com.cloudera.api.v8.RolesResourceV8; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface RolesResourceV11 extends RolesResourceV8 { + + /** + * Lists all roles of a given service. + * @param dataView DataView for getting roles. Defaults to 'summary'. + * @return List of roles. + */ + @GET + @Path("/") + public ApiRoleList readRoles( + @DefaultValue(DATA_VIEW_DEFAULT) @QueryParam(DATA_VIEW) DataView dataView); + + /** + * Retrieves detailed information about a role. + * + * @param roleName The role name. + * @param dataView The view to materialize. Defaults to 'full'. + * @return The details of the role. + */ + @GET + @Path("/{roleName}") + public ApiRole readRole( + @PathParam(ROLE_NAME) String roleName, + @DefaultValue(DATA_VIEW_FULL) @QueryParam(DATA_VIEW) DataView dataView); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v11/RootResourceV11.java b/java/src/main/java/com/cloudera/api/v11/RootResourceV11.java new file mode 100644 index 00000000..c352b53a --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/RootResourceV11.java @@ -0,0 +1,46 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import com.cloudera.api.v10.RootResourceV10; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV11 extends RootResourceV10 { + /** + * @return The Cloudera Manager resource handler. + */ + @Override + @Path("/cm") + public ClouderaManagerResourceV11 getClouderaManagerResource(); + + @Override + @Path("/clusters") + public ClustersResourceV11 getClustersResource(); + + @Override + @Path("/timeseries") + public TimeSeriesResourceV11 getTimeSeriesResource(); + + @Override + @Path("/users") + public UsersResourceV11 getUsersResource(); + + @Override + @Path("/commands") + public CommandsResourceV11 getCommandsResource(); +} diff --git a/java/src/main/java/com/cloudera/api/v11/ServicesResourceV11.java b/java/src/main/java/com/cloudera/api/v11/ServicesResourceV11.java new file mode 100644 index 00000000..cb92d17e --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/ServicesResourceV11.java @@ -0,0 +1,66 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_FULL; +import static com.cloudera.api.Parameters.SERVICE_NAME; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiService; +import com.cloudera.api.v10.ServicesResourceV10; +import com.cloudera.api.v4.ReplicationsResourceV4; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ServicesResourceV11 extends ServicesResourceV10 { + + @Override + public RolesResourceV11 getRolesResource(String serviceName); + + /** + * Retrieves the replication resource. + * Only available with Cloudera Manager Enterprise Edition. + * @param serviceName The service name. + * @return The replications resource handler. + */ + @Path("/{serviceName}/replications") + @Override + public ReplicationsResourceV11 getReplicationsResource( + @PathParam(SERVICE_NAME) String serviceName); + + /** + * Retrieves details information about a service. + * + * @param serviceName The service name. + * @param dataView DataView to materialize. Defaults to 'full'. + * @return The details of the service. + */ + @GET + @Path("/{serviceName}") + public ApiService readService( + @PathParam(SERVICE_NAME) String serviceName, + @DefaultValue(DATA_VIEW_FULL) @QueryParam(DATA_VIEW) DataView dataView); +} diff --git a/java/src/main/java/com/cloudera/api/v11/TimeSeriesResourceV11.java b/java/src/main/java/com/cloudera/api/v11/TimeSeriesResourceV11.java new file mode 100644 index 00000000..fd2e68ad --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/TimeSeriesResourceV11.java @@ -0,0 +1,67 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import com.cloudera.api.model.ApiTimeSeriesEntityAttributeList; +import com.cloudera.api.model.ApiTimeSeriesEntityTypeList; +import com.cloudera.api.model.ApiTimeSeriesRequest; +import com.cloudera.api.v6.TimeSeriesResourceV6; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +public interface TimeSeriesResourceV11 extends TimeSeriesResourceV6 { + /** + * Retrieve all metric entity types monitored by Cloudera Manager. + * It is guaranteed that parent types appear before their children. + *

    + * Available since API v11. + * + * @return List of time series entity type. + */ + @GET + @Path("/entityTypes") + public ApiTimeSeriesEntityTypeList getEntityTypes(); + + /** + * Retrieve all metric entity type attributes monitored by Cloudera Manager. + *

    + * Available since API v11. + * + * @return List of time series entity attributes. + */ + @GET + @Path("/entityTypeAttributes") + public ApiTimeSeriesEntityAttributeList getEntityTypeAttributes(); + + /** + * Retrieve time-series data from the Cloudera Manager (CM) time-series + * data store accepting HTTP POST request. This method differs + * from queryTimeSeries() in v6 that this could accept query strings that are + * longer than HTTP GET request limit. + * + * Available since API v11. + * + * @param timeSeriesRequest Request object containing information used when + * retrieving timeseries data. + * @return List of time series that match the tsquery. + */ + @POST + @Path("/") + public Response queryTimeSeries(ApiTimeSeriesRequest timeSeriesRequest); +} diff --git a/java/src/main/java/com/cloudera/api/v11/UsersResourceV11.java b/java/src/main/java/com/cloudera/api/v11/UsersResourceV11.java new file mode 100644 index 00000000..2c9da392 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/UsersResourceV11.java @@ -0,0 +1,42 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v11; + +import com.cloudera.api.model.ApiUserSessionList; +import com.cloudera.api.v1.UsersResource; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public interface UsersResourceV11 extends UsersResource { + /** + * Return a list of the sessions associated with interactive authenticated + * users in Cloudera Manager. + *

    + * Note that these sessions are only associated with users who log into the + * web interface. API users will not appear. + * + * @return A list of user sessions + */ + @GET + @Path("/sessions") + public ApiUserSessionList getSessions(); +} diff --git a/java/src/main/java/com/cloudera/api/v11/package-info.java b/java/src/main/java/com/cloudera/api/v11/package-info.java new file mode 100644 index 00000000..70c3d726 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v11/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * API version 11, introduced in Cloudera Manager 5.5.0. + */ + +package com.cloudera.api.v11; diff --git a/java/src/main/java/com/cloudera/api/v12/ClouderaManagerResourceV12.java b/java/src/main/java/com/cloudera/api/v12/ClouderaManagerResourceV12.java new file mode 100644 index 00000000..dc6a92ef --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v12/ClouderaManagerResourceV12.java @@ -0,0 +1,34 @@ +// Copyright (c) 2015 Cloudera, Inc. All rights reserved. +package com.cloudera.api.v12; + +import com.cloudera.api.model.ApiClusterTemplate; +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v11.ClouderaManagerResourceV11; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClouderaManagerResourceV12 extends ClouderaManagerResourceV11 { + + /** + * Create cluster as per the given cluster template + * + * @param apiClusterTemplate cluster template + * @param addRepositories if true the parcels repositories in the cluster + * template will be added. + * @return The command performing import task + */ + @POST + @Path("importClusterTemplate") + public ApiCommand importClusterTemplate( + ApiClusterTemplate apiClusterTemplate, + @QueryParam("addRepositories") @DefaultValue("false") boolean addRepositories); + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v12/ClustersResourceV12.java b/java/src/main/java/com/cloudera/api/v12/ClustersResourceV12.java new file mode 100644 index 00000000..7b2d3141 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v12/ClustersResourceV12.java @@ -0,0 +1,69 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v12; + +import static com.cloudera.api.Parameters.CLUSTER_NAME; +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiClusterTemplate; +import com.cloudera.api.model.ApiServiceList; +import com.cloudera.api.v11.ClustersResourceV11; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV12 extends ClustersResourceV11 { + + /** + * Export the cluster template for the given cluster. If cluster does not have + * host templates defined it will export host templates based on roles + * assignment. + * + * @param clusterName cluster name + * @param exportAutoConfig export configs set by the auto configuration + * @return Cluster template + */ + @GET + @Consumes + @Path("/{clusterName}/export") + public ApiClusterTemplate export( + @PathParam(CLUSTER_NAME) String clusterName, + @QueryParam("exportAutoConfig") @DefaultValue("false") boolean exportAutoConfig); + + + /** + * List the services that can provide distributed file system (DFS) capabilities in this cluster. + * + * @param clusterName cluster name + * @param view data view required for matching services + * @return Services that provide DFS capabilities in this cluster + */ + @GET + @Path("/{clusterName}/dfsServices") + public ApiServiceList listDfsServices( + @PathParam(CLUSTER_NAME) String clusterName, + @QueryParam(DATA_VIEW) @DefaultValue(DATA_VIEW_DEFAULT) DataView view); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v12/RootResourceV12.java b/java/src/main/java/com/cloudera/api/v12/RootResourceV12.java new file mode 100644 index 00000000..f2ed1cc0 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v12/RootResourceV12.java @@ -0,0 +1,33 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v12; + +import com.cloudera.api.v11.RootResourceV11; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV12 extends RootResourceV11 { + + @Override + @Path("/cm") + public ClouderaManagerResourceV12 getClouderaManagerResource(); + + @Override + @Path("/clusters") + public ClustersResourceV12 getClustersResource(); + +} diff --git a/java/src/main/java/com/cloudera/api/v12/package-info.java b/java/src/main/java/com/cloudera/api/v12/package-info.java new file mode 100644 index 00000000..78dcdcd0 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v12/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * API version 12, introduced in Cloudera Manager 5.7.0. + */ + +package com.cloudera.api.v12; diff --git a/java/src/main/java/com/cloudera/api/v2/ClouderaManagerResourceV2.java b/java/src/main/java/com/cloudera/api/v2/ClouderaManagerResourceV2.java index e95bfce9..5c1b01fc 100644 --- a/java/src/main/java/com/cloudera/api/v2/ClouderaManagerResourceV2.java +++ b/java/src/main/java/com/cloudera/api/v2/ClouderaManagerResourceV2.java @@ -48,7 +48,7 @@ public interface ClouderaManagerResourceV2 extends ClouderaManagerResource { *

  • Cluster Administrators (but Navigator config will be redacted)
  • * *

    - * Note: starting with v3, the deployment information contais data about + * Note: starting with v3, the deployment information contains data about * Cloudera Manager peers configured for the instance. This data contains * plain text authentication information used to connect to the remote peer. * diff --git a/java/src/main/java/com/cloudera/api/v3/CmPeersResource.java b/java/src/main/java/com/cloudera/api/v3/CmPeersResource.java index dbff46fa..4282f55a 100644 --- a/java/src/main/java/com/cloudera/api/v3/CmPeersResource.java +++ b/java/src/main/java/com/cloudera/api/v3/CmPeersResource.java @@ -40,6 +40,9 @@ public interface CmPeersResource { *

    * Available since API v3. Only available with Cloudera Manager Enterprise * Edition. + *

    + * When accessed via API version before v11, only REPLICATION type peers will + * be returned. * * @return List of Cloudera Manager peers. */ @@ -62,6 +65,9 @@ public interface CmPeersResource { *

    * Available since API v3. Only available with Cloudera Manager Enterprise * Edition. + *

    + * Type field in ApiCmPeer is available since API v11. if not specified + * when making createPeer() call, 'REPLICATION' type peer will be created. * * @param peer Peer to create (see above). * @return Information about the created peer. diff --git a/java/src/main/java/com/cloudera/api/v4/AuditsResource.java b/java/src/main/java/com/cloudera/api/v4/AuditsResource.java index 03a218c1..52c945ce 100644 --- a/java/src/main/java/com/cloudera/api/v4/AuditsResource.java +++ b/java/src/main/java/com/cloudera/api/v4/AuditsResource.java @@ -46,9 +46,10 @@ public interface AuditsResource { * * @param maxResults Maximum number of audits to return * @param resultOffset Offset of audits to return - * @param startTime Start of the period to query (defaults to 1 day ago - * relative to endTime) - * @param endTime End of the period to query (defaults to current time) + * @param startTime Start of the period to query in ISO 8601 format (defaults + * to 1 day ago relative to endTime). + * @param endTime End of the period to query in ISO 8601 format (defaults to + * current time). * @param query * The query to filter out audits in the system. It accepts * querying the intersection of a list of constraints, @@ -207,9 +208,6 @@ public interface AuditsResource { * queries are converted to standard SQL LIKE syntax, so any % (%25) * character in a value that also contains a wild card will be * interpreted as a wild card.) - *

    - * Values for time related query parameters (startTime and - * endTime) should be ISO8601 timestamps. *

    * Available since API v4. * diff --git a/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java b/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java index d4a56efd..4942e3db 100644 --- a/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java +++ b/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java @@ -52,8 +52,10 @@ public interface ImpalaQueriesResource { * expression using standard and / or boolean logic and parenthesis. * An example of a complex filter is: 'query_duration > 5s and (user = root or * user = myUserName)'. - * @param from Returns queries that were active between the from and to times - * @param to Returns queries that were active between the from and to times + * @param from Start of the period to query in ISO 8601 format (defaults to 5 + * minutes before the 'to' time). + * @param to End of the period to query in ISO 8601 format (defaults to + * current time). * @param limit The maximum number of queries to return. Queries will be * returned in the following order: *

      diff --git a/java/src/main/java/com/cloudera/api/v4/ServicesResourceV4.java b/java/src/main/java/com/cloudera/api/v4/ServicesResourceV4.java index 09f22a4d..5e503854 100644 --- a/java/src/main/java/com/cloudera/api/v4/ServicesResourceV4.java +++ b/java/src/main/java/com/cloudera/api/v4/ServicesResourceV4.java @@ -234,8 +234,10 @@ public RoleCommandsResourceV4 getRoleCommandsResource( * * @param hdfsServiceName The HDFS service name. * @param nameService The (optional) HDFS nameservice. Required for HA setup. - * @param from The (optional) start time of the report. Default to 24 hours before "to" time. - * @param to The (optional) end time of the report. Default to now. + * @param from The (optional) start time of the report in ISO 8601 format ( + * defaults to 24 hours before "to" time). + * @param to The (optional) end time of the report in ISO 8601 format ( + * defaults to now). * @param aggregation The (optional) aggregation period for the data. * Supports "hourly", "daily" (default) and "weekly". * @return Report data. @@ -263,8 +265,10 @@ public ApiHdfsUsageReport getHdfsUsageReport( * Edition. * * @param mrServiceName The MR service name. - * @param from The (optional) start time of the report. Default to 24 hours before "to" time. - * @param to The (optional) end time of the report. Default to now. + * @param from The (optional) start time of the report in ISO 8601 format + * (defaults to 24 hours before "to" time). + * @param to The (optional) end time of the report in ISO 8601 format (defaults + * to now). * @param aggregation The (optional) aggregation period for the data. * Supports "hourly", "daily" (default) and "weekly". * @return Report data. diff --git a/java/src/main/java/com/cloudera/api/v4/TimeSeriesResource.java b/java/src/main/java/com/cloudera/api/v4/TimeSeriesResource.java index 2b0a9a5f..e6124938 100644 --- a/java/src/main/java/com/cloudera/api/v4/TimeSeriesResource.java +++ b/java/src/main/java/com/cloudera/api/v4/TimeSeriesResource.java @@ -41,13 +41,14 @@ public interface TimeSeriesResource { *

      * Please see the * - * tsquery language documentation.

      + * tsquery language documentation. + *

      * Available since API v4. * * @param query Tsquery to run against the CM time-series data store. - * @param from Start of the period to query (defaults to 5 minutes before the + * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the * end of the period). - * @param to End of the period to query (defaults to current time). + * @param to End of the period to query in ISO 8601 format (defaults to current time). * * @return List of time series that match the tsquery. */ diff --git a/java/src/main/java/com/cloudera/api/v6/DashboardsResource.java b/java/src/main/java/com/cloudera/api/v6/DashboardsResource.java index f1f31644..e2ca3205 100644 --- a/java/src/main/java/com/cloudera/api/v6/DashboardsResource.java +++ b/java/src/main/java/com/cloudera/api/v6/DashboardsResource.java @@ -32,7 +32,9 @@ public interface DashboardsResource { /** - * Returns the list of all dashboards. + * Returns the list of all user-customized dashboards. This includes both the + * new dashboards created by users as well as any user customizations to + * built-in dashboards. *

      * Available since API v6. */ diff --git a/java/src/main/java/com/cloudera/api/v6/ServicesResourceV6.java b/java/src/main/java/com/cloudera/api/v6/ServicesResourceV6.java index 8fe9927d..8e737e38 100644 --- a/java/src/main/java/com/cloudera/api/v6/ServicesResourceV6.java +++ b/java/src/main/java/com/cloudera/api/v6/ServicesResourceV6.java @@ -52,7 +52,7 @@ public interface ServicesResourceV6 extends ServicesResourceV4 { @Path("/{serviceName}/snapshots") public SnapshotsResource getSnapshotsResource( @PathParam(SERVICE_NAME) String serviceName); - + /** * @return The YARN applications resource handler. */ @@ -72,7 +72,7 @@ public YarnApplicationsResource getYarnApplicationsResource( * with valid configuration. *

      * Available since API v6. - * + * * @param serviceName * Name of the Yarn service on which to run the command. * @return Information about the submitted command @@ -95,7 +95,7 @@ public ApiCommand importMrConfigsIntoYarn( *

    *

    * Available since API v6. - * + * * @param serviceName * Name of the Yarn service on which to run the command. * @return Information about the submitted command @@ -104,7 +104,7 @@ public ApiCommand importMrConfigsIntoYarn( @Path("/{serviceName}/commands/switchToMr2") public ApiCommand switchToMr2( @PathParam(SERVICE_NAME) String serviceName); - + /** * Enable high availability (HA) for a YARN ResourceManager. *

    @@ -127,7 +127,7 @@ public ApiCommand switchToMr2( public ApiCommand enableRmHaCommand( @PathParam(SERVICE_NAME) String serviceName, ApiEnableRmHaArguments args); - + /** * Disable high availability (HA) for ResourceManager. * @@ -185,7 +185,7 @@ public ApiCommand enableOozieHaCommand( public ApiCommand disableOozieHaCommand( @PathParam(SERVICE_NAME) String serviceName, ApiDisableOozieHaArguments args); - + /** * Enable High Availability (HA) with Automatic Failover for an HDFS NameNode. *

    @@ -225,7 +225,7 @@ public ApiCommand hdfsEnableNnHaCommand( * Then, HDFS service is restarted and all services that were stopped * are started again afterwards. * Finally, client configs for HDFS and its depedents will be re-deployed. - * + * * @param serviceName The HDFS service name. * @param args Arguments for the command. * @return Information about the submitted command. @@ -439,5 +439,13 @@ public ApiCommand serviceCommandByName( @GET @Path("/{serviceName}/commandsByName") public ApiCommandMetadataList listServiceCommands( - @PathParam(SERVICE_NAME) String serviceName); + @PathParam(SERVICE_NAME) String serviceName); + + /** + * @return The Impala queries resource handler + */ + @Override + @Path("/{serviceName}/impalaQueries") + public ImpalaQueriesResourceV6 getImpalaQueriesResource( + @PathParam(SERVICE_NAME) String serviceName); } diff --git a/java/src/main/java/com/cloudera/api/v6/TimeSeriesResourceV6.java b/java/src/main/java/com/cloudera/api/v6/TimeSeriesResourceV6.java index 314d54dc..332dff3d 100644 --- a/java/src/main/java/com/cloudera/api/v6/TimeSeriesResourceV6.java +++ b/java/src/main/java/com/cloudera/api/v6/TimeSeriesResourceV6.java @@ -21,6 +21,7 @@ import static com.cloudera.api.Parameters.CONTENT_TYPE; import static com.cloudera.api.Parameters.DESIRED_ROLLUP; import static com.cloudera.api.Parameters.MUST_USE_DESIRED_ROLLUP; +import static com.cloudera.api.Parameters.ROLLUP_DEFAULT; import static com.cloudera.api.Parameters.TO; import javax.ws.rs.DefaultValue; @@ -33,20 +34,21 @@ import com.cloudera.api.v4.TimeSeriesResource; public interface TimeSeriesResourceV6 extends TimeSeriesResource { - /** * Retrieve time-series data from the Cloudera Manager (CM) time-series * data store using a tsquery. * * Please see the * - * tsquery language documentation.

    + * tsquery language documentation. + *

    * Available since API v6. * * @param query Tsquery to run against the CM time-series data store. - * @param from Start of the period to query (defaults to 5 minutes before the - * end of the period). - * @param to End of the period to query (defaults to current time). + * @param from Start of the period to query in ISO 8601 format (defaults to 5 + * minutes before the end of the period). + * @param to End of the period to query in ISO 8601 format (defaults to + * current time). * @param contentType to return the response in. The content types * "application/json" and "text/csv" are supported. This defaults to * "application/json". If "text/csv" is specified then we return one row @@ -71,7 +73,7 @@ public Response queryTimeSeries( @DefaultValue(MediaType.APPLICATION_JSON) String contentType, @QueryParam(DESIRED_ROLLUP) - @DefaultValue("RAW") + @DefaultValue(ROLLUP_DEFAULT) String desiredRollup, @QueryParam(MUST_USE_DESIRED_ROLLUP) @DefaultValue("false") diff --git a/java/src/main/java/com/cloudera/api/v6/YarnApplicationsResource.java b/java/src/main/java/com/cloudera/api/v6/YarnApplicationsResource.java index 697875bb..290c5f6a 100644 --- a/java/src/main/java/com/cloudera/api/v6/YarnApplicationsResource.java +++ b/java/src/main/java/com/cloudera/api/v6/YarnApplicationsResource.java @@ -52,10 +52,9 @@ public interface YarnApplicationsResource { * expression using standard and / or boolean logic and parenthesis. * An example of a complex filter is: 'application_duration > 5s and (user = root or * user = myUserName'). - * @param from Returns applications that were active between the from and to times. - * Defaults to 5 minutes before the 'to' time. - * @param to Returns applications that were active between the from and to times. - * Defaults to now. + * @param from Start of the period to query in ISO 8601 format (defaults to 5 + * minutes before the 'to' time). + * @param to End of the period to query in ISO 8601 format (defaults to now). * @param limit The maximum number of applications to return. Applications will be * returned in the following order: *

      diff --git a/java/src/main/java/com/cloudera/api/v8/AuditsResourceV8.java b/java/src/main/java/com/cloudera/api/v8/AuditsResourceV8.java index 05c201cb..5721c72b 100644 --- a/java/src/main/java/com/cloudera/api/v8/AuditsResourceV8.java +++ b/java/src/main/java/com/cloudera/api/v8/AuditsResourceV8.java @@ -48,9 +48,10 @@ public interface AuditsResourceV8 extends AuditsResource { * * @param maxResults Maximum number of audits to return * @param resultOffset Offset of audits to return - * @param startTime Start of the period to query (defaults to 1 day ago - * relative to endTime) - * @param endTime End of the period to query (defaults to current time) + * @param startTime Start of the period to query in ISO 8601 format (defaults + * to 1 day ago relative to endTime). + * @param endTime End of the period to query in ISO 8601 format (defaults to + * current time). * @param query * The query to filter out audits in the system. It accepts * querying the intersection of a list of constraints, @@ -253,14 +254,12 @@ public interface AuditsResourceV8 extends AuditsResource { * queries are converted to standard SQL LIKE syntax, so any % (%25) * character in a value that also contains a wild card will be * interpreted as a wild card.) - *

      - * Values for time related query parameters (startTime and - * endTime) should be ISO8601 timestamps. *

      * Available since API v8. A subset of these features is available since v4. * * @return List of audits in descending order of timestamp */ + @Override @GET @Path("/") public ApiAuditList readAudits( diff --git a/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java b/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java index bbf020d7..5066a5ee 100644 --- a/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java +++ b/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java @@ -16,6 +16,11 @@ package com.cloudera.api; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.message.Message; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.junit.Test; import java.net.MalformedURLException; @@ -23,6 +28,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class ClouderaManagerClientBuilderTest { @@ -96,4 +103,64 @@ public ApiRootResource newProxy(ClouderaManagerClientBuilder builder) { .enableLogging() .build(); } + + @Test + public void testMaintainSessionConfig() { + ClouderaManagerClientBuilder builder = new ClouderaManagerClientBuilder(); + ApiRootResource proxy = builder.withHost("localhost") + .withPort(1) + .enableLogging() + .build(); + ClientConfiguration cfg = WebClient.getConfig(proxy); + assertNotNull(cfg); + Boolean maintainSession = (Boolean)cfg.getRequestContext().get(Message.MAINTAIN_SESSION); + assertNull(maintainSession); + + proxy = builder.setMaintainSessionAcrossRequests(true).build(); + cfg = WebClient.getConfig(proxy); + assertNotNull(cfg); + maintainSession = (Boolean)cfg.getRequestContext().get(Message.MAINTAIN_SESSION); + assertTrue(maintainSession); + } + + @Test + public void testPassingLocale() { + ClouderaManagerClientBuilder builder = new ClouderaManagerClientBuilder(); + ApiRootResource proxy = builder.withHost("localhost") + .withPort(1) + .enableLogging() + .build(); + ClientConfiguration cfg = WebClient.getConfig(proxy); + HTTPConduit conduit = (HTTPConduit) cfg.getConduit(); + HTTPClientPolicy clientPolicy = conduit.getClient(); + + assertNotNull(clientPolicy); + String acceptLanguage = clientPolicy.getAcceptLanguage(); + assertNull(acceptLanguage); + + proxy = builder.withAcceptLanguage("some-string").build(); + cfg = WebClient.getConfig(proxy); + conduit = (HTTPConduit) cfg.getConduit(); + clientPolicy = conduit.getClient(); + assertEquals("some-string", clientPolicy.getAcceptLanguage()); + } + + @Test + public void testStreamAutoClosureConfig() { + ClouderaManagerClientBuilder builder = new ClouderaManagerClientBuilder(); + ApiRootResource proxy = builder.withHost("localhost") + .withPort(1) + .enableLogging() + .build(); + ClientConfiguration cfg = WebClient.getConfig(proxy); + assertNotNull(cfg); + Boolean autoClosure = (Boolean)cfg.getRequestContext().get("response.stream.auto.close"); + assertNull(autoClosure); + + proxy = builder.enableStreamAutoClosure().build(); + cfg = WebClient.getConfig(proxy); + assertNotNull(cfg); + autoClosure = (Boolean)cfg.getRequestContext().get("response.stream.auto.close"); + assertTrue(autoClosure); + } } diff --git a/java/src/test/java/com/cloudera/api/model/ApiModelTest.java b/java/src/test/java/com/cloudera/api/model/ApiModelTest.java index 1457c98c..babb169c 100644 --- a/java/src/test/java/com/cloudera/api/model/ApiModelTest.java +++ b/java/src/test/java/com/cloudera/api/model/ApiModelTest.java @@ -16,6 +16,8 @@ package com.cloudera.api.model; +import static org.junit.Assert.*; + import com.cloudera.api.ApiErrorMessage; import com.cloudera.api.ApiObjectMapper; import com.cloudera.api.ApiUtils; @@ -42,6 +44,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -54,7 +57,6 @@ import org.joda.time.Duration; import org.joda.time.Instant; import org.junit.Test; -import static org.junit.Assert.*; public class ApiModelTest { private final static String TEXT_ENCODING = "UTF-8"; @@ -223,6 +225,7 @@ public void testApiConfig() throws Exception { ApiConfig cfg = new ApiConfig("name", "value", true, "default", "display", "description", "relatedName", ApiConfig.ValidationState.OK, "validationMessage"); + cfg.setValidationWarningsSuppressed(true); checkJsonXML(cfg); ApiServiceConfig svcCfg = new ApiServiceConfig(); @@ -243,7 +246,9 @@ public void testApiHost() @Test public void testApiHealthCheck() throws Exception { ApiHealthCheck healthCheck = new ApiHealthCheck("checkName", - ApiHealthSummary.GOOD); + ApiHealthSummary.GOOD, + "Dummy Health explanation.", + false); checkJsonXML(healthCheck); } @@ -258,6 +263,7 @@ public void testApiRole() role.setHaStatus(ApiRole.HaStatus.ACTIVE); role.setHealthChecks(createHealthChecks()); role.setHealthSummary(ApiHealthSummary.GOOD); + role.setEntityStatus(ApiEntityStatus.GOOD_HEALTH); role.setHostRef(new ApiHostRef("myhost")); role.setMaintenanceMode(true); role.setMaintenanceOwners(createMaintenanceOwners()); @@ -282,11 +288,13 @@ public void testApiService() service.setDisplayName("mydisplayname"); service.setHealthChecks(createHealthChecks()); service.setHealthSummary(ApiHealthSummary.GOOD); + service.setEntityStatus(ApiEntityStatus.GOOD_HEALTH); service.setMaintenanceMode(true); service.setMaintenanceOwners(createMaintenanceOwners()); service.setName("myname"); service.setServiceState(ApiServiceState.STARTED); service.setServiceUrl("http://foo:7180"); + service.setRoleInstancesUrl("http://foo:7180/instances"); service.setType("mytype"); ApiRoleConfigGroup rcg = new ApiRoleConfigGroup(); @@ -519,6 +527,7 @@ public void testConfig() throws Exception { "relatedName", ApiConfig.ValidationState.OK, "validationMessage"); + config.setValidationWarningsSuppressed(false); checkJsonXML(config); } @@ -586,6 +595,8 @@ public void testCmPeer() throws Exception { peer.setUrl("url1"); peer.setUsername("user1"); peer.setPassword("password1"); + peer.setType(ApiCmPeerType.REPLICATION); + peer.setClouderaManagerCreatedUser(true); checkJsonXML(peer); } @@ -615,6 +626,7 @@ public void testHdfsReplication() throws Exception { ApiScheduleInterval.MONTH, true); hdfsInfo.setHdfsArguments(hdfsArgs); hdfsInfo.setNextRun(new Date(12345)); + hdfsInfo.setActive(true); ApiReplicationCommand cmd = new ApiReplicationCommand(); fillInCommand(cmd); @@ -664,6 +676,7 @@ public void testHiveReplication() throws Exception { ApiReplicationSchedule sch = new ApiReplicationSchedule(20L, new Date(1234), new Date(5678), 10, ApiScheduleInterval.MONTH, true); sch.setHiveArguments(args); + sch.setActive(true); checkJsonXML(sch); ApiHiveReplicationResult res = new ApiHiveReplicationResult(); @@ -676,6 +689,7 @@ public void testHiveReplication() throws Exception { res.setErrorCount(1); res.setDryRun(true); res.setPhase("foo"); + res.setRunAsUser("foo"); ApiHdfsReplicationResult hdfsRes = newHdfsReplicationResult(); res.setDataReplicationResult(hdfsRes); @@ -833,6 +847,7 @@ private ApiSnapshotPolicy createPolicy() { policy.setDayOfMonth((byte) 31); policy.setMonthOfYear((byte) 6); policy.setHoursForHourlySnapshots(Arrays.asList((byte) 4, (byte) 8)); + policy.setPaused(false); return policy; } @@ -842,7 +857,9 @@ public void testYarnApplication() throws Exception { ApiMr2AppInformation mr2Information = new ApiMr2AppInformation("jobState"); ApiYarnApplication application = new ApiYarnApplication( "appId", "appName", new Date(), new Date(), "user", "pool", - "FINISHED", 80.0, mr2Information, Maps.newHashMap()); + "FINISHED", 80.0, mr2Information, Maps.newHashMap(), + ImmutableList.of("foo"), 1234L, 5678L, + 123, 1, 3, 1d, 2d, 3d, 4d, 5d); checkJsonXML(application); ApiYarnApplicationResponse response = new ApiYarnApplicationResponse( @@ -896,8 +913,10 @@ public void testApiTimeSeriesData() throws Exception { ApiTimeSeriesCrossEntityMetadata xEntityMetadata = new ApiTimeSeriesCrossEntityMetadata(); - xEntityMetadata.setMaxEntityDisplayName("maxDisplayName"); + xEntityMetadata.setMaxEntityDisplayName("maxEntityDisplayName"); xEntityMetadata.setMinEntityDisplayName("minEntityDisplayName"); + xEntityMetadata.setMaxEntityName("maxEntityName"); + xEntityMetadata.setMinEntityName("minEntityName"); xEntityMetadata.setNumEntities(3.14); aggStats.setCrossEntityMetadata(xEntityMetadata); checkJsonXML(data); @@ -905,8 +924,14 @@ public void testApiTimeSeriesData() throws Exception { private List createHealthChecks() { return ImmutableList.of( - new ApiHealthCheck("TEST1", ApiHealthSummary.GOOD), - new ApiHealthCheck("TEST2", ApiHealthSummary.CONCERNING)); + new ApiHealthCheck("TEST1", + ApiHealthSummary.GOOD, + "Dummy Health explanation.", + false), + new ApiHealthCheck("TEST2", + ApiHealthSummary.CONCERNING, + "Dummy Health explanation.", + false)); } private List createMaintenanceOwners() { @@ -928,6 +953,7 @@ private ApiHdfsReplicationArguments newHdfsReplicationArguments() { hdfsArgs.setSkipTrash(true); hdfsArgs.setPreserveXAttrs(true); hdfsArgs.setReplicationStrategy(ReplicationStrategy.DYNAMIC); + hdfsArgs.setExclusionFilters(Lists.newArrayList("/a/.*", "/b/.*")); return hdfsArgs; } @@ -946,6 +972,8 @@ private ApiHdfsReplicationResult newHdfsReplicationResult() { result.setNumBytesCopyFailed(400); result.setSetupError("error"); result.setSnapshottedDirs(Arrays.asList("/user/a")); + result.setFailedFiles(Arrays.asList("path1")); + result.setRunAsUser("systest"); return result; } @@ -958,6 +986,7 @@ private void fillInCommand(ApiCommand cmd) { cmd.setSuccess(false); cmd.setResultMessage("message"); cmd.setResultDataUrl("url"); + cmd.setCanRetry(false); } private ApiCluster newCluster() { @@ -967,8 +996,10 @@ private ApiCluster newCluster() { cluster.setName("mycluster"); cluster.setDisplayName("mycluster-displayName"); cluster.setClusterUrl("http://some-url:7180/cmf/clusterRedirect/mycluster"); + cluster.setHostsUrl("http://some-url:7180/cmf/clusterRedirect/mycluster/hosts"); cluster.setVersion(ApiClusterVersion.CDH4); cluster.setFullVersion("4.1.2"); + cluster.setEntityStatus(ApiEntityStatus.GOOD_HEALTH); return cluster; } @@ -980,6 +1011,7 @@ private ApiHost newHost() { host.setCommissionState(ApiCommissionState.COMMISSIONED); host.setHealthChecks(createHealthChecks()); host.setHealthSummary(ApiHealthSummary.GOOD); + host.setEntityStatus(ApiEntityStatus.GOOD_HEALTH); host.setHostId("myHostId"); host.setHostUrl("http://foo:7180"); host.setHostname("myHostname"); @@ -992,6 +1024,7 @@ private ApiHost newHost() { host.setRackId("/default"); host.setRoleRefs(roleRefs); host.setTotalPhysMemBytes(1234L); + host.setClusterRef(new ApiClusterRef("clusterName")); return host; } From 79dd937d354f875d26f9313c62b324b9a351b9af Mon Sep 17 00:00:00 2001 From: mthakkar Date: Fri, 5 Aug 2016 11:20:12 -0700 Subject: [PATCH 10/11] [java] Updated with v13 java source --- java/enunciate.xml | 6 +- java/pom.xml | 2 +- .../com/cloudera/api/ApiRootResource.java | 8 ++- .../ApiCollectDiagnosticDataArguments.java | 24 ++++++-- .../api/model/ApiReplicationState.java | 55 ++++++++++++++++++ .../cloudera/api/v13/ClustersResourceV13.java | 39 +++++++++++++ .../api/v13/ReplicationsResourceV13.java | 41 +++++++++++++ .../com/cloudera/api/v13/RootResourceV13.java | 30 ++++++++++ .../cloudera/api/v13/ServicesResourceV13.java | 57 +++++++++++++++++++ .../com/cloudera/api/v13/package-info.java | 21 +++++++ 10 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 java/src/main/java/com/cloudera/api/model/ApiReplicationState.java create mode 100644 java/src/main/java/com/cloudera/api/v13/ClustersResourceV13.java create mode 100644 java/src/main/java/com/cloudera/api/v13/ReplicationsResourceV13.java create mode 100644 java/src/main/java/com/cloudera/api/v13/RootResourceV13.java create mode 100644 java/src/main/java/com/cloudera/api/v13/ServicesResourceV13.java create mode 100644 java/src/main/java/com/cloudera/api/v13/package-info.java diff --git a/java/enunciate.xml b/java/enunciate.xml index 42eb3a95..d129009b 100644 --- a/java/enunciate.xml +++ b/java/enunciate.xml @@ -2,18 +2,18 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd"> - + - + com.cloudera.api cloudera-manager-api Cloudera Manager API - 5.7.0 + 5.8.0 2.7.7 diff --git a/java/src/main/java/com/cloudera/api/ApiRootResource.java b/java/src/main/java/com/cloudera/api/ApiRootResource.java index 912efea3..5d05e599 100644 --- a/java/src/main/java/com/cloudera/api/ApiRootResource.java +++ b/java/src/main/java/com/cloudera/api/ApiRootResource.java @@ -19,6 +19,7 @@ import com.cloudera.api.v10.RootResourceV10; import com.cloudera.api.v11.RootResourceV11; import com.cloudera.api.v12.RootResourceV12; +import com.cloudera.api.v13.RootResourceV13; import com.cloudera.api.v2.RootResourceV2; import com.cloudera.api.v3.RootResourceV3; import com.cloudera.api.v4.RootResourceV4; @@ -27,7 +28,6 @@ import com.cloudera.api.v7.RootResourceV7; import com.cloudera.api.v8.RootResourceV8; import com.cloudera.api.v9.RootResourceV9; -import com.cloudera.api.v12.RootResourceV12; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -116,6 +116,12 @@ public interface ApiRootResource { @Path("/v12") RootResourceV12 getRootV12(); + /** + * @return The v13 root resource. + */ + @Path("/v13") + RootResourceV13 getRootV13(); + /** * Fetch the current API version supported by the server. *

      diff --git a/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java b/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java index 4b5107cf..5d76c55c 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java @@ -34,6 +34,7 @@ public class ApiCollectDiagnosticDataArguments { private String ticketNumber; private String comments; private String clusterName; + private boolean enableMonitorMetricsCollection; private List roles; /** @@ -48,17 +49,21 @@ public void setBundleSize(long bundleSizeByte) { } /** - * This parameter is ignored as of CM 4.5. - * Use endTime and bundleSize instead. + * This parameter is ignored between CM 4.5 and CM 5.7 versions. + * For versions from CM 4.5 to CM 5.7, use endTime and + * bundleSizeBytes instead. + * + * For CM 5.7+ versions, startTime is an optional parameter that + * is with endTime and bundleSizeBytes. This was introduced + * to perform diagnostic data estimation and collection of global + * diagnostics data for a certain time range. * The start time (in ISO 8601 format) * of the period to collection statistics for. */ - @Deprecated public String getStartTime() { return startTime; } - @Deprecated public void setStartTime(String startTime) { this.startTime = startTime; } @@ -120,6 +125,17 @@ public void setClusterName(String clusterName) { this.clusterName = clusterName; } + /** + * Flag to enable collection of metrics for chart display. + */ + public boolean getEnableMonitorMetricsCollection() { + return enableMonitorMetricsCollection; + } + + public void setEnableMonitorMetricsCollection(boolean enable) { + this.enableMonitorMetricsCollection = enable; + } + /** * List of roles for which to get logs and metrics. * diff --git a/java/src/main/java/com/cloudera/api/model/ApiReplicationState.java b/java/src/main/java/com/cloudera/api/model/ApiReplicationState.java new file mode 100644 index 00000000..f93df2d3 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiReplicationState.java @@ -0,0 +1,55 @@ +// Copyright (c) 2016 Cloudera, Inc. All rights reserved. +package com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +/** + * The state of Hive/HDFS Replication. + */ +public class ApiReplicationState { + private Boolean incrementalExportEnabled; + + public ApiReplicationState() { + this(false); + } + + public ApiReplicationState(Boolean incrementalExportEnabled) { + this.incrementalExportEnabled = incrementalExportEnabled; + } + + /** + * + * returns if incremental export is enabled for the given Hive service. + * Not applicable for HDFS service. + */ + public Boolean getIncrementalExportEnabled() { + return incrementalExportEnabled; + } + + public void setIncrementalExportEnabled(Boolean incrementalExportEnabled) { + this.incrementalExportEnabled = incrementalExportEnabled; + } + + @Override + public String toString() { + return toStringHelper().toString(); + } + + protected Objects.ToStringHelper toStringHelper() { + return Objects.toStringHelper(this) + .add("incrementalExportEnabled", incrementalExportEnabled); + } + + @Override + public boolean equals(Object o) { + ApiReplicationState that = ApiUtils.baseEquals(this, o); + return this == that || (that != null && + Objects.equal(incrementalExportEnabled, that.getIncrementalExportEnabled())); + } + + @Override + public int hashCode() { + return Objects.hashCode(incrementalExportEnabled); + } +} diff --git a/java/src/main/java/com/cloudera/api/v13/ClustersResourceV13.java b/java/src/main/java/com/cloudera/api/v13/ClustersResourceV13.java new file mode 100644 index 00000000..d598cadd --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v13/ClustersResourceV13.java @@ -0,0 +1,39 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v13; + +import com.cloudera.api.v12.ClustersResourceV12; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import static com.cloudera.api.Parameters.CLUSTER_NAME; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV13 extends ClustersResourceV12 { + + /** + * @return The services resource handler. + */ + @Override + @Path("/{clusterName}/services") + public ServicesResourceV13 getServicesResource( + @PathParam(CLUSTER_NAME) String clusterName); +} diff --git a/java/src/main/java/com/cloudera/api/v13/ReplicationsResourceV13.java b/java/src/main/java/com/cloudera/api/v13/ReplicationsResourceV13.java new file mode 100644 index 00000000..05417c9a --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v13/ReplicationsResourceV13.java @@ -0,0 +1,41 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v13; + +import com.cloudera.api.DataView; +import com.cloudera.api.model.ApiReplicationState; +import com.cloudera.api.v11.ReplicationsResourceV11; + +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +import static com.cloudera.api.Parameters.DATA_VIEW; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; + +public interface ReplicationsResourceV13 extends ReplicationsResourceV11 { + /** + * returns the replication state. for example if incremental export + * is enabled, etc + * @param view view to materialize + * @return replicate state object. + */ + @GET + @Path("/replicationState") + public ApiReplicationState getReplicationState( + @QueryParam(DATA_VIEW) @DefaultValue(DATA_VIEW_DEFAULT) DataView view); +} diff --git a/java/src/main/java/com/cloudera/api/v13/RootResourceV13.java b/java/src/main/java/com/cloudera/api/v13/RootResourceV13.java new file mode 100644 index 00000000..3138a1f0 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v13/RootResourceV13.java @@ -0,0 +1,30 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v13; + +import com.cloudera.api.v12.RootResourceV12; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV13 extends RootResourceV12 { + /** + * @return The clusters resource handler. + */ + @Override + @Path("/clusters") + public ClustersResourceV13 getClustersResource(); +} diff --git a/java/src/main/java/com/cloudera/api/v13/ServicesResourceV13.java b/java/src/main/java/com/cloudera/api/v13/ServicesResourceV13.java new file mode 100644 index 00000000..a6a89399 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v13/ServicesResourceV13.java @@ -0,0 +1,57 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.cloudera.api.v13; + +import static com.cloudera.api.Parameters.SERVICE_NAME; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v11.ServicesResourceV11; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ServicesResourceV13 extends ServicesResourceV11 { + /** + * Retrieves the replication resource. + * Only available with Cloudera Manager Enterprise Edition. + * @param serviceName The service name. + * @return The replications resource handler. + */ + @Path("/{serviceName}/replications") + @Override + public ReplicationsResourceV13 getReplicationsResource( + @PathParam(SERVICE_NAME) String serviceName); + + /** + * Creates the HDFS directory where YARN container usage metrics are + * stored by NodeManagers for CM to read and aggregate into app usage metrics. + *

      + * Available since API v13. + *

      + * @param serviceName The YARN service name. + * @return Information about the submitted command. + */ + @POST + @Path("/{serviceName}/commands/yarnCreateCmContainerUsageInputDirCommand") + public ApiCommand createYarnCmContainerUsageInputDirCommand( + @PathParam(SERVICE_NAME) String serviceName); +} diff --git a/java/src/main/java/com/cloudera/api/v13/package-info.java b/java/src/main/java/com/cloudera/api/v13/package-info.java new file mode 100644 index 00000000..aabbdb18 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v13/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * API version 13, introduced in Cloudera Manager 5.8.0. + */ + +package com.cloudera.api.v13; From 2c25ce8a846dcecf61e396778407a3773ff815a9 Mon Sep 17 00:00:00 2001 From: Melissa Crawford Date: Sat, 31 Dec 2016 16:38:46 -0600 Subject: [PATCH 11/11] cant --> can't --- python/src/cm_shell/prettytable.py | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/python/src/cm_shell/prettytable.py b/python/src/cm_shell/prettytable.py index 30d72b5c..00b940f1 100644 --- a/python/src/cm_shell/prettytable.py +++ b/python/src/cm_shell/prettytable.py @@ -65,7 +65,7 @@ def _get_size(text): max_width = len(line) return (max_width, max_height) - + def _unicode(value, encoding="UTF-8"): if not isinstance(value, basestring): value = str(value) @@ -144,10 +144,10 @@ def __init__(self, field_names=None, **kwargs): self._vertical_char = kwargs["vertical_char"] or "|" self._horizontal_char = kwargs["horizontal_char"] or "-" self._junction_char = kwargs["junction_char"] or "+" - + self._format = kwargs["format"] or False self._attributes = kwargs["attributes"] or {} - + def __getattr__(self, name): if name == "rowcount": @@ -161,7 +161,7 @@ def __getattr__(self, name): return 0 else: raise AttributeError(name) - + def __getitem__(self, index): newtable = copy.deepcopy(self) @@ -334,7 +334,7 @@ def _set_max_width(self, val): for field in self._field_names: self._max_width[field] = val max_width = property(_get_max_width, _set_max_width) - + def _get_start(self): """Start index of the range of rows to print @@ -395,7 +395,7 @@ def _set_sort_key(self, val): self._validate_option("sort_key", val) self._sort_key = val sort_key = property(_get_sort_key, _set_sort_key) - + def _get_header(self): """Controls printing of table header with field names @@ -652,7 +652,7 @@ def del_row(self, row_index): row_index - The index of the row you want to delete. Indexing starts at 0.""" if row_index > len(self._rows)-1: - raise Exception("Cant delete row at index %d, table only has %d rows!" % (row_index, len(self._rows))) + raise Exception("Can't delete row at index %d, table only has %d rows!" % (row_index, len(self._rows))) del self._rows[row_index] def add_column(self, fieldname, column, align="c"): @@ -704,9 +704,9 @@ def copy(self): def _format_value(self, field, value): if isinstance(value, int) and field in self._int_format: - value = ("%%%sd" % self._int_format[field]) % value + value = ("%%%sd" % self._int_format[field]) % value elif isinstance(value, float) and field in self._float_format: - value = ("%%%sf" % self._float_format[field]) % value + value = ("%%%sf" % self._float_format[field]) % value return value def _compute_widths(self, rows, options): @@ -738,8 +738,8 @@ def _get_rows(self, options): Arguments: options - dictionary of option settings.""" - - # Make a copy of only those rows in the slice range + + # Make a copy of only those rows in the slice range rows = copy.deepcopy(self._rows[options["start"]:options["end"]]) # Sort if necessary if options["sortby"]: @@ -751,7 +751,7 @@ def _get_rows(self, options): # Undecorate rows = [row[1:] for row in rows] return rows - + ############################## # PLAIN TEXT STRING METHODS # ############################## @@ -812,7 +812,7 @@ def get_string(self, **kwargs): # Add bottom of border if options["border"] and not options["hrules"]: bits.append(self._hrule) - + string = "\n".join(bits) self._nonunicode = string return _unicode(string) @@ -856,7 +856,7 @@ def _stringify_header(self, options): return "".join(bits) def _stringify_row(self, row, options): - + for index, value in enumerate(row): row[index] = self._format_value(self.field_names[index], value) @@ -865,7 +865,7 @@ def _stringify_row(self, row, options): max_width = self._max_width.get(field, 0) lines = _unicode(value).split("\n") new_lines = [] - for line in lines: + for line in lines: if max_width and len(line) > max_width: line = textwrap.fill(line, max_width) new_lines.append(line) @@ -882,7 +882,7 @@ def _stringify_row(self, row, options): self._widths[index] = max(namewidth, datawidth) else: self._widths[index] = datawidth - + row_height = 0 for c in row: h = _get_size(c)[1] @@ -919,7 +919,7 @@ def _stringify_row(self, row, options): y += 1 self._hrule = self._stringify_hrule(options) - + if options["border"] and options["hrules"]== ALL: bits[row_height-1].append("\n") bits[row_height-1].append(self._hrule) @@ -1063,6 +1063,6 @@ def main(): x.add_row(["Melbourne", 1566, 3806092, 646.9]) x.add_row(["Perth", 5386, 1554769, 869.4]) print(x) - + if __name__ == "__main__": main()