public class

HbaseCloudConnector

extends Object
java.lang.Object
   ↳ org.mule.module.hbase.HbaseCloudConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

HBase connector

It delegates each Processor on a HBaseService and it accepts custom configuration in a Key-Value fashion

Summary

Fields
private HBaseService facade The HBaseService You may change it for mocking purposes
private Map<String, String> properties HBase internal configuration properties, be sure to add the following properties to ensure a connection against your hBase instance: "hbase.zookeeper.quorum", "hbase.zookeeper.property.clientPort" For more information please consult HBase documentation.
Public Constructors
HbaseCloudConnector()
Public Methods
void addColumnFamily(String tableName, String columnFamilyName, Integer maxVersions, Boolean inMemory, Integer scope)
Adds a column family to a table given a table and column name.
boolean checkAndDeleteValue(String tableName, String rowKey, String checkColumnFamilyName, String checkColumnQualifier, Object checkValue, String deleteColumnFamilyName, String deleteColumnQualifier, Long deleteTimestamp, boolean deleteAllVersions, RowLock lock)
Atomically checks if a value at a (table, row,family,qualifier) matches the given one.
boolean checkAndPutValue(String tableName, String rowKey, String checkColumnFamilyName, String checkColumnQualifier, Object checkValue, String putColumnFamilyName, String putColumnQualifier, Long putTimestamp, Object value, boolean writeToWAL, RowLock lock)
Atomically checks if a value at a (table, row,family,qualifier) matches the given one.
void createTable(String tableName)
Creates a new table given its name.
void deleteColumnFamily(String tableName, String columnFamilyName)
Delete a column family
void deleteTable(String tableName)
Disables and deletes an existent table.
void deleteValues(String tableName, String rowKey, String columnFamilyName, String columnQualifier, Long timestamp, boolean deleteAllVersions, RowLock lock)
Deletes the values at a given row
void disableTable(String tableName)
Disables an existent table
void enableTable(String tableName)
Enables an existent table.
boolean existsColumnFamily(String tableName, String columnFamilyName)
Answers if column family exists.
boolean existsTable(String tableName)
Answers if a given table exists, regardless it is enabled or not
HBaseService getFacade()
Map<String, String> getProperties()
Result getValues(String tableName, String rowKey, String columnFamilyName, String columnQualifier, Integer maxVersions, Long timestamp)
Answers the values at the given row - (table, row) combination
long incrementValue(String tableName, String rowKey, String columnFamilyName, String columnQualifier, long amount, boolean writeToWAL)
Atomically increments the value of at a (table, row, familyName, familyQualifier) combination.
void initialiseConnector()
boolean isAliveServer()
Answers if the HBase server is reachable
boolean isEnabledTable(String tableName)
Answers if the given existent table is enabled.
void modifyColumnFamily(String tableName, String columnFamilyName, Integer maxVersions, Integer blocksize, CompressionType compressionType, CompressionType compactionCompressionType, Boolean inMemory, Integer timeToLive, Boolean blockCacheEnabled, BloomFilterType bloomFilterType, Integer replicationScope, Map<String, String> values)
Changes one or more properties of a column family in a table.
void putValue(String tableName, String rowKey, String columnFamilyName, String columnQualifier, Long timestamp, Object value, boolean writeToWAL, RowLock lock)
Saves a value at the specified (table, row, familyName, familyQualifier, timestamp) combination
Iterable<Result> scanTable(String tableName, String columnFamilyName, String columnQualifier, Long timestamp, Long maxTimestamp, Integer caching, boolean cacheBlocks, int maxVersions, String startRowKey, String stopRowKey, int fetchSize)
Scans across all rows in a table, returning a scanner over it
void setFacade(HBaseService facade)
void setProperties(Map<String, String> properties)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private HBaseService facade

The HBaseService You may change it for mocking purposes

private Map<String, String> properties

HBase internal configuration properties, be sure to add the following properties to ensure a connection against your hBase instance: "hbase.zookeeper.quorum", "hbase.zookeeper.property.clientPort" For more information please consult HBase documentation.

Public Constructors

public HbaseCloudConnector ()

Public Methods

public void addColumnFamily (String tableName, String columnFamilyName, Integer maxVersions, Boolean inMemory, Integer scope)

Adds a column family to a table given a table and column name. This Processor gracefully handles necessary table disabling and enabled.

