sajjad-moradi commented on code in PR #14536:
URL: https://github.com/apache/pinot/pull/14536#discussion_r1870149233


##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/ServerInfoFetcher.java:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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.controller.util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.spi.utils.InstanceTypeUtils;
+
+
+/**
+ * This is a helper class that fetch server information from Helix/ZK. It 
caches the server information to avoid
+ * repeated ZK access. This class is NOT thread-safe.
+ */
+public class ServerInfoFetcher {

Review Comment:
   The name is too generic. I suggest to rename it to something like 
`ServerQueryStateFetcher`.
   Also this is only used in SegmentStatusChecker class. Let's make it private 
to that class (move it to that class), and later if there's any use elsewhere, 
it can be made public.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java:
##########
@@ -80,6 +82,8 @@ public class SegmentStatusChecker extends 
ControllerPeriodicTask<SegmentStatusCh
 
   private long _lastDisabledTableLogTimestamp = 0;
 
+  private ServerInfoFetcher _serverInfoFetcher;

Review Comment:
   Let's not have this as a class member. The reason is the cache you have in 
the class is not cleared. If you create an `ServerInfoFetcher` object in each 
run of the segment status checker, there's no need to worry about the cache 
eviction.



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