exceptionfactory commented on code in PR #8152:
URL: https://github.com/apache/nifi/pull/8152#discussion_r1435328555


##########
nifi-nar-bundles/nifi-questdb-bundle/nifi-questdb-status-history/src/main/java/org/apache/nifi/controller/status/history/questdb/EmbeddedQuestDbStatusHistoryRepositoryDefinitions.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.nifi.controller.status.history.questdb;
+
+import org.apache.nifi.controller.status.ConnectionStatus;
+import org.apache.nifi.controller.status.NodeStatus;
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+import org.apache.nifi.controller.status.ProcessorStatus;
+import org.apache.nifi.controller.status.RemoteProcessGroupStatus;
+import org.apache.nifi.controller.status.history.ConnectionStatusDescriptor;
+import org.apache.nifi.controller.status.history.GarbageCollectionStatus;
+import org.apache.nifi.controller.status.history.MetricDescriptor;
+import org.apache.nifi.controller.status.history.NodeStatusDescriptor;
+import org.apache.nifi.controller.status.history.ProcessGroupStatusDescriptor;
+import org.apache.nifi.controller.status.history.ProcessorStatusDescriptor;
+import 
org.apache.nifi.controller.status.history.RemoteProcessGroupStatusDescriptor;
+import org.apache.nifi.controller.status.history.StandardMetricDescriptor;
+import org.apache.nifi.controller.status.history.StandardStatusSnapshot;
+import org.apache.nifi.questdb.InsertRowDataSource;
+import org.apache.nifi.questdb.QueryResultProcessor;
+import org.apache.nifi.questdb.mapping.RequestMapping;
+import org.apache.nifi.questdb.mapping.RequestMappingBuilder;
+
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+final class EmbeddedQuestDbStatusHistoryRepositoryDefinitions {
+    /**
+     * Date format expected by the storage.
+     */
+    static final String CAPTURE_DATE_FORMAT = "yyyy-MM-dd:HH:mm:ss Z";
+
+    /**
+     * Date formatter for the database fields.
+     */
+    static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormatter.ofPattern(CAPTURE_DATE_FORMAT).withZone(ZoneId.systemDefault());
+
+    // General component
+
+    static final String COMPONENT_STATUS_QUERY =
+        "SELECT * FROM %s " +
+        "WHERE componentId = '%s' " +
+        "AND capturedAt > to_timestamp('%s', '" + CAPTURE_DATE_FORMAT + "') " +
+        "AND capturedAt < to_timestamp('%s', '" + CAPTURE_DATE_FORMAT + "') " +
+        "ORDER BY capturedAt ASC";
+
+    // Connection
+
+    static final String TABLE_NAME_CONNECTION_STATUS = "connectionStatus";
+
+    static final String CREATE_CONNECTION_STATUS =
+        "CREATE TABLE " + TABLE_NAME_CONNECTION_STATUS + " (" +
+        "capturedAt TIMESTAMP," +
+        "componentId SYMBOL capacity 2000 nocache index capacity 1500," +
+        "inputBytes LONG," +
+        "inputCount LONG," +
+        "outputBytes LONG," +
+        "outputCount LONG," +
+        "queuedBytes LONG," +
+        "queuedCount LONG," +
+        "totalQueuedDuration LONG," +
+        "maxQueuedDuration LONG," +
+        "averageQueuedDuration LONG" +
+        ") TIMESTAMP(capturedAt) PARTITION BY DAY";
+
+    private static final Map<Integer, MetricDescriptor<ConnectionStatus>> 
CONNECTION_METRICS = new HashMap<>() {{
+        put(2, ConnectionStatusDescriptor.INPUT_BYTES.getDescriptor());
+        put(3, ConnectionStatusDescriptor.INPUT_COUNT.getDescriptor());
+        put(4, ConnectionStatusDescriptor.OUTPUT_BYTES.getDescriptor());
+        put(5, ConnectionStatusDescriptor.OUTPUT_COUNT.getDescriptor());
+        put(6, ConnectionStatusDescriptor.QUEUED_BYTES.getDescriptor());
+        put(7, ConnectionStatusDescriptor.QUEUED_COUNT.getDescriptor());
+        put(8, 
ConnectionStatusDescriptor.TOTAL_QUEUED_DURATION.getDescriptor());
+        put(9, ConnectionStatusDescriptor.MAX_QUEUED_DURATION.getDescriptor());
+        put(10, 
ConnectionStatusDescriptor.AVERAGE_QUEUED_DURATION.getDescriptor());
+    }};

Review Comment:
   Although not all of the bullet points may be applicable, this is a helpful 
list of the disadvantages of this approach, particularly the creation new new 
class instances. Less of an issue with this static list, but more along the 
lines of an approach to be avoided.
   
   
https://www.baeldung.com/java-double-brace-initialization#disadvantages-of-using-double-braces



-- 
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: issues-unsubscr...@nifi.apache.org

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

Reply via email to