co.cask.tephra.hbase94
Class TransactionAwareHTable

java.lang.Object
  extended by co.cask.tephra.hbase94.TransactionAwareHTable
All Implemented Interfaces:
TransactionAware, Closeable, org.apache.hadoop.hbase.client.HTableInterface

public class TransactionAwareHTable
extends Object
implements org.apache.hadoop.hbase.client.HTableInterface, TransactionAware

A Transaction Aware HTable implementation for HBase 0.94.


Constructor Summary
TransactionAwareHTable(org.apache.hadoop.hbase.client.HTable hTable)
          Create a transactional aware instance of the passed HTable
TransactionAwareHTable(org.apache.hadoop.hbase.client.HTable hTable, boolean allowNonTransactional)
          Create a transactional aware instance of the passed HTable, with the option of allowing non-transactional operations.
 
Method Summary
 org.apache.hadoop.hbase.client.Result append(org.apache.hadoop.hbase.client.Append append)
           
 Object[] batch(List<? extends org.apache.hadoop.hbase.client.Row> actions)
           
 void batch(List<? extends org.apache.hadoop.hbase.client.Row> actions, Object[] results)
           
 boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, org.apache.hadoop.hbase.client.Delete delete)
           
 boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, org.apache.hadoop.hbase.client.Put put)
           
 void close()
           
 boolean commitTx()
           
<T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol,R>
Map<byte[],R>
coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, org.apache.hadoop.hbase.client.coprocessor.Batch.Call<T,R> callable)
           
<T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol,R>
void
coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, org.apache.hadoop.hbase.client.coprocessor.Batch.Call<T,R> callable, org.apache.hadoop.hbase.client.coprocessor.Batch.Callback<R> callback)
           
