aho135 commented on code in PR #17707:
URL: https://github.com/apache/druid/pull/17707#discussion_r1978157688


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java:
##########
@@ -166,6 +172,36 @@ public boolean 
createOrUpdateAndStartSupervisor(SupervisorSpec spec)
     }
   }
 
+  /**
+   * Checks whether the submitted SupervisorSpec differs from the current spec 
in SupervisorManager's supervisor list.
+   * This is used in SupervisorResource specPost to determine whether the 
Supervisor needs to be restarted
+   * @param spec The spec submitted
+   * @return boolean - false if the spec is unchanged, else true
+   */
+  public boolean shouldUpdateSupervisor(SupervisorSpec spec)
+  {
+    Preconditions.checkState(started, "SupervisorManager not started");
+    Preconditions.checkNotNull(spec, "spec");
+    Preconditions.checkNotNull(spec.getId(), "spec.getId()");
+    Preconditions.checkNotNull(spec.getDataSources(), "spec.getDatasources()");
+    synchronized (lock) {
+      Preconditions.checkState(started, "SupervisorManager not started");
+      try {
+        byte[] specAsBytes = jsonMapper.writeValueAsBytes(spec);
+        Pair<Supervisor, SupervisorSpec> currentSupervisor = 
supervisors.get(spec.getId());
+        if (currentSupervisor != null &&
+            Arrays.equals(specAsBytes, 
jsonMapper.writeValueAsBytes(currentSupervisor.rhs))
+        ) {
+          return false;
+        }

Review Comment:
   Thanks for the review @kfaraz
    I'm not sure I follow on this suggestion. If currentSupervisor exists then 
this would always return false, and we never check if the spec was actually 
changed. Please let me know if I'm missing something here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to