     (-> state
         ;; TODO, move this into a barrier completed action
         ;; so we can make the checkpoints separate to the barriers
-        (update :barrier merge {:scheduled? false})
+        (update :barrier    merge {:scheduled? false})
         (update :checkpoint merge {:initiated? false
                                    :write-version next-write-version}))))
 

       (catch KeeperException$BadVersionException bve
         (throw (Exception. "Coordinator failed to write coordinates.
                             This is likely due to the coordinator being quarantined, and another coordinator taking over.")))))

(defn complete-job! [state job-id]
  (>!! (:group-ch state) [:send-to-outbox {:fn :complete-job :args {:job-id job-id}}])
  state)

(defn next-replica
  [{:keys [log job-id peer-id messenger curr-replica tenancy-id] :as state}

      (if (empty? new-remaining)
        (update state :barrier merge {:remaining nil
                                      :offering? false})
        (do ;; sleep for two milliseconds before retrying the offer
            (LockSupport/parkNanos (* 2 1000000))
            (update state :barrier merge {:remaining new-remaining}))))
    state))

(defn write-coordinate [curr-version log tenancy-id job-id coordinate]
