      (apply hash-map (interleave  (set members) (partition-all d (set ids)))))))
 
 
+(defn get-partition-members [connector topic]
+  (empheral-ls connector (str topic "/partition-members/*")))
+
 (defn- is-master!? 
   "Get a lock on $topic/master if the lock is not attained it means this host is not the master"
   [connector host topic]

		        (do
               ;if master and all the nodes have written to the sync point, write the new assignments and set the partition flag to nil
               (if (is-master!? connector host topic)
                 (if (>= (count (empheral-ls connector (sync-point-path-keys connector topic))) (count (get-remote-members connector)))
                   (let [members (get-member-keys connector)]
                     ;delete all keys in sync path
                     (doseq [ks (empheral-ls connector (sync-point-path-keys connector topic))]
                       (empheral-del connector (:path ks)))
                     ;set the assignments and un set the partition flag
                     (empheral-set connector (assignments-path topic) (distribute-ids members ids))
                     (empheral-del connector (partition-flag-path topic)))
                   (info  "sync keys " (empheral-ls connector (sync-point-path-keys connector topic)) " members " (map :path (get-remote-members connector))))
                 )
               
               (if (is-partition-flag? connector topic)

  (str topic "/sync-point/*"))


(defn- get-member-keys [connector topic]
  (map #(-> (clojure.string/split % #"/") last)  (get-partition-members connector topic)))

(defn- perform-assignments! 
  "Read the members, sets the partition flag to true, sets the assignemnts from distribute-ids and finally sets the partition flag to nil"
  [connector host topic ids]
  ;(prn "perform-assignments is-flag " (empheral-get connector (partition-flag-path topic)) " - d1 "   (empheral-get connector (assignments-path topic))
   ; " d2 " (distribute-ids (get-member-keys connector) ids)  " ids " ids " members " (get-member-keys connector))
  (if (and ;only perform assignments if the partion flat is false and the calculated assignment differs from the saved one
        (not (empheral-get connector (partition-flag-path topic)))
        (not= (empheral-get connector (assignments-path topic)) (distribute-ids (get-member-keys connector topic) ids)))
      (empheral-set connector (partition-flag-path topic) true)))

(defn- wait-on-partition-flag! 
