Jackie-Jiang commented on code in PR #9058:
URL: https://github.com/apache/pinot/pull/9058#discussion_r927117765


##########
pinot-common/src/main/java/org/apache/pinot/common/minion/TaskManagerStatusCache.java:
##########
@@ -0,0 +1,32 @@
+/**
+ * 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.common.minion;
+
+import java.util.function.Consumer;
+
+
+public abstract class TaskManagerStatusCache<T extends BaseTaskGeneratorInfo> {

Review Comment:
   Suggest changing it to an interface



##########
pinot-common/src/main/java/org/apache/pinot/common/minion/TaskGeneratorMostRecentRunInfo.java:
##########
@@ -0,0 +1,120 @@
+/**
+ * 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.common.minion;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.google.common.annotations.VisibleForTesting;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+
+/**
+ * a task generator running history which keeps the most recent several 
success run timestamp and the most recent
+ * several error run messages.
+ */
+@JsonPropertyOrder({"tableNameWithType", "taskType", "mostRecentSuccessRunTS", 
"mostRecentErrorRunMessages"})
+public class TaskGeneratorMostRecentRunInfo extends BaseTaskGeneratorInfo {
+  @VisibleForTesting
+  static final int MAX_NUM_OF_HISTORY_TO_KEEP = 5;
+  private final String _taskType;
+  private final String _tableNameWithType;
+  // the timestamp to error message map of the most recent several error runs
+  private final TreeMap<Long, String> _mostRecentErrorRunMessages;
+  // the timestamp of the most recent several success runs
+  private final List<Long> _mostRecentSuccessRunTS;
+
+  private TaskGeneratorMostRecentRunInfo(String tableNameWithType, String 
taskType) {
+    _tableNameWithType = tableNameWithType;
+    _taskType = taskType;
+    _mostRecentErrorRunMessages = new TreeMap<>();
+    _mostRecentSuccessRunTS = new ArrayList<>();
+  }
+
+  /**
+   * Returns the table name with type
+   */
+  public String getTableNameWithType() {
+    return _tableNameWithType;
+  }
+
+  @Override
+  public String getTaskType() {
+    return _taskType;
+  }
+
+  /**
+   * Gets the timestamp to error message map of the most recent several error 
runs
+   */
+  public TreeMap<String, String> getMostRecentErrorRunMessages() {
+    TreeMap<String, String> result = new TreeMap<>();
+    _mostRecentErrorRunMessages.forEach((timestamp, error) -> result.put(
+        OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), 
ZoneId.of("UTC")).toString(), error));

Review Comment:
   (minor)
   ```suggestion
           OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), 
ZoneOffset.UTC).toString(), error));
   ```
   
   We can also consider putting `ZoneId.systemDefault()` which might be more 
readable, but it might also be confusing when the client is in a different 
timezone from the server. IMO both ways have pros and cons, so your call



-- 
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