Parameters
tableName The name of the target table
columnFamilyName The name of the column
maxVersions The optional maximum number of versions the column family supports
inMemory If all the column values will be stored in the region's cache
scope Replication scope: 0 for locally scoped data (data for this column family will not be replicated) and 1 for globally scoped data (data will be replicated to all peers.))

public boolean checkAndDeleteValue (String tableName, String rowKey, String checkColumnFamilyName, String checkColumnQualifier, Object checkValue, String deleteColumnFamilyName, String deleteColumnQualifier, Long deleteTimestamp, boolean deleteAllVersions, RowLock lock)

Atomically checks if a value at a (table, row,family,qualifier) matches the given one. If it does, it performs the delete.

Parameters
tableName The name of the table that contains the cell to check.
rowKey The row key that contains the cell to check.
checkColumnFamilyName The column family of the cell to check.
checkColumnQualifier The qualifier of the column to check
checkValue The value to check. It must be either a byte array or a serializable object. As a special case, strings are saved always in standard utf-8 format.
deleteColumnFamilyName The name of the column family to delete
deleteColumnQualifier The qualifier of the column values to delete. If no qualifier is specified, the Processor will affect all the qulifiers for the given column family name to delete. Thus it has only sense if deleteColumnFamilyName is specified
deleteTimestamp The timestamp of the values to delete. If no timestamp is specified, the most recent timestamp for the deleted value is used. Only has sense if deleteColumnFamilyName is specified
deleteAllVersions If all versions should be deleted,or only those more recent than the deleteTimestamp. Only has sense if deleteColumnFamilyName and deleteColumnQualifier are specified
lock An optional RowLock
Returns
  • true if the new delete was executed, false otherwise

public boolean checkAndPutValue (String tableName, String rowKey, String checkColumnFamilyName, String checkColumnQualifier, Object checkValue, String putColumnFamilyName, String putColumnQualifier, Long putTimestamp, Object value, boolean writeToWAL, RowLock lock)

Atomically checks if a value at a (table, row,family,qualifier) matches the given one. If it does, it performs the put.

Parameters
tableName The name of the table that contains the cell to check.
rowKey The row key that contains the cell to check.
checkColumnFamilyName The column family of the cell to check.
checkColumnQualifier The column qualifier of the cell to check.
checkValue The value to check. It must be either a byte array or a serializable object. As a special case, strings are saved always in standard utf-8 format.
putColumnFamilyName The column family of the cell to put.
putColumnQualifier The column qualifier of the cell to put.
putTimestamp The version dimension to put.
value The value to put. It must be either a byte array or a serializable object. As a special case, strings are saved always in standard utf-8 format.
writeToWAL Set it to false means that in a fail scenario, you will lose any increments that have not been flushed.
lock And optional RowLock
Returns
  • true if the new put was executed, false otherwise

public void createTable (String tableName)

Creates a new table given its name. The descriptor must be unique and not reserved.

Parameters
tableName The descriptor for the new table.

public void deleteColumnFamily (String tableName, String columnFamilyName)

Delete a column family

Parameters
tableName Required the target table
columnFamilyName Required the target column family

public void deleteTable (String tableName)

Disables and deletes an existent table.

Parameters
tableName Name of table to delete

public void deleteValues (String tableName, String rowKey, String columnFamilyName, String columnQualifier, Long timestamp, boolean deleteAllVersions, RowLock lock)

Deletes the values at a given row

Parameters
tableName The name of the target table
rowKey The key of the row to delete
columnFamilyName Set null to delete all column families in the specified row
columnQualifier The qualifier of the column values to delete. If no qualifier is specified, the Processor will affect all the qulifiers for the given column family name to delete. Thus it has only sense if deleteColumnFamilyName is specified
timestamp The timestamp of the values to delete. If no timestamp is specified, the most recent timestamp for the deleted value is used. Only has sense if deleteColumnFamilyName is specified
deleteAllVersions If all versions should be deleted,or only those more recent than the deleteTimestamp. Only has sense if deleteColumnFamilyName and deleteColumnQualifier are specified
lock An optional RowLock

public void disableTable (String tableName)

Disables an existent table

Parameters
tableName The table name to disable

public void enableTable (String tableName)

Enables an existent table.

Parameters
tableName Name of the table to enable

public boolean existsColumnFamily (String tableName, String columnFamilyName)

Answers if column family exists.

Parameters
tableName The target table name
columnFamilyName The target column family name
Returns
  • true if the column exists, false otherwise

public boolean existsTable (String tableName)

Answers if a given table exists, regardless it is enabled or not

