Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Getting Started

dgomezferro edited this page May 14, 2012 · 17 revisions

Here we explain all the steps needed to get a transactional HBase working assuming you already have a (pseudo-)distributed HBase cluster.

Installation

To install Omid, just download an unpack the repository. Under the main directory, run this

$ mvn install

Now you can add a dependency on Omid-0.0.1-SNAPSHOT on your project if you are using maven.

Configuration

Omid's clients use the usual hbase-site.xml for configuration, it needs two additional parameters

<property>
 <name>tso.host</name>
 <value>tso.your.cluster.com</value>
</property>
<property>
  <name>tso.port</name>
  <value>1234</value>
</property>

Usage

To use HBase transactional support the relevant interfaces are TransactionManager and TransactionalTable, both in com.yahoo.omid.client. The common use case is to start a new transaction with TransactionState txn1 = transactionManager.beginTransaction(), then use this transaction to perform different HBase operations, like transactionalTable.put(txn1, putOperation) and finally commit it transactionManager.tryCommit(txn1).

Example

     Configuration conf = HBaseConfiguration.create();
     TransactionManager tm = new TransactionManager(conf);
     TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);
     
     TransactionState t1 = tm.beginTransaction();

     Put put = new Put(row);
     putt.add(fam, col, data);
     tt.put(t1, p);
     
     ResultScanner rs = tt.getScanner(t1, new Scan().setStartRow(startrow).setStopRow(stoprow));
     Result r = rs.next();
     while (r != null) {
        ...
        r = rs.next();
     }
     tm.tryCommit(t1);