You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/08/21 22:41:00 UTC
git commit: AMBARI-2982. Nullpointer exception with getting Ganglia
metrics. (swagle)
Updated Branches:
refs/heads/trunk 67fd6fb7c -> 88cd415ca
AMBARI-2982. Nullpointer exception with getting Ganglia metrics. (swagle)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/88cd415c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/88cd415c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/88cd415c
Branch: refs/heads/trunk
Commit: 88cd415ca5ae69fa13213ab866129caf6b0dbd54
Parents: 67fd6fb
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Wed Aug 21 13:31:53 2013 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Wed Aug 21 13:31:53 2013 -0700
----------------------------------------------------------------------
.../ganglia/GangliaPropertyProvider.java | 37 ++++++++++++++++----
1 file changed, 30 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88cd415c/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
index 3dba5e2..5aedfc9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
@@ -421,10 +421,22 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider {
reader = new BufferedReader(new InputStreamReader(
getStreamProvider().readFrom(spec)));
- int startTime = convertToNumber(reader.readLine()).intValue();
+ String feedStart = reader.readLine();
+ if (feedStart == null || feedStart.isEmpty()) {
+ LOG.info("Empty feed while getting ganglia metrics for spec => "+
+ spec);
+ return Collections.emptySet();
+ }
+ int startTime = convertToNumber(feedStart).intValue();
String dsName = reader.readLine();
- while(! dsName.equals("[AMBARI_END]")) {
+ if (dsName == null || dsName.isEmpty()) {
+ LOG.info("Feed without body while reading ganglia metrics for spec " +
+ "=> " + spec);
+ return Collections.emptySet();
+ }
+
+ while(!dsName.equals("[AMBARI_END]")) {
GangliaMetric metric = new GangliaMetric();
List<GangliaMetric.TemporalMetric> listTemporalMetrics =
new ArrayList<GangliaMetric.TemporalMetric>();
@@ -456,12 +468,23 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider {
}
dsName = reader.readLine();
+ if (dsName == null || dsName.isEmpty()) {
+ LOG.info("Unexpected end of stream reached while getting ganglia " +
+ "metrics for spec => " + spec);
+ return Collections.emptySet();
+ }
}
- int endTime = convertToNumber(reader.readLine()).intValue();
-
- int totalTime = endTime - startTime;
- if (LOG.isInfoEnabled() && totalTime > POPULATION_TIME_UPPER_LIMIT) {
- LOG.info("Ganglia resource population time: " + totalTime);
+ String feedEnd = reader.readLine();
+ if (feedEnd == null || feedEnd.isEmpty()) {
+ LOG.info("Error reading end of feed while getting ganglia metrics " +
+ "for spec => " + spec);
+ } else {
+
+ int endTime = convertToNumber(feedEnd).intValue();
+ int totalTime = endTime - startTime;
+ if (LOG.isInfoEnabled() && totalTime > POPULATION_TIME_UPPER_LIMIT) {
+ LOG.info("Ganglia resource population time: " + totalTime);
+ }
}
} catch (IOException e) {
if (LOG.isErrorEnabled()) {