tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [3/6] git commit: TAJO-1074: Query calculates wrong progress before subquery init. (jinho)
Date Wed, 01 Oct 2014 15:38:26 GMT
TAJO-1074: Query calculates wrong progress before subquery init. (jinho)

Closes #162


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

Branch: refs/heads/block_iteration
Commit: 35e49f039ccabf46d8cf20511c189aea7c15571a
Parents: f295ddc
Author: jhkim <jhkim@apache.org>
Authored: Wed Oct 1 13:55:24 2014 +0900
Committer: jhkim <jhkim@apache.org>
Committed: Wed Oct 1 13:55:24 2014 +0900

----------------------------------------------------------------------
 CHANGES                                         |  2 +
 .../main/java/org/apache/tajo/cli/TajoCli.java  |  2 +-
 .../apache/tajo/master/querymaster/Query.java   | 12 +---
 .../main/java/org/apache/tajo/util/JSPUtil.java |  2 +-
 .../master/querymaster/TestQueryProgress.java   | 73 ++++++++++++++++++++
 5 files changed, 79 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/35e49f03/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 48fba31..ad9a490 100644
--- a/CHANGES
+++ b/CHANGES
@@ -155,6 +155,8 @@ Release 0.9.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1074: Query calculates wrong progress before subquery init. (jinho)
+
     TAJO-1025: Network disconnection during query processing can cause 
     infinite exceptions. (Jihun Kang via jinho)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/35e49f03/tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java b/tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java
index d5040bd..51c8c9f 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java
@@ -587,7 +587,7 @@ public class TajoCli {
         if (TajoClient.isInCompleteState(status.getState()) && status.getState()
!= QueryState.QUERY_KILL_WAIT) {
           break;
         } else {
-          Thread.sleep(Math.min(100 * progressRetries, 1000));
+          Thread.sleep(Math.min(200 * progressRetries, 1000));
           progressRetries += 2;
         }
       }

http://git-wip-us.apache.org/repos/asf/tajo/blob/35e49f03/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Query.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Query.java b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Query.java
index 7063197..c2cf54e 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Query.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Query.java
@@ -245,26 +245,18 @@ public class Query implements EventHandler<QueryEvent> {
       synchronized(subqueries) {
         tempSubQueries.addAll(subqueries.values());
       }
+
       float [] subProgresses = new float[tempSubQueries.size()];
-      boolean finished = true;
       for (SubQuery subquery: tempSubQueries) {
         if (subquery.getState() != SubQueryState.NEW) {
           subProgresses[idx] = subquery.getProgress();
-          if (finished && subquery.getState() != SubQueryState.SUCCEEDED) {
-            finished = false;
-          }
         } else {
           subProgresses[idx] = 0.0f;
-          finished = false;
         }
         idx++;
       }
 
-      if (finished) {
-        return 1.0f;
-      }
-
-      float totalProgress = 0;
+      float totalProgress = 0.0f;
       float proportion = 1.0f / (float)(getExecutionBlockCursor().size() - 1); // minus one
is due to
 
       for (int i = 0; i < subProgresses.length; i++) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/35e49f03/tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java b/tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java
index 8aebab0..fb7ba26 100644
--- a/tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java
+++ b/tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java
@@ -218,7 +218,7 @@ public class JSPUtil {
     });
   }
 
-  static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("###.0");
+  static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("###.#");
   public static String percentFormat(float value) {
     return PERCENT_FORMAT.format(value * 100.0f);
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/35e49f03/tajo-core/src/test/java/org/apache/tajo/master/querymaster/TestQueryProgress.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/master/querymaster/TestQueryProgress.java
b/tajo-core/src/test/java/org/apache/tajo/master/querymaster/TestQueryProgress.java
new file mode 100644
index 0000000..0f925bb
--- /dev/null
+++ b/tajo-core/src/test/java/org/apache/tajo/master/querymaster/TestQueryProgress.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.master.querymaster;
+
+import org.apache.tajo.*;
+import org.apache.tajo.client.QueryStatus;
+import org.apache.tajo.client.TajoClient;
+import org.apache.tajo.conf.TajoConf;
+import org.apache.tajo.ipc.ClientProtos;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.junit.Assert.*;
+
+@Category(IntegrationTest.class)
+public class TestQueryProgress {
+  private static TajoTestingCluster cluster;
+  private static TajoConf conf;
+  private static TajoClient client;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    cluster = TpchTestBase.getInstance().getTestingCluster();
+    conf = cluster.getConfiguration();
+    client = new TajoClient(conf);
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    client.close();
+  }
+
+  @Test(timeout = 10000)
+  public final void testQueryProgress() throws Exception {
+    ClientProtos.SubmitQueryResponse res = client.executeQuery("select l_orderkey from lineitem
group by l_orderkey");
+    QueryId queryId = new QueryId(res.getQueryId());
+
+    float prevProgress = 0;
+    while (true) {
+      QueryStatus status = client.getQueryStatus(queryId);
+      if (status == null) continue;
+
+      float progress = status.getProgress();
+
+      if (prevProgress > progress) {
+        fail("Previous progress: " + prevProgress + ", Current progress : " + progress);
+      }
+      prevProgress = progress;
+      assertTrue(progress <= 1.0f);
+
+      if (TajoClient.isInCompleteState(status.getState())) break;
+    }
+  }
+}


Mime
View raw message