 
 ;;; Whether we should allow region relocation or not
 (defonce read-only? (atom false))
+
+;;; Whether we should include meta region or not
+(defonce with-meta? (atom false))
 
 ;;; Cache the result of previous inspection
 (defonce cached (atom {:updated-at nil :regions []}))


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

(defn -main [& args]
  (let [[opts args] ((juxt filter remove) #(.startsWith % "-") args)
        opts (set (map #(keyword (str/replace % #"^-*" "")) opts))]
    (reset! read-only? (contains? opts :read-only))
    (when (not= 2 (count args)) (exit "invalid number of arguments"))
    (try
      (let [[zk port] args


(defn regions-by-tables
  "Generates output for /table_regions.json. Regions grouped by their tables."
  [regions metric sort {:keys [with-meta?] :or {with-meta? false}}]
  (let [;; Exclude hbase:meta table
        all-regions (if with-meta? regions (remove :meta? regions))
        ;; Sort the regions
        sorted-regions (if (= sort :metric)
                         (reverse (sort-by metric all-regions))
