drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansi...@apache.org
Subject [5/7] drill git commit: DRILL-2593: 500 error when crc for a query profile is out of sync
Date Thu, 23 Jun 2016 18:10:45 GMT
DRILL-2593: 500 error when crc for a query profile is out of sync


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

Branch: refs/heads/1.7.0
Commit: 4687a8b50c9cb032229c51084e56a5fab006ffc5
Parents: 23a46a0
Author: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
Authored: Sun Jun 12 13:48:54 2016 +0000
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Wed Jun 22 15:15:54 2016 -0700

----------------------------------------------------------------------
 .../server/rest/profile/ProfileResources.java   | 55 +++++++++++++-------
 .../src/main/resources/rest/profile/list.ftl    |  9 ++++
 2 files changed, 46 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/4687a8b5/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
index 05441c0..d2e953d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
@@ -18,9 +18,9 @@
 package org.apache.drill.exec.server.rest.profile;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -84,7 +84,7 @@ public class ProfileResources {
       this.time = new Date(time);
       this.foreman = foreman;
       this.location = "http://localhost:8047/profile/" + queryId + ".json";
-      this.query = query = query.substring(0,  Math.min(query.length(), 150));
+      this.query = query.substring(0,  Math.min(query.length(), 150));
       this.state = state;
       this.user = user;
     }
@@ -137,10 +137,12 @@ public class ProfileResources {
   public class QProfiles {
     private List<ProfileInfo> runningQueries;
     private List<ProfileInfo> finishedQueries;
+    private List<String> errors;
 
-    public QProfiles(List<ProfileInfo> runningQueries, List<ProfileInfo> finishedQueries)
{
+    public QProfiles(List<ProfileInfo> runningQueries, List<ProfileInfo> finishedQueries,
List<String> erorrs) {
       this.runningQueries = runningQueries;
       this.finishedQueries = finishedQueries;
+      this.errors = erorrs;
     }
 
     public List<ProfileInfo> getRunningQueries() {
@@ -150,6 +152,8 @@ public class ProfileResources {
     public List<ProfileInfo> getFinishedQueries() {
       return finishedQueries;
     }
+
+    public List<String> getErrors() { return errors; }
   }
 
   @GET
@@ -160,33 +164,48 @@ public class ProfileResources {
       final PersistentStore<QueryProfile> completed = getProvider().getOrCreateStore(QueryManager.QUERY_PROFILE);
       final TransientStore<QueryInfo> running = getCoordinator().getOrCreateTransientStore(QueryManager.RUNNING_QUERY_INFO);
 
+      final List<String> errors = Lists.newArrayList();
+
       final List<ProfileInfo> runningQueries = Lists.newArrayList();
 
-      for (final Map.Entry<String, QueryInfo> entry: Lists.newArrayList(running.entries()))
{
-        final QueryInfo profile = entry.getValue();
-        if (principal.canManageProfileOf(profile.getUser())) {
-          runningQueries.add(new ProfileInfo(entry.getKey(), profile.getStart(), profile.getForeman().getAddress(),
-              profile.getQuery(), profile.getState().name(), profile.getUser()));
+      final Iterator<Map.Entry<String, QueryInfo>> runningEntries = running.entries();
+      while (runningEntries.hasNext()) {
+        try {
+          final Map.Entry<String, QueryInfo> runningEntry = runningEntries.next();
+          final QueryInfo profile = runningEntry.getValue();
+          if (principal.canManageProfileOf(profile.getUser())) {
+            runningQueries.add(new ProfileInfo(runningEntry.getKey(), profile.getStart(),
profile.getForeman().getAddress(), profile.getQuery(), profile.getState().name(), profile.getUser()));
+          }
+        } catch (Exception e) {
+          errors.add(e.getMessage());
+          logger.error("Error getting running query info.", e);
         }
       }
 
       Collections.sort(runningQueries, Collections.reverseOrder());
 
-      List<ProfileInfo> finishedQueries = Lists.newArrayList();
-      for (Map.Entry<String, QueryProfile> entry : Lists.newArrayList(completed.getRange(0,
MAX_PROFILES))) {
-        QueryProfile profile = entry.getValue();
-        if (principal.canManageProfileOf(profile.getUser())) {
-          finishedQueries.add(new ProfileInfo(entry.getKey(), profile.getStart(), profile.getForeman().getAddress(),
-              profile.getQuery(), profile.getState().name(), profile.getUser()));
+      final List<ProfileInfo> finishedQueries = Lists.newArrayList();
+
+      final Iterator<Map.Entry<String, QueryProfile>> range = completed.getRange(0,
MAX_PROFILES);
+      while (range.hasNext()) {
+        try {
+          final Map.Entry<String, QueryProfile> profileEntry = range.next();
+          final QueryProfile profile = profileEntry.getValue();
+          if (principal.canManageProfileOf(profile.getUser())) {
+            finishedQueries.add(new ProfileInfo(profileEntry.getKey(), profile.getStart(),
profile.getForeman().getAddress(), profile.getQuery(), profile.getState().name(), profile.getUser()));
+          }
+        } catch (Exception e) {
+          errors.add(e.getMessage());
+          logger.error("Error getting finished query profile.", e);
         }
       }
 
-      return new QProfiles(runningQueries, finishedQueries);
+      return new QProfiles(runningQueries, finishedQueries, errors);
     } catch (Exception e) {
-      logger.debug("Failed to get profiles from persistent or ephemeral store.");
-      return new QProfiles(new ArrayList<ProfileInfo>(), new ArrayList<ProfileInfo>());
+      throw UserException.resourceError(e)
+          .message("Failed to get profiles from persistent or ephemeral store.")
+          .build(logger);
     }
-
   }
 
   @GET

http://git-wip-us.apache.org/repos/asf/drill/blob/4687a8b5/exec/java-exec/src/main/resources/rest/profile/list.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/profile/list.ftl b/exec/java-exec/src/main/resources/rest/profile/list.ftl
index cf92ede..88d1407 100644
--- a/exec/java-exec/src/main/resources/rest/profile/list.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/list.ftl
@@ -17,6 +17,15 @@
   <a href="/queries">back</a><br/>
   <div class="page-header">
   </div>
+  <#if (model.getErrors()?size > 0) >
+    <div id="message" class="alert alert-danger alert-dismissable">
+        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
+        <strong>Failed to get profiles:</strong><br>
+        <#list model.getErrors() as error>
+          ${error}<br>
+        </#list>
+    </div>
+  </#if>
   <#if (model.getRunningQueries()?size > 0) >
     <h3>Running Queries</h3>
     <div class="table-responsive">


Mime
View raw message