SlideShare a Scribd company logo
HBase Client API
 (for webapps?)
         Nick Dimiduk
   Seattle Scalability Meetup
          2013-03-27




                                1
2
3
What are my choices?
   switch (technology) {

       case ‘    ’:
         ...

       case ‘    ’:
         ...

       case ‘    ’:
         ...
   }

                           4
Apache HBase




               5
Java client Interfaces
•   Configuration holds details where to find the cluster and tunable
    settings. Roughly equivalent to JDBC connection string.

•   HConnection represents connections to to the cluster.

•   HBaseAdmin handles DDL operations (create, list, drop, alter, &c.)

•   HTablePool connection pool for table handles.

•   HTable (HTableInterface) is a handle on a single HBase table.
    Send "commands" to the table (Put, Get, Scan, Delete, Increment)

                                                                         6
Java client Example
public static final byte[] TABLE_NAME = Bytes.toBytes("twits");
public static final byte[] TWITS_FAM = Bytes.toBytes("twits");

public static final byte[] USER_COL                                 = Bytes.toBytes("user");
public static final byte[] TWIT_COL                                 = Bytes.toBytes("twit");

private HTablePool pool = new HTablePool();




 https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L23-L30

                                                                                                                    7
Java client Example
private static class Twit {

   private Twit(Result r) {
     this(
           r.getColumnLatest(TWITS_FAM, USER_COL).getValue(),
           Arrays.copyOfRange(r.getRow(), Md5Utils.MD5_LENGTH,
             Md5Utils.MD5_LENGTH + longLength),
           r.getColumnLatest(TWITS_FAM, TWIT_COL).getValue());
   }

   private Twit(byte[] user, byte[] dt, byte[] text) {
     this(
           Bytes.toString(user),
           new DateTime(-1 * Bytes.toLong(dt)),
           Bytes.toString(text));
   }
https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L129-L143

                                                                                                                     8
Java client Example

       private static Get mkGet(String user, DateTime dt) {
         Get g = new Get(mkRowKey(user, dt));
         g.addColumn(TWITS_FAM, USER_COL);
         g.addColumn(TWITS_FAM, TWIT_COL);
         return g;
       }




https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L60-L65

                                                                                                                   9
Ruby, Python client Interface




                                10
Ruby, Python client Interface
        Jyth on
JRu by,

             : '(




                                11
Thrift client Interface


1. Generate bindings

2. Run a “Gateway” between clients and cluster

3. ... profit? code!
        w rite




                                                 12
HBase Cluster

 HBase Clients




Sidebar: Architecture Recap
                                 13
Thrift
                    Gateway     HBase Cluster

Thrift Clients




                 Thrift Architecture
                                                14
Thrift client Interface


•   Thrift gateway exposes a client to RegionServers

•   stateless :D

•   ... except for scanners :'(




