Skip to content

Commit

Permalink
Merge branch 'release/0.90.5-3'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsantiago committed Apr 21, 2012
2 parents dc62420 + ef4dc03 commit 003240d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 38 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Expand Up @@ -160,6 +160,8 @@ Basic unit tests passing. No known bugs. Bug reports and input welcome.

## Lately...

- Update to version 0.90.5-3, which makes the HBaseAdmin object rebindable. Work by [Ryan Senior](https://github.com/senior).

- Update to version 0.90.5-2, with the addition of set-config and default-config, to programmatically chanage HBase's configuration. Work by [Robert Levy](https://github.com/rplevy-draker).

- Update to version 0.90.5-1, with a race condition fix from [Homer
Expand Down
15 changes: 3 additions & 12 deletions project.clj
@@ -1,4 +1,4 @@
(defproject clojure-hbase "0.90.5-2"
(defproject clojure-hbase "0.90.5-3"
:description "A convenient Clojure interface to HBase."
:dependencies [[org.clojure/clojure "1.2.0"]
[org.apache.hadoop/hadoop-core "0.20.205.0"]
Expand All @@ -9,14 +9,5 @@
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[org.clojure/tools.logging "0.2.3"]]
:multi-deps {"1.2" [[org.clojure/clojure "1.2.0"]]
"1.3" [[org.clojure/clojure "1.3.0"]]
:all [[org.apache.hadoop/hadoop-core "0.20.205.0"]
[org.apache.hbase/hbase "0.90.5"]
[org.apache.zookeeper/zookeeper "3.3.2"]
[log4j/log4j "1.2.16" :exclusions [javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[org.clojure/tools.logging "0.2.3"]]}
:dev-dependencies [])
:profiles {:clojure1.2 [[org.clojure/clojure "1.2.0"]]
:clojure1.3 [[org.clojure/clojure "1.3.0"]]})
57 changes: 31 additions & 26 deletions src/clojure_hbase/admin.clj
Expand Up @@ -8,8 +8,13 @@
[org.apache.hadoop.hbase.util Bytes]
[org.apache.hadoop.hbase.io.hfile Compression]))

(def ^{:tag HBaseAdmin :dynamic true :private true} *admin*
(HBaseAdmin. (HBaseConfiguration/create)))
(def ^{:tag HBaseAdmin :dynamic true} *admin*
(atom nil))

(defn hbase-admin []
(when-not @*admin*
(swap! *admin* #(or % (HBaseAdmin. (HBaseConfiguration/create)))))
@*admin*)

;;
;; HColumnDescriptor
Expand Down Expand Up @@ -72,101 +77,101 @@

(defn add-column-family
[table-name ^HColumnDescriptor column-descriptor]
(.addColumn *admin* (to-bytes table-name) column-descriptor))
(.addColumn (hbase-admin) (to-bytes table-name) column-descriptor))

(defn hbase-available?
[]
(HBaseAdmin/checkHBaseAvailable (HBaseConfiguration.)))

(defn compact
[table-or-region-name]
(.compact *admin* (to-bytes table-or-region-name)))
(.compact (hbase-admin) (to-bytes table-or-region-name)))

(defn create-table
[table-descriptor]
(.createTable *admin* table-descriptor))
(.createTable (hbase-admin) table-descriptor))

(defn create-table-async
[^HTableDescriptor table-descriptor split-keys]
(.createTableAsync *admin* table-descriptor split-keys))
(.createTableAsync (hbase-admin) table-descriptor split-keys))

(defn delete-column-family
[table-name column-name]
(.deleteColumn *admin* (to-bytes table-name) (to-bytes column-name)))
(.deleteColumn (hbase-admin) (to-bytes table-name) (to-bytes column-name)))

(defn delete-table
[table-name]
(.deleteTable *admin* (to-bytes table-name)))
(.deleteTable (hbase-admin) (to-bytes table-name)))

(defn disable-table
[table-name]
(.disableTable *admin* (to-bytes table-name)))
(.disableTable (hbase-admin) (to-bytes table-name)))

(defn enable-table
[table-name]
(.enableTable *admin* (to-bytes table-name)))
(.enableTable (hbase-admin) (to-bytes table-name)))

(defn flush
[table-or-region-name]
(.flush *admin* (to-bytes table-or-region-name)))
(.flush (hbase-admin) (to-bytes table-or-region-name)))

(defn cluster-status
[]
(.getClusterStatus *admin*))
(.getClusterStatus (hbase-admin)))

(defn get-connection
[]
(.getConnection *admin*))
(.getConnection (hbase-admin)))

(defn get-master
[]
(.getMaster *admin*))
(.getMaster (hbase-admin)))

(defn get-table-descriptor
[table-name]
(.getTableDescriptor *admin* (to-bytes table-name)))
(.getTableDescriptor (hbase-admin) (to-bytes table-name)))

(defn master-running?
[]
(.isMasterRunning *admin*))
(.isMasterRunning (hbase-admin)))

(defn table-available?
[table-name]
(.isTableAvailable *admin* (to-bytes table-name)))
(.isTableAvailable (hbase-admin) (to-bytes table-name)))

(defn table-disabled?
[table-name]
(.isTableDisabled *admin* (to-bytes table-name)))
(.isTableDisabled (hbase-admin) (to-bytes table-name)))

(defn table-enabled?
[table-name]
(.isTableEnabled *admin* (to-bytes table-name)))
(.isTableEnabled (hbase-admin) (to-bytes table-name)))

(defn list-tables
[]
(seq (.listTables *admin*)))
(seq (.listTables (hbase-admin))))

(defn major-compact
[table-or-region-name]
(.majorCompact *admin* (to-bytes table-or-region-name)))
(.majorCompact (hbase-admin) (to-bytes table-or-region-name)))

(defn modify-column-family
[table-name column-name ^HColumnDescriptor column-descriptor]
(.modifyColumn *admin* (to-bytes table-name) (to-bytes column-name)
(.modifyColumn (hbase-admin) (to-bytes table-name) (to-bytes column-name)
column-descriptor))

(defn modify-table
[table-name table-descriptor]
(.modifyTable *admin* (to-bytes table-name) table-descriptor))
(.modifyTable (hbase-admin) (to-bytes table-name) table-descriptor))

(defn shutdown
[]
(.shutdown *admin*))
(.shutdown (hbase-admin)))

(defn split
[table-or-region-name]
(.split *admin* (to-bytes table-or-region-name)))
(.split (hbase-admin) (to-bytes table-or-region-name)))

(defn table-exists?
[table-name]
(.tableExists *admin* (to-bytes table-name)))
(.tableExists (hbase-admin) (to-bytes table-name)))

0 comments on commit 003240d

Please sign in to comment.