      (finally
       (zk/close conn)))))
 
+(defmethod clear-tenancy OnyxClient
+  [client tenancy-id]
+  (clear-tenancy (:conn (:log client)) tenancy-id))
+
 (defmulti job-snapshot-coordinates
   "Reads the latest full snapshot coordinate stored for a given job-id and
    tenancy-id. This snapshot coordinate can be supplied to build-resume-point

   This information can then be used to playback a log and get the current job state, and to resolve to resume point coordinates via onyx.api/job-snapshot-coordinates.
   Connector can take either a ZooKeeper address as a string, or a ZooKeeper log component.
   History is the order of earliest to latest."
  (fn [connector job-name]
    (type connector)))

(defmethod job-ids-history org.apache.curator.framework.imps.CuratorFrameworkImpl
  [conn job-name]
  (loop [position 0 entries []]
    (let [entry (try (extensions/read-job-name-metadata conn job-name position)
                     (catch org.apache.zookeeper.KeeperException$NoNodeException nne))]
      (if entry
        (recur (inc position) (conj entries entry))
        entries))))

(defmethod job-ids-history String
  [zookeeper-address job-name]
  (s/validate s/Str zookeeper-address)
  (s/validate os/JobName job-name)
  (let [conn (zk/connect zookeeper-address)]
    (try
     (job-ids-history conn job-name)
     (finally
      (zk/close conn)))))

(defmulti clear-job-data
  "Takes a peer-config, zookeeper-address string, or a curator connection, and deletes

     (finally
      (zk/close conn)))))

(defmethod clear-job-data OnyxClient
  [client tenancy-id job-id]
  (clear-job-data (:conn (:log client)) tenancy-id job-id))

(defmulti clear-tenancy
  "Takes a zookeeper-address string or a curator connection, and deletes
   all data for a given tenancy from ZooKeeper, including job data and cluster logs. 
