Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BalakrishnaV committed Jul 30, 2015
1 parent ee76f32 commit 5648023
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/ResourceManag
#### ClusterMetrics
#### Nodes
#### SchedulerInfo
#### Apps
#### AggregatedApps
Metrics under AggregatedApps are aggregated metrics from all running and recently finished apps. To specify the period for which metrics are gathered, set `aggregateAppPeriod` in config.yml.
Expand Down Expand Up @@ -203,7 +202,7 @@ Custom Dashboard
Contributing
------------
Always feel free to fork and contribute any changes directly via <a href="https://github.com/Appdynamics/hadoop-monitoring-extension">GitHub</a>.
Always feel free to fork and contribute any changes directly here on GitHub.
Community
Expand Down
39 changes: 19 additions & 20 deletions src/main/java/com/appdynamics/monitors/hadoop/HadoopMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,33 @@ private boolean determineIfHadoopHasResourceManger(String hadoopVersion) {
}

private void printResourceManagerMetrics(String metricPathPrefix, Map<String, Object> hadoopMetrics) {
try {
for (Map.Entry<String, Object> entry : hadoopMetrics.entrySet()) {
printMetric(metricPathPrefix + entry.getKey(), entry.getValue());
}
} catch (Exception e) {
logger.error("Error printing ResourceManager Metrics: ", e);
for (Map.Entry<String, Object> entry : hadoopMetrics.entrySet()) {
printMetric(metricPathPrefix + entry.getKey(), entry.getValue());
}
}

private void printAmbariMetrics(String metricPathPrefix, Map<String, Number> ambariMetrics) {
try {
for (Map.Entry<String, Number> entry : ambariMetrics.entrySet()) {
printMetric(metricPathPrefix + entry.getKey(), entry.getValue());
}
} catch (Exception e) {
logger.error("Error printing Ambari Metrics: ", e);
for (Map.Entry<String, Number> entry : ambariMetrics.entrySet()) {
printMetric(metricPathPrefix + entry.getKey(), entry.getValue());
}
}

private void printMetric(String metricName, Object metricValue) {
MetricWriter metricWriter = getMetricWriter(metricName,
MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE,
MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL
);
if (metricValue != null && metricValue instanceof Number) {
String value = MetricUtils.toWholeNumberString(metricValue);
metricWriter.printMetric(value);
try {
MetricWriter metricWriter = getMetricWriter(metricName,
MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE,
MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL
);
if (metricValue != null && metricValue instanceof Number) {
String value = MetricUtils.toWholeNumberString(metricValue);
metricWriter.printMetric(value);
if (logger.isDebugEnabled()) {
logger.debug("Metric: " + metricName + " value: "+ metricValue+" -> " + value);
}
}
} catch (Exception e) {
logger.error("Exception while printing the metric: " + metricName + " value: "+ metricValue, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Map<String, Number> fetchAmbariMetrics() throws AmbariMonitorException {
if (httpClient != null) {
httpClient.close();
}
if (executor != null) {
if (executor != null && !executor.isShutdown()) {
executor.shutdown();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public void populate(Map<String, Object> metrics) {
getClusterMetrics();
getClusterScheduler();
getAggrApps();
getApplicationMetrics();
// Added for RBC but then ignoring as there were lot of auto-generated apps which were causing instability to Controller
// getApplicationMetrics();
getClusterNodes();
}

Expand Down Expand Up @@ -315,6 +316,7 @@ private void getApplicationMetrics() {
for (Map<String, Object> app : appList) {

String appName = (String) app.get("name");

String metricPath = "Apps|" + appName + "|";
if (app.get("finishedTime") != null) {
metrics.put(metricPath + "finishedTime", app.get("finishedTime"));
Expand All @@ -329,6 +331,8 @@ private void getApplicationMetrics() {
metrics.put(metricPath + "runningContainers", app.get("runningContainers"));
metrics.put(metricPath + "memorySeconds", app.get("memorySeconds"));
metrics.put(metricPath + "vcoreSeconds", app.get("vcoreSeconds"));
String appState = (String) app.get("state");
metrics.put(metricPath + "state", AppState.valueOf(appState).ordinal());
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -390,6 +394,6 @@ private Map<String, Object> getNode(Map<String, Object> node, String hierarchy)
}

private enum AppState {
NEW, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED
NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED
}
}

0 comments on commit 5648023

Please sign in to comment.