Skip to content

Commit

Permalink
[java] Updated with v12 java source
Browse files Browse the repository at this point in the history
  • Loading branch information
mthakkar committed May 7, 2016
1 parent 13dc996 commit f443160
Show file tree
Hide file tree
Showing 82 changed files with 4,141 additions and 175 deletions.
207 changes: 160 additions & 47 deletions java/api-docs.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<p>
All services belong to a cluster (except for the Cloudera Management
Service), and is uniquely identified by its name within a Cloudera
Expand All @@ -1083,8 +1083,8 @@
processes.) Once created, a role cannot be reassigned to a different
host. You need to delete and re-create it.
<p>
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.
</dd>
<dt>Role Type</dt>
<dd>
Expand Down Expand Up @@ -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.
</dd>
<dt>Metrics</dt>
<dd>
<p>
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.
<p>
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.
</dd>
</dl>

<h2>Debugging the API</h2>
Expand Down Expand Up @@ -1504,56 +1516,157 @@
}
}</code>

<h3>Metrics</h3>
<h3>Querying metric data</h3>

<p>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.
<p>
Getting dfs capacity metric data for service HDFS-1.
<code>
$ curl -u admin:admin \
'http://localhost:7180/api/v1/clusters/Cluster%201%20-%20CDH4/services/hdfs1/metrics?metrics=dfs_capacity_used_non_hdfs&amp;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"
} ]</code>

[/@boilerplate]
Expand Down
6 changes: 3 additions & 3 deletions java/enunciate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd">

<api-classes>
<include pattern="com.cloudera.api.v10.*"/>
<include pattern="com.cloudera.api.v12.*"/>
</api-classes>

<services>
<rest defaultRestSubcontext="/api/v10"/>
<rest defaultRestSubcontext="/api/v12"/>
</services>

<modules>
<docs splashPackage="com.cloudera.api"
copyright="Cloudera, Inc. All rights reserved."
docsDir="apidocs"
title="Cloudera Manager API v10"
title="Cloudera Manager API v12"
groupRestResources="byPath"
freemarkerXMLProcessingTemplate="api-docs.fmt"
css="static/cms/css/api-docs.css"
Expand Down
36 changes: 33 additions & 3 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>5.7.0</version>

<properties>
<cxf.version>2.7.5</cxf.version>
<cxf.version>2.7.7</cxf.version>
<guava.version>14.0</guava.version>
<jackson2.version>2.1.0</jackson2.version>
<joda.version>2.1</joda.version>
Expand All @@ -21,7 +21,7 @@
<distributionManagement>
<repository>
<id>cdh.releases.repo</id>
<url>http://maven.jenkins.cloudera.com:8081/artifactory/libs-release-local</url>
<url>http://maven.jenkins.cloudera.com:8081/artifactory/cdh-staging-local</url>
<name>CDH Releases Repository</name>
</repository>
<snapshotRepository>
Expand Down Expand Up @@ -114,6 +114,36 @@
</plugins>
</build>
</profile>
<profile>
<!-- profile to use with Atlassian Clover for code coverage -->
<id>clover</id>
<properties>
<clover.version>4.0.3</clover.version>
<clover.generateHtml>true</clover.generateHtml>
<clover.generateXml>true</clover.generateXml>
</properties>
<dependencies>
<dependency>
<groupId>com.atlassian.clover</groupId>
<artifactId>clover</artifactId>
<version>${clover.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Clover plugin to enable maven to create instantiated jars that will record code coverage -->
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>${clover.version}</version>
<configuration>
<generateHtml>${clover.generateHtml}</generateHtml>
<generateXml>${clover.generateXml}</generateXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
Expand Down Expand Up @@ -153,7 +183,7 @@
<pattern>com.</pattern>
<shadedPattern>${privateClassPath}.com.</shadedPattern>
<includes>
<include>com.google.guava.**</include>
<include>com.google.common.**</include>
<include>com.fasterxml.jackson.**</include>
</includes>
</relocation>
Expand Down
17 changes: 16 additions & 1 deletion java/src/main/java/com/cloudera/api/ApiRootResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
* <p>
Expand Down
11 changes: 11 additions & 0 deletions java/src/main/java/com/cloudera/api/ApiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }

}
Expand Down
Loading

0 comments on commit f443160

Please sign in to comment.