org.springframework.data.hadoop.hbase
Class HbaseUtils

java.lang.Object
  extended by org.springframework.data.hadoop.hbase.HbaseUtils

public class HbaseUtils
extends Object

Helper class featuring methods for Hbase table handling and exception translation.

Author:
Costin Leau

Constructor Summary
HbaseUtils()
           
 
Method Summary
static DataAccessException convertHbaseException(Exception ex)
          Converts the given (Hbase) exception to an appropriate exception from org.springframework.dao hierarchy.
static HTableInterface getHTable(String tableName, Configuration configuration)
          Retrieves an Hbase table instance identified by its name.
static HTableInterface getHTable(String tableName, Configuration configuration, Charset charset, HTableInterfaceFactory tableFactory)
          Retrieves an Hbase table instance identified by its name and charset using the given table factory.
static void releaseTable(String tableName, HTableInterface table)
          Releases (or closes) the given table, created via the given configuration if it is not managed externally (or bound to the thread).
static void releaseTable(String tableName, HTableInterface table, HTableInterfaceFactory tableFactory)
          Releases (or closes) the given table, created via the given configuration if it is not managed externally (or bound to the thread).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HbaseUtils

public HbaseUtils()
Method Detail

convertHbaseException

public static DataAccessException convertHbaseException(Exception ex)
Converts the given (Hbase) exception to an appropriate exception from org.springframework.dao hierarchy.

Parameters:
ex - Hbase exception that occurred
Returns:
the corresponding DataAccessException instance

getHTable

public static HTableInterface getHTable(String tableName,
                                        Configuration configuration)
Retrieves an Hbase table instance identified by its name.

Parameters:
configuration - Hbase configuration object
tableName - table name
Returns:
table instance

getHTable

public static HTableInterface getHTable(String tableName,
                                        Configuration configuration,
                                        Charset charset,
                                        HTableInterfaceFactory tableFactory)
Retrieves an Hbase table instance identified by its name and charset using the given table factory.

Parameters:
tableName - table name
configuration - Hbase configuration object
charset - name charset (may be null)
tableFactory - table factory (may be null)
Returns:
table instance

releaseTable

public static void releaseTable(String tableName,
                                HTableInterface table)
Releases (or closes) the given table, created via the given configuration if it is not managed externally (or bound to the thread).

Parameters:
tableName -
table -

releaseTable

public static void releaseTable(String tableName,
                                HTableInterface table,
                                HTableInterfaceFactory tableFactory)
Releases (or closes) the given table, created via the given configuration if it is not managed externally (or bound to the thread).

Parameters:
tableName -
table -
tableFactory -