<T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol>
T
coprocessorProxy(Class<T> protocol, byte[] row)
           
 void delete(org.apache.hadoop.hbase.client.Delete delete)
           
 void delete(List<org.apache.hadoop.hbase.client.Delete> deletes)
           
 boolean exists(org.apache.hadoop.hbase.client.Get get)
           
 void flushCommits()
           
 org.apache.hadoop.hbase.client.Result get(org.apache.hadoop.hbase.client.Get get)
           
 org.apache.hadoop.hbase.client.Result[] get(List<org.apache.hadoop.hbase.client.Get> gets)
           
 boolean getAllowNonTransactional()
          True if the instance allows non-transaction operations.
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 org.apache.hadoop.hbase.client.Result getRowOrBefore(byte[] row, byte[] family)
           
 org.apache.hadoop.hbase.client.ResultScanner getScanner(byte[] family)
           
 org.apache.hadoop.hbase.client.ResultScanner getScanner(byte[] family, byte[] qualifier)
           
 org.apache.hadoop.hbase.client.ResultScanner getScanner(org.apache.hadoop.hbase.client.Scan scan)
           
 org.apache.hadoop.hbase.HTableDescriptor getTableDescriptor()
           
 byte[] getTableName()
           
 String getTransactionAwareName()
           
 Collection<byte[]> getTxChanges()
           
 long getWriteBufferSize()
           
 org.apache.hadoop.hbase.client.Result increment(org.apache.hadoop.hbase.client.Increment increment)
           
 long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount)
           
 long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL)
           
 boolean isAutoFlush()
           
 org.apache.hadoop.hbase.client.RowLock lockRow(byte[] row)
           
 void mutateRow(org.apache.hadoop.hbase.client.RowMutations rm)
           
 void postTxCommit()
           
 void put(List<org.apache.hadoop.hbase.client.Put> puts)
           
 void put(org.apache.hadoop.hbase.client.Put put)
           
 boolean rollbackTx()
           
 void setAllowNonTransactional(boolean allowNonTransactional)
          Set whether the instance allows non-transactional operations.
 void setAutoFlush(boolean autoFlush)
           
 void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail)
           
 void setWriteBufferSize(long writeBufferSize)
           
 void startTx(Transaction tx)
           
 void unlockRow(org.apache.hadoop.hbase.client.RowLock rl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionAwareHTable

public TransactionAwareHTable(org.apache.hadoop.hbase.client.HTable hTable)
Create a transactional aware instance of the passed HTable

Parameters:
hTable -

TransactionAwareHTable

public TransactionAwareHTable(org.apache.hadoop.hbase.client.HTable hTable,
                              boolean allowNonTransactional)
Create a transactional aware instance of the passed HTable, with the option of allowing non-transactional operations.

Parameters:
hTable -
allowNonTransactional -
Method Detail

getAllowNonTransactional

public boolean getAllowNonTransactional()
True if the instance allows non-transaction operations.

Returns:

setAllowNonTransactional

public void setAllowNonTransactional(boolean allowNonTransactional)
Set whether the instance allows non-transactional operations.

Parameters:
allowNonTransactional -

getTableName

public byte[] getTableName()
Specified by:
getTableName in interface org.apache.hadoop.hbase.client.HTableInterface

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Specified by:
getConfiguration in interface org.apache.hadoop.hbase.client.HTableInterface

getTableDescriptor

public org.apache.hadoop.hbase.HTableDescriptor getTableDescriptor()
                                                            throws IOException
Specified by:
getTableDescriptor in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

exists

public boolean exists(org.apache.hadoop.hbase.client.Get get)
               throws IOException
Specified by:
exists in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

batch

public void batch(List<? extends org.apache.hadoop.hbase.client.Row> actions,
                  Object[] results)
           throws IOException,
                  InterruptedException
Specified by:
batch in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException
InterruptedException

batch

public Object[] batch(List<? extends org.apache.hadoop.hbase.client.Row> actions)
               throws IOException,
                      InterruptedException
Specified by:
batch in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException
InterruptedException

get

public org.apache.hadoop.hbase.client.Result get(org.apache.hadoop.hbase.client.Get get)
                                          throws IOException
Specified by:
get in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

get

public org.apache.hadoop.hbase.client.Result[] get(List<org.apache.hadoop.hbase.client.Get> gets)
                                            throws IOException
Specified by:
get in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

getRowOrBefore

public org.apache.hadoop.hbase.client.Result getRowOrBefore(byte[] row,
                                                            byte[] family)
                                                     throws IOException
Specified by:
getRowOrBefore in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

getScanner

public org.apache.hadoop.hbase.client.ResultScanner getScanner(org.apache.hadoop.hbase.client.Scan scan)
                                                        throws IOException
Specified by:
getScanner in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

getScanner

public org.apache.hadoop.hbase.client.ResultScanner getScanner(byte[] family)
                                                        throws IOException
Specified by:
getScanner in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

getScanner

public org.apache.hadoop.hbase.client.ResultScanner getScanner(byte[] family,
                                                               byte[] qualifier)
                                                        throws IOException
Specified by:
getScanner in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

put

public void put(org.apache.hadoop.hbase.client.Put put)
         throws IOException
Specified by:
put in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

put

public void put(List<org.apache.hadoop.hbase.client.Put> puts)
         throws IOException
Specified by:
put in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

checkAndPut

public boolean checkAndPut(byte[] row,
                           byte[] family,
                           byte[] qualifier,
                           byte[] value,
                           org.apache.hadoop.hbase.client.Put put)
                    throws IOException
Specified by:
checkAndPut in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

delete

public void delete(org.apache.hadoop.hbase.client.Delete delete)
            throws IOException
Specified by:
delete in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

delete

public void delete(List<org.apache.hadoop.hbase.client.Delete> deletes)
            throws IOException
Specified by:
delete in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

checkAndDelete

public boolean checkAndDelete(byte[] row,
                              byte[] family,
                              byte[] qualifier,
                              byte[] value,
                              org.apache.hadoop.hbase.client.Delete delete)
                       throws IOException
Specified by:
checkAndDelete in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

mutateRow

public void mutateRow(org.apache.hadoop.hbase.client.RowMutations rm)
               throws IOException
Specified by:
mutateRow in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

append

public org.apache.hadoop.hbase.client.Result append(org.apache.hadoop.hbase.client.Append append)
                                             throws IOException
Specified by:
append in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

increment

public org.apache.hadoop.hbase.client.Result increment(org.apache.hadoop.hbase.client.Increment increment)
                                                throws IOException
Specified by:
increment in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

incrementColumnValue

public long incrementColumnValue(byte[] row,
                                 byte[] family,
                                 byte[] qualifier,
                                 long amount)
                          throws IOException
Specified by:
incrementColumnValue in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

incrementColumnValue

public long incrementColumnValue(byte[] row,
                                 byte[] family,
                                 byte[] qualifier,
                                 long amount,
                                 boolean writeToWAL)
                          throws IOException
Specified by:
incrementColumnValue in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

isAutoFlush

public boolean isAutoFlush()
Specified by:
isAutoFlush in interface org.apache.hadoop.hbase.client.HTableInterface

flushCommits

public void flushCommits()
                  throws IOException
Specified by:
flushCommits in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

lockRow

public org.apache.hadoop.hbase.client.RowLock lockRow(byte[] row)
                                               throws IOException
Specified by:
lockRow in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

unlockRow

public void unlockRow(org.apache.hadoop.hbase.client.RowLock rl)
               throws IOException
Specified by:
unlockRow in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

coprocessorProxy

public <T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol> T coprocessorProxy(Class<T> protocol,
                                                                                      byte[] row)
Specified by:
coprocessorProxy in interface org.apache.hadoop.hbase.client.HTableInterface

coprocessorExec

public <T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol,R> Map<byte[],R> coprocessorExec(Class<T> protocol,
                                                                                                   byte[] startKey,
                                                                                                   byte[] endKey,
                                                                                                   org.apache.hadoop.hbase.client.coprocessor.Batch.Call<T,R> callable)
                              throws IOException,
                                     Throwable
Specified by:
coprocessorExec in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException
Throwable

coprocessorExec

public <T extends org.apache.hadoop.hbase.ipc.CoprocessorProtocol,R> void coprocessorExec(Class<T> protocol,
                                                                                          byte[] startKey,
                                                                                          byte[] endKey,
                                                                                          org.apache.hadoop.hbase.client.coprocessor.Batch.Call<T,R> callable,
                                                                                          org.apache.hadoop.hbase.client.coprocessor.Batch.Callback<R> callback)
                     throws IOException,
                            Throwable
Specified by:
coprocessorExec in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException
Throwable

setAutoFlush

public void setAutoFlush(boolean autoFlush)
Specified by:
setAutoFlush in interface org.apache.hadoop.hbase.client.HTableInterface

setAutoFlush

public void setAutoFlush(boolean autoFlush,
                         boolean clearBufferOnFail)
Specified by:
setAutoFlush in interface org.apache.hadoop.hbase.client.HTableInterface

getWriteBufferSize

public long getWriteBufferSize()
Specified by:
getWriteBufferSize in interface org.apache.hadoop.hbase.client.HTableInterface

setWriteBufferSize

public void setWriteBufferSize(long writeBufferSize)
                        throws IOException
Specified by:
setWriteBufferSize in interface org.apache.hadoop.hbase.client.HTableInterface
Throws:
IOException

startTx

public void startTx(Transaction tx)
Specified by:
startTx in interface TransactionAware

getTxChanges

public Collection<byte[]> getTxChanges()
Specified by:
getTxChanges in interface TransactionAware

commitTx

public boolean commitTx()
                 throws Exception
Specified by:
commitTx in interface TransactionAware
Throws:
Exception

postTxCommit

public void postTxCommit()
Specified by:
postTxCommit in interface TransactionAware

rollbackTx

public boolean rollbackTx()
                   throws Exception
Specified by:
rollbackTx in interface TransactionAware
Throws:
Exception

getTransactionAwareName

public String getTransactionAwareName()
Specified by:
getTransactionAwareName in interface TransactionAware


Copyright © 2014. All Rights Reserved.