mcvsubbu commented on a change in pull request #5266:
URL: https://github.com/apache/incubator-pinot/pull/5266#discussion_r430838191



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
##########
@@ -43,17 +44,79 @@
  */
 @SuppressWarnings("unused")
 public class ServiceStatus {
+  public static final String STATUS_DESCRIPTION_NONE = "None";
+  public static final String STATUS_DESCRIPTION_INIT = "Init";
+  public static final String STATUS_DESCRIPTION_STARTED = "Started";
+  public static final String STATUS_DESCRIPTION_NO_HELIX_STATE = "Helix state 
does not exist";
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ServiceStatus.class);
+  private static final int MAX_RESOURCE_NAMES_TO_LOG = 5;
+  private static final Map<String, ServiceStatusCallback> 
serviceStatusCallbackMap = new ConcurrentHashMap<>();
+  private static final ServiceStatusCallback serviceStatusCallback =
+      new 
MapBasedMultipleCallbackServiceStatusCallback(serviceStatusCallbackMap);
 
-  public enum Status {
-    STARTING, GOOD, BAD
+  public static void setServiceStatusCallback(String name, 
ServiceStatusCallback serviceStatusCallback) {
+    ServiceStatus.serviceStatusCallbackMap.put(name, serviceStatusCallback);
   }
 
-  public static final String STATUS_DESCRIPTION_NONE = "None";
-  public static final String STATUS_DESCRIPTION_INIT = "Init";
-  public static final String STATUS_DESCRIPTION_NO_HELIX_STATE = "Helix state 
does not exist";
+  public static void removeServiceStatusCallback(String name) {
+    ServiceStatus.serviceStatusCallbackMap.remove(name);
+  }
 
-  private static final int MAX_RESOURCE_NAMES_TO_LOG = 5;
+  public static Status getServiceStatus() {
+    return getServiceStatus(serviceStatusCallback);
+  }
+
+  public static Status getServiceStatus(String name) {
+    if (serviceStatusCallbackMap.containsKey(name)) {
+      return getServiceStatus(serviceStatusCallbackMap.get(name));
+    } else {
+      return Status.NOT_STARTED;

Review comment:
       But then the shut down sequence is not instantaneous. You call shutdown 
and then wait for it to shutdown. During that time, the status should be 
SHUTTING_DOWN. And then you can change it to NOT_STARTED when the shutdown is 
complete.




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