timoninmaxim commented on code in PR #298:
URL: https://github.com/apache/ignite-extensions/pull/298#discussion_r2063094247


##########
modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/SystemViewHandler.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.ignite.internal.performancestatistics.handlers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import static 
org.apache.ignite.internal.performancestatistics.util.Utils.MAPPER;
+
+/**
+ * Builds JSON with system view tables.
+ *
+ * Example:
+ * <pre>
+ * {
+ *    $nodeId: {
+ *      $systemViewTable: [
+ *        { $column1: $value1, $column2: $value2 },
+ *        { $column1: $value3, $column2: $value4 }
+ *        ]
+ *    }
+ * }
+ * </pre>
+ */
+public class SystemViewHandler implements IgnitePerformanceStatisticsHandler {
+    /** System view tables. */
+    private final Map<UUID, Map<String, List<Map<String, Object>>>> results = 
new HashMap<>();
+
+    /** {@inheritDoc} */
+    @Override public void systemView(UUID nodeId, String viewName, 
List<String> schema, List<Object> data) {
+        Map<String, List<Map<String, Object>>> nodeData = 
results.computeIfAbsent(nodeId, uuid -> new HashMap<>());
+
+        List<Map<String, Object>> viewData = 
nodeData.computeIfAbsent(viewName, string -> new ArrayList<>());
+
+        Map <String, Object> row = new LinkedHashMap<>(schema.size());

Review Comment:
   excess white space after Map



##########
modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/SystemViewHandler.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.ignite.internal.performancestatistics.handlers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import static 
org.apache.ignite.internal.performancestatistics.util.Utils.MAPPER;
+
+/**
+ * Builds JSON with system view tables.
+ *
+ * Example:
+ * <pre>
+ * {
+ *    $nodeId: {
+ *      $systemViewTable: [
+ *        { $column1: $value1, $column2: $value2 },
+ *        { $column1: $value3, $column2: $value4 }
+ *        ]
+ *    }
+ * }
+ * </pre>
+ */
+public class SystemViewHandler implements IgnitePerformanceStatisticsHandler {
+    /** System view tables. */
+    private final Map<UUID, Map<String, List<Map<String, Object>>>> results = 
new HashMap<>();

Review Comment:
   Useless intermediate object. Let's fill ObjectNode instead



##########
modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/SystemViewHandler.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.ignite.internal.performancestatistics.handlers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import static 
org.apache.ignite.internal.performancestatistics.util.Utils.MAPPER;
+
+/**
+ * Builds JSON with system view tables.
+ *
+ * Example:
+ * <pre>
+ * {
+ *    $nodeId: {
+ *      $systemViewTable: [
+ *        { $column1: $value1, $column2: $value2 },
+ *        { $column1: $value3, $column2: $value4 }
+ *        ]
+ *    }
+ * }
+ * </pre>
+ */
+public class SystemViewHandler implements IgnitePerformanceStatisticsHandler {
+    /** System view tables. */
+    private final Map<UUID, Map<String, List<Map<String, Object>>>> results = 
new HashMap<>();
+
+    /** {@inheritDoc} */
+    @Override public void systemView(UUID nodeId, String viewName, 
List<String> schema, List<Object> data) {
+        Map<String, List<Map<String, Object>>> nodeData = 
results.computeIfAbsent(nodeId, uuid -> new HashMap<>());
+
+        List<Map<String, Object>> viewData = 
nodeData.computeIfAbsent(viewName, string -> new ArrayList<>());
+
+        Map <String, Object> row = new LinkedHashMap<>(schema.size());
+
+        for (int i = 0; i < data.size(); i++)
+            row.put(schema.get(i), data.get(i));
+
+        viewData.add(row);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<String, JsonNode> results() {
+        ObjectNode resNode = MAPPER.createObjectNode();
+
+        results.forEach((id, views) -> {
+            ObjectNode gridObjNode = MAPPER.createObjectNode();
+
+            views.forEach((view, rows) -> {
+                ArrayNode rowsArrNode = generateRowsNode(rows);
+                gridObjNode.set(view, rowsArrNode);
+            });
+
+            resNode.set(id.toString(), gridObjNode);
+        });
+
+        return Map.of("systemView", resNode);

Review Comment:
   Extensions sources use jdk8.



##########
modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsPrinterTest.java:
##########
@@ -70,6 +78,8 @@ public class PerformanceStatisticsPrinterTest {
     /** Test node ID. */
     private static final UUID NODE_ID = UUID.randomUUID();
 
+    private static final int TIMEOUT = 10_000;

Review Comment:
   Missed javadoc



##########
modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/PrintHandler.java:
##########
@@ -340,6 +344,19 @@ public PrintHandler(PrintStream ps, @Nullable BitSet ops, 
long from, long to, @N
         ps.println("}");
     }
 
+    /** {@inheritDoc} */
+    @Override public void systemView(UUID nodeId, String viewName, 
List<String> schema, List<Object> data) {
+        ObjectNode node = MAPPER.createObjectNode();

Review Comment:
   Looks suboptimal.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to