          (regions-by-tables (:regions @cached)
                             (keyword metric))))
   (PUT "/move_region" {{:keys [src dest region]} :params}
+       (when @read-only?
+         (throw (Exception. "Read-only mode. Not allowed.")))
        (hbase/admin-let
          [admin @zookeeper]
          (.move admin (.getBytes region) (.getBytes dest))


(defn exit [message]
  (println message)
  (println "usage: hbase-region-inspector QUORUM[/ZKPORT] PORT")
  (System/exit 1))

(defn -main [& args]
  (when (not= 2 (count args)) (exit "invalid number of arguments"))
  (try
    (let [[zk port] args
          port (Integer/parseInt port)]
      (bootstrap zk port true))
    (catch NumberFormatException e (exit "invalid port"))))



;;; ZooKeeper quorum we point to
(defonce zookeeper (atom "localhost"))

;;; Whether we should allow region relocation or not
(defonce read-only? (atom false))

;;; Cache the result of previous inspection
(defonce cached (atom {:updated-at nil :regions []}))
