I am trying to fetch the number of Flume agents are running on My CDH5.8 cluster using Cloudera Manager API .
https://cloudera.github.io/cm_api/
Till now i could not figure out which RESTful Model I should consider or the related Java class. If any one can help or to inform the the referenced Java class to look into that will be great
If you use the following API:
The size of the items
array in the JSON object returned will be the number of Flume agents. To find the number of running agents, for each item, check that roleState
equals STARTED
.
The Java class ApiRole
is probably what you need. This code snippet from the whirr-cm example is close to what you want.
for (ApiService apiService : apiResourceRootV3.getClustersResource().getServicesResource(getName(cluster))
.readServices(DataView.SUMMARY)) {
for (ApiRole apiRole : apiResourceRootV3.getClustersResource().getServicesResource(getName(cluster))
.getRolesResource(apiService.getName()).readRoles()) {
if (apiRole.getRoleState().equals(ApiRoleState.STARTED)) {
servicesNotStarted.remove(apiRole.getName());
}
}
}
You would just need to limit this to the Flume service.