Skip to content

hibari-labs/embedded-hibari-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embedded Hibari Sample Application

A sample Erlang/OTP application with embedded Hibari DB server

Getting Started

Requirements

  • Erlang/OTP 17.x

  • Unix-like operating system that can run Erlang/OTP 17.x

    • GNU/Linux — Ubuntu, Debian, Fedora, CentOS, CoreOS, etc.

    • Mac OS X

    • BSD — FreeBSD

    • illumos — SmartOS, OmniOS

Building the Application

$ make deps
$ make compile

Start the Application

make run starts the application with embedded single-node Hibari DB server.

$ make run
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
(emb-hibari@127.0.0.1)1>
hibari/log/console.log
$ tail -f hibari/log/console.log
2015-03-13 21:25:47.846 [info] <0.7.0> Application lager started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:47.849 [info] <0.7.0> Application cluster_info started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:47.855 [info] <0.7.0> Application gmt_util started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:47.864 [info] <0.92.0>@partition_detector_server:init:207 Partition detector: active status on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:47.874 [info] <0.7.0> Application partition_detector started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:47.889 [info] <0.103.0>@congestion_watcher_server:do_mark:239 mark: 20150313212547 [{0,0},{0,0},{0,0}]
2015-03-13 21:25:47.889 [info] <0.7.0> Application congestion_watcher started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:48.064 [info] <0.115.0>@gmt_hlog_common:schedule_next_daily_scavenger:1496 Scheduling next scavenger 20052 seconds from now.
2015-03-13 21:25:48.071 [info] <0.7.0> Application gdss_brick started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:48.079 [info] <0.7.0> Application gdss_client started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:48.080 [info] <0.132.0>@brick_admin:start:305 normal start, Args = []
2015-03-13 21:25:48.121 [info] <0.7.0> Application gdss_admin started on node 'emb-hibari@127.0.0.1'
2015-03-13 21:25:48.124 [info] <0.7.0> Application embedded_hibari started on node 'emb-hibari@127.0.0.1'

There is a very simple demo function called eh_client_demo:demo/1. Try it from Erlang shell.

(emb-hibari@127.0.0.1)1> eh_client_demo:demo().
Bootstrapping Hibari... ok
ok
Wait for 30 seconds.
Creating table 'demo'... ok
ok
Wait for 30 seconds.

brick_simple:add(demo, <<"/100/1/A">>, <<"AAA">>)
   -> {ok,1426252510468011}

brick_simple:get_many(demo, <<"/100/1">>, 100)
    -> {ok,{[{<<"/100/1/A">>,1426252510468011,<<"AAA">>}],false}}

brick_simple:do(demo, [txn,
                       {set,<<"/100/1/A">>,0,<<"AAA">>,0,[]},
                       {set,<<"/100/1/B">>,0,<<"AAA">>,0,[]}])
    -> [{ok,1426252510469528},{ok,1426252510469532}]

brick_simple:get_many(demo, <<"/100/1">>, 100)
    -> {ok,{[{<<"/100/1/A">>,1426252510469528,<<"AAA">>},
             {<<"/100/1/B">>,1426252510469532,<<"AAA">>}],
            false}}


ok
(emb-hibari@127.0.0.1)2>

Admin Server’s Web-based Management Console

To access Hibari admin server’s web-based management console, open http://localhost:23080/ with a web browser.

Stop the Application

To stop the application with the embedded Hibari DB server, use Erlang shell command q().

You might want to stop epmd (Erlang Port Mapper Daemon) process too. (e.g. sudo killall -QUIT epmd)

Under the Hood

Check out the following files:

All Hibari data files will be created inside ./hibari/ directory (except ./Schema.local). You can change the data file location by sys.config.

TODOs

  • Replace error(1) in eh_admin_client with better errors

  • (DONE) Create tables from the application

  • (IN-PROGRESS) Demonstrate CRUD operations

  • Run checkpoint operation

  • Add multi-node configuration

  • Demonstrate node down and recovery

  • …​

License

embedded-hibari-sample is open-sourced under the Apache 2.0 license. See the LICENSE file for details.

About

A sample Erlang/OTP application with embedded Hibari DB server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published