Repository: ambari Updated Branches: refs/heads/branch-2.0.0 0b9f69500 -> 4528a5306
AMBARI-9771 AMS: ResultSpooler spill files are left behind in /tmp folder (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4528a530 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4528a530 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4528a530 Branch: refs/heads/branch-2.0.0 Commit: 4528a530662d57ccfe92eb1ee321766bf7d0baf5 Parents: 0b9f695 Author: Dmytro Sen <[email protected]> Authored: Tue Feb 24 19:57:14 2015 +0200 Committer: Dmytro Sen <[email protected]> Committed: Wed Feb 25 13:41:22 2015 +0200 ---------------------------------------------------------------------- .../metrics/timeline/PhoenixHBaseAccessor.java | 54 +++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4528a530/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java index af05d93..36f0ab9 100644 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java +++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java @@ -34,7 +34,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -408,6 +407,7 @@ public class PhoenixHBaseAccessor { Connection conn = getConnection(); PreparedStatement stmt = null; + ResultSet rs = null; TimelineMetrics metrics = new TimelineMetrics(); try { @@ -416,14 +416,20 @@ public class PhoenixHBaseAccessor { stmt = getLatestMetricRecords(condition, conn, metrics); } else { stmt = PhoenixTransactSQL.prepareGetMetricsSqlStmt(conn, condition); - - ResultSet rs = stmt.executeQuery(); + rs = stmt.executeQuery(); while (rs.next()) { appendMetricFromResultSet(metrics, condition, metricFunctions, rs); } } } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + // Ignore + } + } if (stmt != null) { try { stmt.close(); @@ -492,11 +498,21 @@ public class PhoenixHBaseAccessor { splitCondition.setCurrentMetric(metricName); stmt = PhoenixTransactSQL.prepareGetLatestMetricSqlStmt(conn, splitCondition); - - ResultSet rs = stmt.executeQuery(); - while (rs.next()) { - TimelineMetric metric = getLastTimelineMetricFromResultSet(rs); - metrics.getMetrics().add(metric); + ResultSet rs = null; + try { + rs = stmt.executeQuery(); + while (rs.next()) { + TimelineMetric metric = getLastTimelineMetricFromResultSet(rs); + metrics.getMetrics().add(metric); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + // Ignore + } + } } } @@ -601,12 +617,22 @@ public class PhoenixHBaseAccessor { splitCondition.setCurrentMetric(metricName); stmt = PhoenixTransactSQL.prepareGetLatestAggregateMetricSqlStmt(conn, splitCondition); - - ResultSet rs = stmt.executeQuery(); - while (rs.next()) { - TimelineMetric metric = getAggregateTimelineMetricFromResultSet(rs, - new Function()); - metrics.getMetrics().add(metric); + ResultSet rs = null; + try { + rs = stmt.executeQuery(); + while (rs.next()) { + TimelineMetric metric = getAggregateTimelineMetricFromResultSet(rs, + new Function()); + metrics.getMetrics().add(metric); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + // Ignore + } + } } }
