-
Notifications
You must be signed in to change notification settings - Fork 106
Getting Started
Here we explain all the steps needed to get a transactional HBase working assuming you already have a (pseudo-)distributed HBase cluster.
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.
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>
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)
.
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);
Omid
Copyright 2011-2015 Yahoo Inc. Licensed under the Apache License, Version 2.0