rajagopr commented on code in PR #15044:
URL: https://github.com/apache/pinot/pull/15044#discussion_r1960790378


##########
pinot-minion/src/main/java/org/apache/pinot/minion/BaseMinionStarter.java:
##########
@@ -168,6 +172,26 @@ public void 
registerEventObserverFactory(MinionEventObserverFactory eventObserve
     
_eventObserverFactoryRegistry.registerEventObserverFactory(eventObserverFactory);
   }
 
+  public MinionTaskObserverStorageManager getMinionTaskProgressManager() {
+    String progressManagerClassName = 
_config.getProperty(MinionConf.MINION_TASK_PROGRESS_MANAGER_CLASS);
+    MinionTaskObserverStorageManager progressManager = null;
+    if (progressManagerClassName != null) {

Review Comment:
   Let's replace with `StringUtils.isNotEmpty(progressManagerClassName)` to 
cover for both null and empty scenarios.



##########
pinot-minion/src/main/java/org/apache/pinot/minion/event/MinionEventObserver.java:
##########
@@ -86,4 +95,6 @@ default MinionTaskState getTaskState() {
   default long getStartTs() {
     return -1;
   }
+
+  void cleanup();

Review Comment:
   Add docs. when should cleanup be performed?



##########
pinot-minion/src/main/java/org/apache/pinot/minion/event/DefaultMinionTaskObserverStorageManager.java:
##########
@@ -0,0 +1,89 @@
+/**
+ * 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.pinot.minion.event;
+
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.minion.MinionConf;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.tasks.MinionTaskBaseObserverStats;
+import org.apache.pinot.spi.tasks.MinionTaskObserverStorageManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DefaultMinionTaskObserverStorageManager implements 
MinionTaskObserverStorageManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultMinionTaskObserverStorageManager.class);
+
+  public static final String MAX_NUM_STATUS_TO_TRACK = 
"pinot.minion.task.maxNumStatusToTrack";
+  public static final int DEFAULT_MAX_NUM_STATUS_TO_TRACK = 128;
+
+  private final Map<String, MinionTaskBaseObserverStats> 
_minionTaskProgressStatsMap = new HashMap<>();
+  private int _maxNumStatusToTrack;
+
+  private static final DefaultMinionTaskObserverStorageManager 
DEFAULT_INSTANCE;
+  static {
+    DEFAULT_INSTANCE = new DefaultMinionTaskObserverStorageManager();
+    DEFAULT_INSTANCE.init(new MinionConf());
+  }
+
+  public static DefaultMinionTaskObserverStorageManager getDefaultInstance() {
+    return DEFAULT_INSTANCE;
+  }
+
+  @Override
+  public void init(PinotConfiguration configuration) {
+    try {
+      _maxNumStatusToTrack =
+          
Integer.parseInt(configuration.getProperty(DefaultMinionTaskObserverStorageManager.MAX_NUM_STATUS_TO_TRACK));
+    } catch (NumberFormatException e) {
+      LOGGER.warn("Unable to parse the value of '{}' using default value: {}",

Review Comment:
   nit: sentence is bit confusing to read. Let's re-write as `Unable to parse 
the configured value: {}, using the default value: {} instead.`



##########
pinot-minion/src/main/java/org/apache/pinot/minion/event/MinionEventObserverFactory.java:
##########
@@ -31,6 +32,11 @@ public interface MinionEventObserverFactory {
    */
   void init(MinionTaskZkMetadataManager zkMetadataManager);
 
+  /**
+   * Initializes the task executor factory.

Review Comment:
   Docs for this and the previous method are exactly the same. Let's reason 
about the new param `MinionTaskObserverStorageManager` as part of this methods 
docs.



##########
pinot-minion/src/main/java/org/apache/pinot/minion/event/DefaultMinionTaskObserverStorageManager.java:
##########
@@ -0,0 +1,89 @@
+/**
+ * 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.pinot.minion.event;
+
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.minion.MinionConf;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.tasks.MinionTaskBaseObserverStats;
+import org.apache.pinot.spi.tasks.MinionTaskObserverStorageManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DefaultMinionTaskObserverStorageManager implements 
MinionTaskObserverStorageManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultMinionTaskObserverStorageManager.class);
+
+  public static final String MAX_NUM_STATUS_TO_TRACK = 
"pinot.minion.task.maxNumStatusToTrack";
+  public static final int DEFAULT_MAX_NUM_STATUS_TO_TRACK = 128;
+
+  private final Map<String, MinionTaskBaseObserverStats> 
_minionTaskProgressStatsMap = new HashMap<>();
+  private int _maxNumStatusToTrack;
+
+  private static final DefaultMinionTaskObserverStorageManager 
DEFAULT_INSTANCE;
+  static {
+    DEFAULT_INSTANCE = new DefaultMinionTaskObserverStorageManager();
+    DEFAULT_INSTANCE.init(new MinionConf());
+  }
+
+  public static DefaultMinionTaskObserverStorageManager getDefaultInstance() {
+    return DEFAULT_INSTANCE;
+  }
+
+  @Override
+  public void init(PinotConfiguration configuration) {
+    try {
+      _maxNumStatusToTrack =
+          
Integer.parseInt(configuration.getProperty(DefaultMinionTaskObserverStorageManager.MAX_NUM_STATUS_TO_TRACK));
+    } catch (NumberFormatException e) {
+      LOGGER.warn("Unable to parse the value of '{}' using default value: {}",
+          DefaultMinionTaskObserverStorageManager.MAX_NUM_STATUS_TO_TRACK,
+          
DefaultMinionTaskObserverStorageManager.DEFAULT_MAX_NUM_STATUS_TO_TRACK);
+      _maxNumStatusToTrack = 
DefaultMinionTaskObserverStorageManager.DEFAULT_MAX_NUM_STATUS_TO_TRACK;
+    }
+  }
+
+  @Nullable
+  @Override
+  public MinionTaskBaseObserverStats getTaskProgress(String taskId) {
+    if (_minionTaskProgressStatsMap.containsKey(taskId)) {
+      return new 
MinionTaskBaseObserverStats(_minionTaskProgressStatsMap.get(taskId));
+    }
+    return null;
+  }
+
+  @Override
+  public synchronized void setTaskProgress(String taskId, 
MinionTaskBaseObserverStats progress) {
+    _minionTaskProgressStatsMap.put(taskId, progress);
+    Deque<MinionTaskBaseObserverStats.StatusEntry> progressLogs = 
progress.getProgressLogs();

Review Comment:
   Given this is a public method, a non-null check can be added to the 
`progress` object.



-- 
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: commits-unsubscr...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to