novabyte / diver

A HBase driver for Erlang/Elixir using Jinterface and the Asynchbase Java client to query the database.
Apache License 2.0
49 stars 9 forks source link

Initial client impl. #1

Closed novabyte closed 9 years ago

novabyte commented 9 years ago

Initial work on the client.

A GenServer starts and is linked to a Java server, if the JVM process dies it is automatically restarted. The Java server manages a HBase client that requests are dispatched to which makes queries to HBase.

In this initial release only the HBaseClient#stats() method has been implemented (demonstrated below). There's also no client API yet, GenServer calls must be made directly.

Part of the future work includes a proper module for the client interface.

$ iex --name "diver@127.0.0.1" --cookie "mycookie" -S mix
iex(diver@127.0.0.1)1> proc = {:diver_java_server, :"__diver__diver@127.0.0.1"}
{:diver_java_server, :"__diver__diver@127.0.0.1"}
iex(diver@127.0.0.1)2> GenServer.call(proc, {:stats})
{:client_stats,
 [connections_created: 0, root_lookups: 0, scanners_opened: 0, gets: 0,
  num_rpc_delayed_due_to_nsre: 0, no_such_region_exceptions: 0, row_locks: 0,
  contended_meta_lookups: 0, scans: 0, puts: 0, num_batched_rpc_sent: 0,
  flushes: 0, atomic_increments: 0, uncontended_meta_lookups: 0, deletes: 0]}
novabyte commented 9 years ago

To build the codebase you can do the following (at the moment):

$ gradle build && cp _java_build/libs/diver-0.1.0-SNAPSHOT.jar priv/
$ iex --name "diver@127.0.0.1" --cookie "mycookie" -S mix
novabyte commented 9 years ago

Since these changes you can build the codebase with:

$ gradle build && cp _java_build/libs/diver-0.1.0-dev.jar priv
$ iex --name "diver@127.0.0.1" --cookie "mycookie" -S mix

With the service running you can execute a client request with:

iex(diver@127.0.0.1)1> proc = {:diver_java_server, :"__diver__diver@127.0.0.1"}
{:diver_java_server, :"__diver__diver@127.0.0.1"}
iex(diver@127.0.0.1)2> GenServer.call(proc, {:client_stats})
{:client_stats,
 [connections_created: 0, root_lookups: 0, scanners_opened: 0, gets: 0,
  num_rpc_delayed_due_to_nsre: 0, no_such_region_exceptions: 0, row_locks: 0,
  contended_meta_lookups: 0, scans: 0, puts: 0, num_batched_rpc_sent: 0,
  flushes: 0, atomic_increments: 0, uncontended_meta_lookups: 0, deletes: 0]}