Parameters
tableName The table name
Returns
  • true only if the table exists, false otherwise

public HBaseService getFacade ()

public Map<String, String> getProperties ()

public Result getValues (String tableName, String rowKey, String columnFamilyName, String columnQualifier, Integer maxVersions, Long timestamp)

Answers the values at the given row - (table, row) combination

Parameters
tableName Required the target table
rowKey The key of the row to update
columnFamilyName Limits the scan to a specific column family or null
columnQualifier Limits the scan to a specific column or null. Requires a columnFamilyName to be defined.
maxVersions The maximum number of versions to retrieved
timestamp The timestamp
Returns
  • the Result

public long incrementValue (String tableName, String rowKey, String columnFamilyName, String columnQualifier, long amount, boolean writeToWAL)

Atomically increments the value of at a (table, row, familyName, familyQualifier) combination. If the cell value does not yet exist it is initialized to amount.

Parameters
tableName The name of the table that contains the cell to increment.
rowKey The row key that contains the cell to increment.
columnFamilyName The column family of the cell to increment.
columnQualifier The column qualifier of the cell to increment.
amount The amount to increment the cell with (or decrement, if the amount is negative).
writeToWAL Set it to false means that in a fail scenario, you will lose any increments that have not been flushed.
Returns
  • the new value, post increment

public void initialiseConnector ()

Throws
InitialisationException
See Also

public boolean isAliveServer ()

Answers if the HBase server is reachable

Returns
  • true if the server can be reached and the master node is alive, false otherwise.

public boolean isEnabledTable (String tableName)

Answers if the given existent table is enabled.

Parameters
tableName Name of the table to query for its enabling state
Returns
  • true only if the table was disabled. False otherwise

public void modifyColumnFamily (String tableName, String columnFamilyName, Integer maxVersions, Integer blocksize, CompressionType compressionType, CompressionType compactionCompressionType, Boolean inMemory, Integer timeToLive, Boolean blockCacheEnabled, BloomFilterType bloomFilterType, Integer replicationScope, Map<String, String> values)

Changes one or more properties of a column family in a table. This Processor gracefully handles necessary table disabling and enabled.

Parameters
tableName Required the target table
columnFamilyName Required the target column family
maxVersions The new max amount of versions
blocksize The the new block size
compressionType The new compression type
compactionCompressionType The new compaction compression type
inMemory New value for if values are stored in Region's cache
timeToLive New ttl
blockCacheEnabled New value of enabling block cache
bloomFilterType New value of bloom filter type
replicationScope New value for replication scope
values Other custom parameters values

public void putValue (String tableName, String rowKey, String columnFamilyName, String columnQualifier, Long timestamp, Object value, boolean writeToWAL, RowLock lock)

Saves a value at the specified (table, row, familyName, familyQualifier, timestamp) combination

Parameters
tableName Required the target table
rowKey The key of the row to update
columnFamilyName The column family dimension
columnQualifier The column qualifier dimension
timestamp The version dimension
value The value to put. It must be either a byte array or a serializable object. As a special case, strings are saved always in standard utf-8 format.
writeToWAL Set it to false means that in a fail scenario, you will lose any increments that have not been flushed.
lock A optional RowLock

public Iterable<Result> scanTable (String tableName, String columnFamilyName, String columnQualifier, Long timestamp, Long maxTimestamp, Integer caching, boolean cacheBlocks, int maxVersions, String startRowKey, String stopRowKey, int fetchSize)

Scans across all rows in a table, returning a scanner over it

Parameters
tableName Limits the scan to a specific table. This is the only required argument.
columnFamilyName Limits the scan to a specific column family or null
columnQualifier Limits the scan to a specific column or null. Requires a columnFamilyName to be defined.
timestamp Limits the scan to a specific timestamp
maxTimestamp Get versions of columns only within the specified timestamp range: [timestamp, maxTimestamp)
caching The number of rows for caching
cacheBlocks The number of rows for caching that will be passed to scanners
maxVersions Limits the number of versions on each column
startRowKey Limits the beginning of the scan to the specified row inclusive
stopRowKey Limits the end of the scan to the specified row exclusive
fetchSize The number of results internally fetched by request to the HBase server. Increase it for improving network efficiency, or decrease it for reducing memory usage
Returns
  • an Iterable of Result's. It may be used with a collection splitter.

public void setFacade (HBaseService facade)

Parameters
facade

public void setProperties (Map<String, String> properties)

Parameters
properties