Sfoglia il codice sorgente

AMBARI-12718 AMS is doing a (Select *) for certain point in time metrics from Dashboard page (additional patch) (dsen)

Dmytro Sen 10 anni fa
parent
commit
6ac03f0433

+ 5 - 5
ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java

@@ -443,16 +443,16 @@ public class PhoenixTransactSQL {
       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,
+      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_SINGLE_HOST,
+        stmtStr = String.format(GET_LATEST_METRIC_SQL,
           METRICS_RECORD_TABLE_NAME,
-          condition.getConditionClause(),
           METRICS_RECORD_TABLE_NAME,
           condition.getConditionClause());
       }

+ 3 - 3
ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java

@@ -225,7 +225,7 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetLatestMetricSqlStmtSingleHostName() throws SQLException {
     Condition condition = new DefaultCondition(
-      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      Arrays.asList("cpu_user"), Collections.singletonList("h1"),
       "a1", "i1", null, null, null, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
@@ -235,10 +235,10 @@ public class TestPhoenixTransactSQL {
         .andReturn(preparedStatement);
     expect(preparedStatement.getParameterMetaData())
       .andReturn(parameterMetaData).times(2);
-    // 10 = (1 instance_id + 1 appd_id + 1 hostname + 2 metric names) * 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(10).times(2);
+      .andReturn(8).times(2);
 
     replay(connection, preparedStatement, parameterMetaData);
     PhoenixTransactSQL.prepareGetLatestMetricSqlStmt(connection, condition);