   (throw (ex-info (format "Job scheduler %s not recognized" (:job-scheduler replica))
                   {:replica replica})))
 
-(defn job->n-peers [replica]
+(defn balance-jobs [replica]
   (let [j (count (:jobs replica))
         p (count (:peers replica))
         min-peers (int (/ p j))

        [{:fn :volunteer-for-task :args {:id (:id peer-args)}}]
        (= (:job-scheduler old) :onyx.job-scheduler/round-robin)
        (if-let [allocation (peer->allocated-job (:allocations new) (:id peer-args))]
          (let [peer-counts (job->n-peers new)]
            (prn (get peer-counts (:job allocation)))
            [{:fn :volunteer-for-task :args {:id (:id peer-args)}}])
          [{:fn :volunteer-for-task :args {:id (:id peer-args)}}])))


           (fn [i [job-id tasks]]
             {job-id (if (<= i n) max-peers min-peers)})
           (:allocations replica)))))

(defn job->peers [replica]
  (reduce-kv
   (fn [all job tasks]
     (assoc all job (apply concat (vals tasks))))
   {} (:allocations replica)))

(defn peer->allocated-job [allocations id]
  (get
