 
               (updateAll
                []
-               ;; TODO
+                (update-all-domains domains-info global-config local-config)
                )
 
               (update
                [#^String domain]
-               ;; TODO
+                ;; TODO
+                (update-domain domain)
                ))]
       (reset! client (client. ret (:hdfs-conf local-config) global-config))
       ret ))

(defn load-and-sync-status [domains-info loader-fn]
  (let [loaders (dofor [domain (keys domains-info)]
                       (future
                        (try
                          (domain/set-domain-data! (domains-info domain)
                                                   (loader-fn domain))
                          (domain/set-domain-status!
                           (domains-info domain)
                           (thrift/ready-status false))
                          (catch Throwable t
                            (log-error t "Error when loading domain " domain)
                            (domain/set-domain-status!
                             (domains-info domain)
                             (thrift/failed-status t))
                            ))))]
    (with-ret (future-values loaders)
      (log-message "Successfully loaded all domains"))
    ))

      (< (.mostRecentVersion local-vs)
         (.mostRecentVersion remote-vs))))

(defn use-cache-or-update
  ([domain domains-info global-config local-config open-if-no-update]
     (let [fs (filesystem (:hdfs-conf local-config))
           lfs (local-filesystem)
           local-dir (:local-dir local-config)
           local-domain-root (str (path local-dir domain))
           remote-path (-> global-config :domains (get domain))
           remote-vs (DomainStore. fs remote-path)
           local-vs (DomainStore. lfs local-domain-root (.getSpec remote-vs))]
       (if (domain-needs-update? local-vs remote-vs)
         (load-domain fs
                      local-config
                      local-domain-root
                      remote-path
                      (domain/host-shards (domains-info domain)))
         ;; use cached domain from local-dir (no update needed)
         (do
           (swap! finished-loaders + 1)
           (if open-if-no-update
             (open-domain local-config
                          (str (path local-dir domain))
                          (domain/host-shards (domains-info domain))))))))
  ([domain domains-info global-config local-config]
     (use-cache-or-update domain domains-info global-config local-config true)))

(defn delete-deleted-domains
  "Deletes all domains from local filesystem that have been deleted from the global config."
