             [hadoop-util.transfer :as transfer]
             [jackknife.core :as u]
             [jackknife.logging :as log]
+            [clojure.java.io :as io]
             [elephantdb.common.shard :as shard]
             [elephantdb.common.config :as conf]
             [elephantdb.common.status :as status])

        remote-store (.remoteStore domain)
        remote-fs    (.getFileSystem remote-store)
        remote-path  (.shardPath remote-store idx version)
        local-path   (.shardPath local-store idx version)
        timeout-ms (* 6 60 1000)]
    (if (.exists remote-fs (h/path remote-path))
      (do (log/info (format "Copying %s to %s." remote-path local-path))
          (try
            (try-times [3]
                       (with-timeout [timeout-ms]
                         (transfer/rcopy remote-fs remote-path local-path
                                         :throttle throttle)))
            (catch Exception e
              (log/error e)
              (throw e)))
          (log/info (format "Copied %s to %s." remote-path local-path)))
      (do (log/info "Shard doesn't exist. Creating shard # " idx)
          (.createShard local-store idx version)))))


(defalias throttle transfer/throttle
  "Returns a throttling agent for use in throttling domain updates.")

(defn transfer-shard!
  "Transfers the supplied shard (specified by `idx`) from the supplied
  remote version's remote store to the appropriate path on the local
