             (install-tidb! node)
             
             (when (= node :n1)
-              ;(install-hbase! node)
+              (install-hbase! node)
               (start-hbase! node)
               (start-tso-server! node)
-              (Thread/sleep 5000))
+              (Thread/sleep 10000)
+              (setup-db! node))
             
             (jepsen/synchronize test)
             (start-tidb-server! node)
             
-            (Thread/sleep 1000)
             (jepsen/synchronize test)
             (info node "set up"))
     

          (c/exec :tar :xzf "tso-server.tar.gz")
          (c/exec :chmod :+x "tso-server")
          (c/exec :mv :-f "tso-server" "/root")
          (info node "installing themis")
          (c/exec :cp :-f "themis-coprocessor-1.0-SNAPSHOT-jar-with-dependencies.jar" "/root/hbase/lib")
          (c/exec :cp :-f "hbase-site.xml" "/root/hbase/conf")

  (c/su 
    (info node "stopping hbase")
    ; call stop-hbase.sh is very slow, so here we kill java forcely.
    (cu/grepkill "java")
    (Thread/sleep 2000)
    ; (meh (c/exec "/root/hbase/bin/stop-hbase.sh"))
    ;(meh (c/exec :rm :-rf "/var/lib/hbase/"))
    ;(meh (c/exec :rm :-rf "/root/hbase/logs/"))
    (meh (c/exec :rm :-rf "/tmp/hbase/"))
    )
  (info node "hbase stopped"))

(defn eval!
  "Evals a sql string from the command line."
  [s]
  (c/exec :echo s | "/root/interpreter" 
          :-lease 0 
          :-store "hbase" 
          (c/lit (str "-dbpath=\"" store-path "\""))
          :> "/var/log/interpreter.log"))

(defn setup-db!
  "Initialize TiDB database."
  [node]
  (info node "begin to setup tidb database.")
  (eval! (str "create table if not exists dirty
              (id     int not null primary key,
              x       bigint not null);")))


(defn db
  "Sets up and tears down TiDB"
