asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: small JSON cleanup in ClusterNodeDetailsAPIServlet
Date Thu, 12 Jan 2017 23:13:11 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 456ff9ded -> d79c66481


small JSON cleanup in ClusterNodeDetailsAPIServlet

Change-Id: If4a261d27b74934f122d9efbd5cde70efa6f9fd5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1426
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>


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

Branch: refs/heads/master
Commit: d79c66481025bc37ce6c5e9cbd4b59eac66e17d0
Parents: 456ff9d
Author: Till Westmann <tillw@apache.org>
Authored: Mon Jan 9 17:50:30 2017 -0800
Committer: Till Westmann <tillw@apache.org>
Committed: Thu Jan 12 15:12:18 2017 -0800

----------------------------------------------------------------------
 .../servlet/ClusterNodeDetailsAPIServlet.java   | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d79c6648/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
index 590e869..d737ad8 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
@@ -33,6 +33,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import org.apache.asterix.runtime.util.ClusterStateManager;
@@ -161,18 +162,21 @@ public class ClusterNodeDetailsAPIServlet extends ClusterAPIServlet
{
         for (String key : keys) {
             if (key.startsWith("gc-")) {
                 json.remove(key);
-            } else if (json.get(key) instanceof ArrayNode) {
-                final ArrayNode valueArray = (ArrayNode) json.get(key);
-                // fixup an index of -1 to the final element in the array (i.e. RRD_SIZE)
-                if (index == -1) {
-                    index = valueArray.size() - 1;
+            } else {
+                final JsonNode keyNode = json.get(key);
+                if (keyNode instanceof ArrayNode) {
+                    final ArrayNode valueArray = (ArrayNode) keyNode;
+                    // fixup an index of -1 to the final element in the array (i.e. RRD_SIZE)
+                    if (index == -1) {
+                        index = valueArray.size() - 1;
+                    }
+                    final JsonNode value = valueArray.get(index);
+                    json.remove(key);
+                    json.set(key.replaceAll("s$",""), value);
                 }
-                final Object value = valueArray.get(index);
-                json.remove(key);
-                json.putPOJO(key.replaceAll("s$",""), value);
             }
         }
-        List<ObjectNode> gcs = new ArrayList<>();
+        ArrayNode gcs = om.createArrayNode();
 
         for (int i = 0; i < gcNames.size(); i++) {
             ObjectNode gc = om.createObjectNode();
@@ -181,7 +185,7 @@ public class ClusterNodeDetailsAPIServlet extends ClusterAPIServlet {
             gc.set("collection-count", ((ArrayNode)gcCollectionCounts.get(i)).get(index));
             gcs.add(gc);
         }
-        json.putPOJO("gcs", gcs);
+        json.set("gcs", gcs);
 
         return json;
     }


Mime
View raw message