Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,15 @@
(defn get-pacemaker-write-client [conf servers client-pool]
;; Client should be created in case of an exception or first write call
;; Shutdown happens in the retry loop
(try
(.waitUntilReady
(let [client (get @client-pool (first @servers))]
(if (nil? client)
(do
(swap! client-pool merge {(first @servers) (PacemakerClient. conf (first @servers))})
(get @client-pool (first @servers)))
client)))
(catch Exception e
(throw e))))
(let [client (get @client-pool (first @servers))]
(try
(.waitUntilReady
(let [] (if (nil? client)
(do (swap! client-pool merge {(first @servers) (PacemakerClient. conf (first @servers))})
(get @client-pool (first @servers)))
client)))
(catch Exception e (throw e)))
(get @client-pool (first @servers))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitUntilReady is not actually needed because send will call it internally. We can just skip calling it here all together. This then lets us have something like ...

(defn get-pacemaker-write-client [conf servers client-pool]
   ;; Client should be created in case of an exception or first write call
   ;; Shutdown happens in the retry loop
   (let [server (first @servers)]
          (or (get @client-pool server)
              (get (swap! client-pool merge {server (PacemakerClient. conf server)}) server))))

and we can then remove the update to PacemakerClient.java


;; So we can mock the client for testing
(defn makeClientPool [conf client-pool servers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public HBMessage send(HBMessage m) throws PacemakerConnectionException {
}
}

private void waitUntilReady() throws PacemakerConnectionException {
public void waitUntilReady() throws PacemakerConnectionException {
// Wait for 'ready' (channel connected and maybe authentication)
if(!ready.get() || channelRef.get() == null) {
synchronized(this) {
Expand Down