ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-13103 Remove workaround code in PhoenixTransactSQL.prepareGetLatestMetricSqlStmt() (dsen)
Date Thu, 17 Sep 2015 10:39:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 50c6fa53c -> a2260c7f0


AMBARI-13103 Remove workaround code in PhoenixTransactSQL.prepareGetLatestMetricSqlStmt()
(dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a2260c7f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a2260c7f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a2260c7f

Branch: refs/heads/trunk
Commit: a2260c7f0ed96f57ec7bf6974aa30061a948e713
Parents: 50c6fa5
Author: Dmytro Sen <dsen@apache.org>
Authored: Thu Sep 17 13:39:20 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Thu Sep 17 13:39:20 2015 +0300

----------------------------------------------------------------------
 .../timeline/query/PhoenixTransactSQL.java      | 36 +++-----------------
 .../timeline/TestPhoenixTransactSQL.java        | 26 --------------
 2 files changed, 4 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a2260c7f/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
index 77652dc..1d669eb 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
@@ -187,24 +187,6 @@ public class PhoenixTransactSQL {
     "AND E.APP_ID=I.APP_ID " +
     "AND E.INSTANCE_ID=I.INSTANCE_ID";
 
-  /**
-   * Get latest metrics for a single host
-   *
-   * Different queries for a number of hosts and a single host are used due to
-   * bug in Apache Phoenix
-   */
-  public static final String GET_LATEST_METRIC_SQL_SINGLE_HOST = "SELECT " +
-    "METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID, SERVER_TIME, START_TIME, " +
-    "UNITS, METRIC_SUM, METRIC_MAX, METRIC_MIN, METRIC_COUNT, METRICS " +
-    "FROM %s " +
-    "WHERE %s " +
-    "AND (METRIC_NAME, HOSTNAME, SERVER_TIME, APP_ID, INSTANCE_ID) = ANY " +
-    "(SELECT " +
-    "METRIC_NAME, HOSTNAME, MAX(SERVER_TIME) AS SERVER_TIME, APP_ID, INSTANCE_ID " +
-    "FROM %s " +
-    "WHERE %s " +
-    "GROUP BY METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID)";
-
   public static final String GET_METRIC_AGGREGATE_ONLY_SQL = "SELECT %s " +
     "METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID, SERVER_TIME, " +
     "UNITS, " +
@@ -469,20 +451,10 @@ public class PhoenixTransactSQL {
     if (condition.getStatement() != null) {
       stmtStr = condition.getStatement();
     } else {
-      //if not a single metric for a single host
-      if (condition.getHostnames().size() == 1
-        && condition.getMetricNames().size() == 1) {
-        stmtStr = String.format(GET_LATEST_METRIC_SQL_SINGLE_HOST,
-          METRICS_RECORD_TABLE_NAME,
-          condition.getConditionClause(),
-          METRICS_RECORD_TABLE_NAME,
-          condition.getConditionClause());
-      } else {
-        stmtStr = String.format(GET_LATEST_METRIC_SQL,
-          METRICS_RECORD_TABLE_NAME,
-          METRICS_RECORD_TABLE_NAME,
-          condition.getConditionClause());
-      }
+      stmtStr = String.format(GET_LATEST_METRIC_SQL,
+        METRICS_RECORD_TABLE_NAME,
+        METRICS_RECORD_TABLE_NAME,
+        condition.getConditionClause());
     }
 
     if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a2260c7f/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
index 8693a21..a3b5c72 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
@@ -356,32 +356,6 @@ public class TestPhoenixTransactSQL {
   }
 
   @Test
-  public void testPrepareGetLatestMetricSqlStmtSingleHostName() throws SQLException {
-    Condition condition = new DefaultCondition(
-      Arrays.asList("cpu_user"), Collections.singletonList("h1"),
-      "a1", "i1", null, null, null, null, false);
-    Connection connection = createNiceMock(Connection.class);
-    PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
-    ParameterMetaData parameterMetaData = createNiceMock(ParameterMetaData.class);
-    Capture<String> stmtCapture = new Capture<String>();
-    expect(connection.prepareStatement(EasyMock.and(EasyMock.anyString(), EasyMock.capture(stmtCapture))))
-        .andReturn(preparedStatement);
-    expect(preparedStatement.getParameterMetaData())
-      .andReturn(parameterMetaData).times(2);
-    // 8 = (1 instance_id + 1 appd_id + 1 hostname + 1 metric name) * 2,
-    // For GET_LATEST_METRIC_SQL_SINGLE_HOST parameters should be set 2 times
-    expect(parameterMetaData.getParameterCount())
-      .andReturn(8).times(2);
-
-    replay(connection, preparedStatement, parameterMetaData);
-    PhoenixTransactSQL.prepareGetLatestMetricSqlStmt(connection, condition);
-    String stmt = stmtCapture.getValue();
-    Assert.assertTrue(stmt.contains("FROM METRIC_RECORD"));
-    Assert.assertTrue(stmt.contains("ANY"));
-    verify(connection, preparedStatement, parameterMetaData);
-  }
-
-  @Test
   public void testPrepareGetLatestMetricSqlStmtMultipleHostNames() throws SQLException {
     Condition condition = new DefaultCondition(
       Arrays.asList("cpu_user", "mem_free"), Arrays.asList("h1", "h2"),


Mime
View raw message