                                                       15
Thrift client Example

transport = TSocket.TSocket(host, port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
transport.open()




      https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L17-L21

                                                                                     16
Thrift client Example
columns = ['info:user','info:name','info:email']
scanner = client.scannerOpen('users', '', columns)
row = client.scannerGet(scanner)
while row:
    yield user_from_row(row[0])
    row = scannerGet(scanner)
client.scannerClose(scanner)




     https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L33-L39

                                                                                    17
Thrift client Example

def user_from_row(row):
    user = {}
    for col,cell in row.columns.items():
        user[col[5:]] = cell.value
    return "<User: {user}, {name}, {email}>".format(**user)




         https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L26-L30

                                                                                        18
REST client Interface


1. Stand up a "REST Gateway" between your application and the cluster

2. HTTP verbs translate (roughly) into table commands

3. decent support for basic DDL, HTable operations




                                                                        19
HBase Cluster
                   REST
REST Clients
                  Gateway




               REST Architecture
                                            20
REST client Interface


•   REST gateway exposes a client to RegionServers

•   stateless :D

•   ... except for scanners :'(




                                                     21
REST client Example

$ curl -H "Accept: application/json" http://host:port/
{
  "table": [ {
               "name": "followers"
             }, {
               "name": "twits"
             }, {
               "name": "users"
             }
           ]
}




                                                         22
REST client Example
$ curl -H ... http://host:port/table/row [/family:qualifier]
{
    "Row": [
        {
             "key": "VGhlUmVhbE1U",
             "Cell": [
                 {
                     "$": "c2FtdWVsQGNsZW1lbnMub3Jn",
                     "column": "aW5mbzplbWFpbA==",
                     "timestamp": 1338701491422
                 },
                 {
                     "$": "TWFyayBUd2Fpbg==",
                     "column": "aW5mbzpuYW1l",
                     "timestamp": 1338701491422
                 },
             ]
        } ] }

                                                               23
REST client Example

<Rows>
  <Row key="VGhlUmVhbE1U">
    <Cells>
       <Cell column="aW5mbzplbWFpbA==" timestamp="1338701491422">
         c2FtdWVsQGNsZW1lbnMub3Jn
       </Cell>
       <Cell ...>
       ...
    </Cells>
  </Row>
</Rows>




                                                                    24
Beyond Apache




                25
asynchbase
•   Asynchronous non-blocking interface.

•   Inspired by Twisted Python.

•   Partial implementation of HTableInterface.

•   HBaseClient provides entry-point to data.



                                   https://github.com/OpenTSDB/asynchbase
                  http://tsunanet.net/~tsuna/asynchbase/api/org/hbase/async/HBaseClient.html


                                                                                               26
asynchbase
                                                                UpdateResult
                                                                   object



                                 output to
                            => [next state]               3
                        /
                                                               Interpret
input => [this state]                                         response
                        
                            => [error state]
                                 Exception
                                                 Boolean
                                               Put response
                                                                UpdateFailed
                                                                 Exception




                                                                               27
asynchbase Example
       final Scanner scanner = client.newScanner(TABLE_NAME);
       scanner.setFamily(INFO_FAM);
       scanner.setQualifier(PASSWORD_COL);

       ArrayList<ArrayList<KeyValue>> rows = null;
       ArrayList<Deferred<Boolean>> workers = new ArrayList<Deferred<Boolean>>();
       while ((rows = scanner.nextRows(1).joinUninterruptibly()) != null) {
         for (ArrayList<KeyValue> row : rows) {
           KeyValue kv = row.get(0);
           byte[] expected = kv.value();
           String userId = new String(kv.key());
           PutRequest put = new PutRequest(
               TABLE_NAME, kv.key(), kv.family(),
               kv.qualifier(), mkNewPassword(expected));
           Deferred<Boolean> d = client.compareAndSet(put, expected)
             .addCallback(new InterpretResponse(userId))
             .addCallbacks(new ResultToMessage(), new FailureToMessage())
             .addCallback(new SendMessage());
           workers.add(d);
         }
       }

https://github.com/hbaseinaction/twitbase-async/blob/master/src/main/java/HBaseIA/TwitBase/AsyncUsersTool.java#L151-L173

                                                                                                                           28
Others
Reduce day-to-day                                                        Full-blown schema
 developer pain                                                             management


      [Orderly]

                                                               Phoenix




                    Spring-Data
                      Hadoop                                                Kiji.org

                               https://github.com/ndimiduk/orderly
                            http://www.springsource.org/spring-data/
                            https://github.com/forcedotcom/phoenix
                                         http://www.kiji.org/
                                                                                             29
Apache Futures


•   Protobuf wire messages (0.96)

•   C client (TBD, HBASE-1015)

•   HBase Types (TBD, HBASE-8089)




                                     30
So, Webapps?




http://www.amazon.com/Back-Point-Rapiers/dp/B0000271GC

                                                         31
Software Architecture


•   Isolate DAO from app logic, separation of concerns, &c.

•   Separate environment configs from code.

•   Watch out for resource contention.




                                                              32
Deployment Architecture


•   Cache everywhere.

•   Know your component layers.




                                   33
HBase Warts

•   Know thy (HBase) version 0.{92,94,96} !

•   long-running client bug (HBASE-4805).

•   Gateway APIs only as up to date as the people before you require.

•   REST API particularly unpleasant for “Web2.0” folk.



                                                                        34
Thanks!

                                         Nick Dimiduk
                                              github.com/ndimiduk
                                              @xefyr
Nick Dimiduk
Amandeep Khurana
                                              n10k.com
                      FOREWORD BY
                   Michael Stack




                   MANNING




hbaseinaction.com


                                                                    35

More Related Content

What's hot (20)

PDF
Taking Apache Camel For a Ride
Bruce Snyder
 
KEY
Say Hello To Ecmascript 5
Juriy Zaytsev
 
PDF
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
PDF
Fluentd loves MongoDB, at MongoDB SV User Group, July 17, 2012
Treasure Data, Inc.
 
PPT
Oracle database - Get external data via HTTP, FTP and Web Services
Kim Berg Hansen
 
PDF
BlockChain implementation by python
wonyong hwang
 
PDF
T-121-5300 (2008) User Interface Design 10 - UIML
mniemi
 
ODP
Spring 4 advanced final_xtr_presentation
sourabh aggarwal
 
PPTX
Nancy + rest mow2012
Christian Horsdal
 
PDF
Tomcat连接池配置方法V2.1
Zianed Hou
 
PPT
Sqlapi0.1
jitendral
 
KEY
Aimaf
Saad RGUIG
 
PDF
Qt Network Explained (Portuguese)
Microsoft Mobile Developer
 
PDF
Session 40 : SAGA Overview and Introduction
ISSGC Summer School
 
PDF
Bring your infrastructure under control with Infrastructor
Stanislav Tiurikov
 
PDF
Introduction to PHP 5.3
guestcc91d4
 
PDF
Do you know what your drupal is doing? Observe it!
Luca Lusso
 
PPT
Spring data iii
명철 강
 
PPTX
Hazelcast
Bruno Lellis
 
PDF
Building node.js applications with Database Jones
John David Duncan
 
Taking Apache Camel For a Ride
Bruce Snyder
 
Say Hello To Ecmascript 5
Juriy Zaytsev
 
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
Fluentd loves MongoDB, at MongoDB SV User Group, July 17, 2012
Treasure Data, Inc.
 
Oracle database - Get external data via HTTP, FTP and Web Services
Kim Berg Hansen
 
BlockChain implementation by python
wonyong hwang
 
T-121-5300 (2008) User Interface Design 10 - UIML
mniemi
 
Spring 4 advanced final_xtr_presentation
sourabh aggarwal
 
Nancy + rest mow2012
Christian Horsdal
 
Tomcat连接池配置方法V2.1
Zianed Hou
 
Sqlapi0.1
jitendral
 
Aimaf
Saad RGUIG
 
Qt Network Explained (Portuguese)
Microsoft Mobile Developer
 
Session 40 : SAGA Overview and Introduction
ISSGC Summer School
 
Bring your infrastructure under control with Infrastructor
Stanislav Tiurikov
 
Introduction to PHP 5.3
guestcc91d4
 
Do you know what your drupal is doing? Observe it!
Luca Lusso
 
Spring data iii
명철 강
 
Hazelcast
Bruno Lellis
 
Building node.js applications with Database Jones
John David Duncan
 

Viewers also liked (20)

PPTX
HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...
Cloudera, Inc.
 
PDF
Apache HBase for Architects
Nick Dimiduk
 
PDF
Apache HBase Low Latency
Nick Dimiduk
 
KEY
Introduction to Hadoop, HBase, and NoSQL
Nick Dimiduk
 
PDF
Apache Spark Overview
Vadim Y. Bichutskiy
 
PPTX
HBase Low Latency, StrataNYC 2014
Nick Dimiduk
 
PDF
Bring Cartography to the Cloud
Nick Dimiduk
 
PDF
HBase Data Types (WIP)
Nick Dimiduk
 
PPTX
Strata + Hadoop World 2012: Apache HBase Features for the Enterprise
Cloudera, Inc.
 
PDF
HBase Data Types
Nick Dimiduk
 
PPTX
Let Spark Fly: Advantages and Use Cases for Spark on Hadoop
MapR Technologies
 
PPTX
Introduction to HBase - Phoenix HUG 5/14
Jeremy Walsh
 
PDF
Apache Big Data EU 2015 - HBase
Nick Dimiduk
 
PDF
HBase from the Trenches - Phoenix Data Conference 2015
Avinash Ramineni
 
PDF
Intro to HBase - Lars George
JAX London
 
PPTX
HBaseConEast2016: HBase and Spark, State of the Art
Michael Stack
 
PDF
[Spark meetup] Spark Streaming Overview
Stratio
 
PDF
HBase Advanced - Lars George
JAX London
 
PDF
Spark architecture
datamantra
 
PDF
Apache Big Data EU 2015 - Phoenix
Nick Dimiduk
 
HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...
Cloudera, Inc.
 
Apache HBase for Architects
Nick Dimiduk
 
Apache HBase Low Latency
Nick Dimiduk
 
Introduction to Hadoop, HBase, and NoSQL
Nick Dimiduk
 
Apache Spark Overview
Vadim Y. Bichutskiy
 
HBase Low Latency, StrataNYC 2014
Nick Dimiduk
 
Bring Cartography to the Cloud
Nick Dimiduk
 
HBase Data Types (WIP)
Nick Dimiduk
 
Strata + Hadoop World 2012: Apache HBase Features for the Enterprise
Cloudera, Inc.
 
HBase Data Types
Nick Dimiduk
 
Let Spark Fly: Advantages and Use Cases for Spark on Hadoop
MapR Technologies
 
Introduction to HBase - Phoenix HUG 5/14
Jeremy Walsh
 
Apache Big Data EU 2015 - HBase
Nick Dimiduk
 
HBase from the Trenches - Phoenix Data Conference 2015
Avinash Ramineni
 
Intro to HBase - Lars George
JAX London
 
HBaseConEast2016: HBase and Spark, State of the Art
Michael Stack
 
[Spark meetup] Spark Streaming Overview
Stratio
 
HBase Advanced - Lars George
JAX London
 
Spark architecture
datamantra
 
Apache Big Data EU 2015 - Phoenix
Nick Dimiduk
 
Ad

Similar to HBase Client APIs (for webapps?) (20)

KEY
HBase and Hadoop at Urban Airship
dave_revell
 
PPTX
002 hbase clientapi
Scott Miao
 
PDF
3 f6 9_distributed_systems
op205
 
PDF
The basics of fluentd
Treasure Data, Inc.
 
PDF
Facebook keynote-nicolas-qcon
Yiwei Ma
 
PDF
支撑Facebook消息处理的h base存储系统
yongboy
 
PDF
Facebook Messages & HBase
强 王
 
ODP
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
DataStax Academy
 
ODP
Intravert Server side processing for Cassandra
Edward Capriolo
 
PDF
Apache HBase 0.98
AndrewPurtell
 
PPTX
HBaseCon 2012 | Building a Large Search Platform on a Shoestring Budget
Cloudera, Inc.
 
PDF
Making Things Work Together
Subbu Allamaraju
 
PDF
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
 
PDF
appengine ja night #24 Google Cloud Endpoints and BigQuery (English)
Ryo Yamasaki
 
KEY
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Atlassian
 
KEY
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Atlassian
 
PDF
Realtime Sentiment Analysis Application Using Hadoop and HBase
DataWorks Summit
 
PDF
Hbase schema design and sizing apache-con europe - nov 2012
Chris Huang
 
PDF
Storage Infrastructure Behind Facebook Messages
yarapavan
 
PDF
upload test 1
Sadayuki Furuhashi
 
HBase and Hadoop at Urban Airship
dave_revell
 
002 hbase clientapi
Scott Miao
 
3 f6 9_distributed_systems
op205
 
The basics of fluentd
Treasure Data, Inc.
 
Facebook keynote-nicolas-qcon
Yiwei Ma
 
支撑Facebook消息处理的h base存储系统
yongboy
 
Facebook Messages & HBase
强 王
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
DataStax Academy
 
Intravert Server side processing for Cassandra
Edward Capriolo
 
Apache HBase 0.98
AndrewPurtell
 
HBaseCon 2012 | Building a Large Search Platform on a Shoestring Budget
Cloudera, Inc.
 
Making Things Work Together
Subbu Allamaraju
 
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
 
appengine ja night #24 Google Cloud Endpoints and BigQuery (English)
Ryo Yamasaki
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Atlassian
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Atlassian
 
Realtime Sentiment Analysis Application Using Hadoop and HBase
DataWorks Summit
 
Hbase schema design and sizing apache-con europe - nov 2012
Chris Huang
 
Storage Infrastructure Behind Facebook Messages
yarapavan
 
upload test 1
Sadayuki Furuhashi
 
Ad

HBase Client APIs (for webapps?)

  • 1. HBase Client API (for webapps?) Nick Dimiduk Seattle Scalability Meetup 2013-03-27 1
  • 2. 2
  • 3. 3
  • 4. What are my choices? switch (technology) { case ‘ ’: ... case ‘ ’: ... case ‘ ’: ... } 4
  • 6. Java client Interfaces • Configuration holds details where to find the cluster and tunable settings. Roughly equivalent to JDBC connection string. • HConnection represents connections to to the cluster. • HBaseAdmin handles DDL operations (create, list, drop, alter, &c.) • HTablePool connection pool for table handles. • HTable (HTableInterface) is a handle on a single HBase table. Send "commands" to the table (Put, Get, Scan, Delete, Increment) 6
  • 7. Java client Example public static final byte[] TABLE_NAME = Bytes.toBytes("twits"); public static final byte[] TWITS_FAM = Bytes.toBytes("twits"); public static final byte[] USER_COL = Bytes.toBytes("user"); public static final byte[] TWIT_COL = Bytes.toBytes("twit"); private HTablePool pool = new HTablePool(); https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L23-L30 7
  • 8. Java client Example private static class Twit { private Twit(Result r) { this( r.getColumnLatest(TWITS_FAM, USER_COL).getValue(), Arrays.copyOfRange(r.getRow(), Md5Utils.MD5_LENGTH, Md5Utils.MD5_LENGTH + longLength), r.getColumnLatest(TWITS_FAM, TWIT_COL).getValue()); } private Twit(byte[] user, byte[] dt, byte[] text) { this( Bytes.toString(user), new DateTime(-1 * Bytes.toLong(dt)), Bytes.toString(text)); } https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L129-L143 8
  • 9. Java client Example private static Get mkGet(String user, DateTime dt) { Get g = new Get(mkRowKey(user, dt)); g.addColumn(TWITS_FAM, USER_COL); g.addColumn(TWITS_FAM, TWIT_COL); return g; } https://github.com/hbaseinaction/twitbase/blob/master/src/main/java/HBaseIA/TwitBase/hbase/TwitsDAO.java#L60-L65 9
  • 10. Ruby, Python client Interface 10
  • 11. Ruby, Python client Interface Jyth on JRu by, : '( 11
  • 12. Thrift client Interface 1. Generate bindings 2. Run a “Gateway” between clients and cluster 3. ... profit? code! w rite 12
  • 13. HBase Cluster HBase Clients Sidebar: Architecture Recap 13
  • 14. Thrift Gateway HBase Cluster Thrift Clients Thrift Architecture 14
  • 15. Thrift client Interface • Thrift gateway exposes a client to RegionServers • stateless :D • ... except for scanners :'( 15
  • 16. Thrift client Example transport = TSocket.TSocket(host, port) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) transport.open() https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L17-L21 16
  • 17. Thrift client Example columns = ['info:user','info:name','info:email'] scanner = client.scannerOpen('users', '', columns) row = client.scannerGet(scanner) while row: yield user_from_row(row[0]) row = scannerGet(scanner) client.scannerClose(scanner) https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L33-L39 17
  • 18. Thrift client Example def user_from_row(row): user = {} for col,cell in row.columns.items(): user[col[5:]] = cell.value return "<User: {user}, {name}, {email}>".format(**user) https://github.com/hbaseinaction/twitbase.py/blob/master/TwitBase.py#L26-L30 18
  • 19. REST client Interface 1. Stand up a "REST Gateway" between your application and the cluster 2. HTTP verbs translate (roughly) into table commands 3. decent support for basic DDL, HTable operations 19
  • 20. HBase Cluster REST REST Clients Gateway REST Architecture 20
  • 21. REST client Interface • REST gateway exposes a client to RegionServers • stateless :D • ... except for scanners :'( 21
  • 22. REST client Example $ curl -H "Accept: application/json" http://host:port/ { "table": [ { "name": "followers" }, { "name": "twits" }, { "name": "users" } ] } 22
  • 23. REST client Example $ curl -H ... http://host:port/table/row [/family:qualifier] { "Row": [ { "key": "VGhlUmVhbE1U", "Cell": [ { "$": "c2FtdWVsQGNsZW1lbnMub3Jn", "column": "aW5mbzplbWFpbA==", "timestamp": 1338701491422 }, { "$": "TWFyayBUd2Fpbg==", "column": "aW5mbzpuYW1l", "timestamp": 1338701491422 }, ] } ] } 23
  • 24. REST client Example <Rows> <Row key="VGhlUmVhbE1U"> <Cells> <Cell column="aW5mbzplbWFpbA==" timestamp="1338701491422"> c2FtdWVsQGNsZW1lbnMub3Jn </Cell> <Cell ...> ... </Cells> </Row> </Rows> 24
  • 26. asynchbase • Asynchronous non-blocking interface. • Inspired by Twisted Python. • Partial implementation of HTableInterface. • HBaseClient provides entry-point to data. https://github.com/OpenTSDB/asynchbase http://tsunanet.net/~tsuna/asynchbase/api/org/hbase/async/HBaseClient.html 26
  • 27. asynchbase UpdateResult object output to => [next state] 3 / Interpret input => [this state] response => [error state] Exception Boolean Put response UpdateFailed Exception 27
  • 28. asynchbase Example final Scanner scanner = client.newScanner(TABLE_NAME); scanner.setFamily(INFO_FAM); scanner.setQualifier(PASSWORD_COL); ArrayList<ArrayList<KeyValue>> rows = null; ArrayList<Deferred<Boolean>> workers = new ArrayList<Deferred<Boolean>>(); while ((rows = scanner.nextRows(1).joinUninterruptibly()) != null) { for (ArrayList<KeyValue> row : rows) { KeyValue kv = row.get(0); byte[] expected = kv.value(); String userId = new String(kv.key()); PutRequest put = new PutRequest( TABLE_NAME, kv.key(), kv.family(), kv.qualifier(), mkNewPassword(expected)); Deferred<Boolean> d = client.compareAndSet(put, expected) .addCallback(new InterpretResponse(userId)) .addCallbacks(new ResultToMessage(), new FailureToMessage()) .addCallback(new SendMessage()); workers.add(d); } } https://github.com/hbaseinaction/twitbase-async/blob/master/src/main/java/HBaseIA/TwitBase/AsyncUsersTool.java#L151-L173 28
  • 29. Others Reduce day-to-day Full-blown schema developer pain management [Orderly] Phoenix Spring-Data Hadoop Kiji.org https://github.com/ndimiduk/orderly http://www.springsource.org/spring-data/ https://github.com/forcedotcom/phoenix http://www.kiji.org/ 29
  • 30. Apache Futures • Protobuf wire messages (0.96) • C client (TBD, HBASE-1015) • HBase Types (TBD, HBASE-8089) 30
  • 32. Software Architecture • Isolate DAO from app logic, separation of concerns, &c. • Separate environment configs from code. • Watch out for resource contention. 32
  • 33. Deployment Architecture • Cache everywhere. • Know your component layers. 33
  • 34. HBase Warts • Know thy (HBase) version 0.{92,94,96} ! • long-running client bug (HBASE-4805). • Gateway APIs only as up to date as the people before you require. • REST API particularly unpleasant for “Web2.0” folk. 34
  • 35. Thanks! Nick Dimiduk github.com/ndimiduk @xefyr Nick Dimiduk Amandeep Khurana n10k.com FOREWORD BY Michael Stack MANNING hbaseinaction.com 35