Github user revans2 commented on a diff in the pull request: https://github.com/apache/storm/pull/2319#discussion_r138074478 --- Diff: storm-core/src/clj/org/apache/storm/daemon/supervisor.clj --- @@ -758,6 +752,35 @@ (catch Exception e (log-error e "Error running profiler actions, will retry again later"))))) +(defn assigned-assignments-to-local! + [^SupervisorAssignments supervisorAssignments supervisor] + (when (not-nil? supervisorAssignments) + (let [serialized-assignments (into {} (for [[tid amt] (.get_storm_assignment supervisorAssignments)] + {tid (Utils/serialize amt)}))] + (.sync-remote-assignments! (:storm-cluster-state supervisor) serialized-assignments)))) + +;; Supervisor should be told that who is leader. +;; Fetch leader info each time before request node assignment. +;; TODO: get leader address from zk directly. +(defn assignments-from-master + [conf supervisor] + (let [client (atom nil)] + (try + (let [master-client (NimbusClient/getConfiguredClientAs conf nil) + _ (reset! client master-client) ;; keep a refence so we can close it + supervisor-assignments (.getSupervisorAssignments (.getClient master-client) (:my-hostname supervisor))] + (assigned-assignments-to-local! supervisor-assignments supervisor)) + (catch Throwable e --- End diff -- Lets just catch Exception and not Throwable. There are way too many really bad things that are Errors that we don't want to ignore.
---