markap14 commented on a change in pull request #3681: NIFI-6510 - Analytics 
framework
URL: https://github.com/apache/nifi/pull/3681#discussion_r320925930
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/analytics/StatusAnalyticsModelMapFactory.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.analytics;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import org.apache.nifi.controller.status.history.StatusHistoryUtil;
+import org.apache.nifi.nar.ExtensionManager;
+import org.apache.nifi.nar.NarThreadContextClassLoader;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.util.Tuple;
+import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
+import org.apache.nifi.web.api.dto.status.StatusSnapshotDTO;
+
+/**
+ * <p>
+ * This factory supports the creation of models and their associated 
extraction functions
+ * </p>
+ */
+public class StatusAnalyticsModelMapFactory {
+
+    private final static String QUEUED_COUNT_METRIC = "queuedCount";
+    private final static String QUEUED_BYTES_METRIC = "queuedBytes";
+    private final static String INPUT_COUNT_METRIC = "inputCount";
+    private final static String INPUT_BYTES_METRIC = "inputBytes";
+    private final static String OUTPUT_COUNT_METRIC = "outputCount";
+    private final static String OUTPUT_BYTES_METRIC = "outputBytes";
+
+    /**
+     * Return mapping of models and extraction functions for connection status 
analytics prediction instances
+     * @param extensionManager Extension Manager object for instantiating 
classes
+     * @param niFiProperties NiFi Properties object
+     * @return
+     */
+    public static Map<String, Tuple<StatusAnalyticsModel, 
StatusMetricExtractFunction>> getConnectionStatusModelMap(ExtensionManager 
extensionManager, NiFiProperties niFiProperties){
+            Map<String, Tuple<StatusAnalyticsModel, 
StatusMetricExtractFunction>> modelMap = new HashMap<>();
+            StatusMetricExtractFunction extract = 
getConnectionStatusExtractFunction();
+            Tuple<StatusAnalyticsModel, StatusMetricExtractFunction> 
countModelFunction = new Tuple<>(createModelInstance(extensionManager, 
niFiProperties), extract);
 
 Review comment:
   This object model of `Map<String, Tuple<StatusAnalyticsModel, 
StatusMetricExtractFunction>>` is passed around quite a lot. It probably makes 
more sense to get rid of the `Tuple` and instead create a simple object that 
has a getter for the model and a getter for the extract function. It would 
certainly improve the code's readability. It would also mean that there's a 
more cohesive model that can much more naturally evolve over time and can have 
any methods implemented that are necessary that may deal with the two objects 
together, rather than having to build Util methods elsewhere.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to