You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2017/10/10 20:01:01 UTC
asterixdb git commit: [NO ISSUE][*DB][API] Emit exception text on
diag eval error
Repository: asterixdb
Updated Branches:
refs/heads/master 21ed0f726 -> f07e73ae4
[NO ISSUE][*DB][API] Emit exception text on diag eval error
Failure to evaluate diagnostic info generates log & emits exception
string as value, instead of generating 500 & displaying no diag info
Change-Id: Ib4997c57ec3aca4b17c975098865486a6cd72531
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2061
Reviewed-by: Till Westmann <ti...@apache.org>
Tested-by: Michael Blow <mb...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/f07e73ae
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/f07e73ae
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/f07e73ae
Branch: refs/heads/master
Commit: f07e73ae4fe7e911db5ca0c240d1d80fb8d66dda
Parents: 21ed0f7
Author: Michael Blow <mi...@couchbase.com>
Authored: Tue Oct 10 12:27:58 2017 -0400
Committer: Michael Blow <mb...@apache.org>
Committed: Tue Oct 10 13:00:30 2017 -0700
----------------------------------------------------------------------
.../api/http/server/DiagnosticsApiServlet.java | 32 ++++++++++++--------
1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f07e73ae/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
index 3fe591f..eafda09 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/DiagnosticsApiServlet.java
@@ -45,6 +45,7 @@ import org.apache.hyracks.util.JSONUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
+
import io.netty.handler.codec.http.HttpResponseStatus;
public class DiagnosticsApiServlet extends NodeControllerDetailsApiServlet {
@@ -106,9 +107,8 @@ public class DiagnosticsApiServlet extends NodeControllerDetailsApiServlet {
ncData = new HashMap<>();
ncData.put("threaddump",
executor.submit(() -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getThreadDump(nc)))));
- ncData.put("config",
- executor.submit(
- () -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(nc, false, true)))));
+ ncData.put("config", executor
+ .submit(() -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(nc, false, true)))));
ncData.put("stats", executor.submit(() -> fixupKeys(processNodeStats(hcc, nc))));
return ncData;
}
@@ -118,21 +118,29 @@ public class DiagnosticsApiServlet extends NodeControllerDetailsApiServlet {
ccFutureData = new HashMap<>();
ccFutureData.put("threaddump",
executor.submit(() -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getThreadDump(null)))));
- ccFutureData.put("config",
- executor.submit(() -> fixupKeys(
- (ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(null, false, true)))));
- ccFutureData.put("stats",
- executor.submit(() -> fixupKeys(
- (ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(null, true, false)))));
+ ccFutureData.put("config", executor.submit(
+ () -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(null, false, true)))));
+ ccFutureData.put("stats", executor.submit(
+ () -> fixupKeys((ObjectNode) OBJECT_MAPPER.readTree(hcc.getNodeDetailsJSON(null, true, false)))));
return ccFutureData;
}
protected Map<String, JsonNode> resolveFutures(Map<String, Future<JsonNode>> futureMap)
- throws ExecutionException, InterruptedException {
+ throws InterruptedException {
Map<String, JsonNode> result = new HashMap<>();
+ resolveFutures(futureMap, result, result);
+ return result;
+ }
+
+ protected void resolveFutures(Map<String, Future<JsonNode>> futureMap, Map<String, JsonNode> outputMap,
+ Map<String, JsonNode> errorMap) throws InterruptedException {
for (Map.Entry<String, Future<JsonNode>> entry : futureMap.entrySet()) {
- result.put(entry.getKey(), entry.getValue().get());
+ try {
+ outputMap.put(entry.getKey(), entry.getValue().get());
+ } catch (ExecutionException e) {
+ LOGGER.log(Level.WARNING, "unexpected exception obtaining value for " + entry.getKey(), e);
+ errorMap.put(entry.getKey(), new TextNode(String.valueOf(e)));
+ }
}
- return result;
}
}