This is a Crux key value store implementation with HBase. HBase KV Store is horizontally scalable. It is intended Crux deployment on environment like Kubernetes where Crux nodes can be provisioned dynamically on any nodes in the cluster without requiring local index store.
<dependency>
<groupId>io.kosong.crux</groupId>
<artifactId>crux-hbase</artifactId>
<version>0.3.0-SNAPSHOT</version>
</dependency>
[io.kosong.crux.hbase/crux-hbase "0.3.0-SNAPSHOT"]
Refer to Crux reference for details on how to configure Crux index store, document store and transaction log.
The first step is to specify the HBase client configuration with the
io.kosong.crux.hbase/->hbase-config
module.
This follows with the use of
io.kosong.crux.hbase/->hbase-connection
module to create the HBase connection.
And then we can use the io.kosong.crux.hbase/->kv-store
module to configure
the desired Crux components (index store, document store or transaction log)
to use HBase KV Store.
Below is an example of configuring Crux to use HBase KV Stores for all three major components (index store, document store and transaction log).
The configuration allows multiple crux nodes to connect to the same distributed HBase KV index store with single curator coordinated cluster-wide tx-ingester executor to ingest the transactions into the shared distributed index store.
{
;; create a HBaseConfiguration
:hbase-config
{:crux/module 'io.kosong.crux.hbase/->hbase-config
:properties {"hbase.zookeeper.quorum" "127.0.0.1:2181"}}
;; create a shared HBase connection
:hbase-connection
{:crux/module 'io.kosong.crux.hbase/->hbase-connection
:hbase-config :hbase-config}
;; create a curator client to coordinate singleton tx-ingester
:curator
{:crux/module 'io.kosong.crux.hbase/->curator
:zookeeper-quorum "127.0.0.1:2181"}
;; cluster-wide singleton tx-ingest-executor with curator
;; to ensure that there is only one active tx-ingester
;; updating the remote hbase index-store at any one time
:tx-ingest-executor
{:crux/module 'io.kosong.crux.hbase/->tx-ingest-executor
:curator :curator}
:crux/index-store
{:kv-store {:crux/module 'io.kosong.crux.hbase/->kv-store
:hbase-connection :hbase-connection
:table "index-store"}}
:crux/document-store
{:kv-store {:crux/module 'io.kosong.crux.hbase/->kv-store
:hbase-connection :hbase-connection
:table "document-store"}}
;; HBase KV tx-log in ingest only mode as tx-ingester is managed
;; by tx-ingest-executor
:crux/tx-log
{:crux/module 'crux.kv.tx-log/->ingest-only-tx-log
:kv-store {:crux/module 'io.kosong.crux.hbase/->kv-store
:hbase-connection :hbase-connection
:table "tx-log"}}
}
io.kosong.crux.hbase/->hbase-config
properties
- string map to set up HBaseConfiguration
org.apache.hbase.HBaseConfiguration
io.kosong.crux.hbase/->hbase-connection
hbase-config
- An instance of HBaseConfiguration
org.apache.hbase.client.Connection
io.kosong.crux.hbase/->kv-store
hbase-connection
- An instance of org.apache.hbase.client.Connection
table
- HBase table name of the KV Store.namespace
- HBase namespace, default to crux
.family
- HBase column family name, default to cf
.qualifier
- HBase qualifier, default to val
.create-table?
- Create the HBase table if it doesn't exist, default to true
.crux.kv.KvStore
with HBase table data store.io.kosong.crux.hbase/->curator
zookeeper-quorum
- Zookeeper connection stringsession-timeout
- Zookeeper session timeout in milliseconds, default to 60000.connection-timeout
- Zookeeper connection timeout in milliseconds, default to 60000.retry-base-sleep
- Exponential backoff retry base sleep in milliseconds, default to 2000.retry-max-count
- Exponential backoff retry max count, default to 10.CuratorFramework
lio.kosong.crux.hbase/->tx-ingest-executor
curator
- An instance of CuratorFramework
.tx-ingester
- Default to :crux/tx-ingester
.tx-log
- Default to :crux/tx-log
.index-store
- Default to :crux/index-store
.mutex-path
- Zookeeper leader election mutex path, defaults to /crux/tx-ingest-executor
io.kosong.hbase.TxIngestExector
.To build
lein modules install
To test
lein modules test
To run a Clojure REPL for development
lein modules install
lein repl
When in Clojure REPL user
namespace
; Switch to dev namespace
(dev)
; If required, start embedded Zookeeper, HBase cluster
; for local development
(start-embedded-cluster)
; Start Crux
(go)
(crux/status (crux-node))
; Stop Crux
(halt)
; Stop embeded Zookeeper, HBase cluster
(stop-embedded-cluster)
Can you improve this documentation? These fine people already did:
Key Tiong Tan & keytiongEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close