org.springframework.data.hadoop.hbase
Class HbaseSynchronizationManager

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

public abstract class HbaseSynchronizationManager
extends Object

Synchronization manager handling the tracking of Hbase resources (specifically tables). Used either manually or through HbaseInterceptor to bind a table to the thread. Each subsequent call made through HbaseTemplate is aware of the table bound and will use it instead of retrieving a new instance.

Author:
Costin Leau

Constructor Summary
HbaseSynchronizationManager()
           
 
Method Summary
static void bindResource(String key, HTableInterface value)
          Binds the given resource for the given key to the current thread.
static HTableInterface getResource(Object key)
          Returns the resource (table) associated with the given key.
static Set<String> getTableNames()
          Returns the bound tables (by name).
static boolean hasResource(Object key)
          Checks whether any resource is bound for the given key.
static HTableInterface unbindResource(String key)
          Unbinds a resource for the given key from the current thread.
static Object unbindResourceIfPossible(Object key)
          Unbinds a resource for the given key from the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HbaseSynchronizationManager

public HbaseSynchronizationManager()
Method Detail

hasResource

public static boolean hasResource(Object key)
Checks whether any resource is bound for the given key.

Parameters:
key - key to check
Returns:
whether or not a resource is bound for the given key

getResource

public static HTableInterface getResource(Object key)
Returns the resource (table) associated with the given key.

Parameters:
key - association key
Returns:
associated resource (table)

bindResource

public static void bindResource(String key,
                                HTableInterface value)
                         throws IllegalStateException
Binds the given resource for the given key to the current thread.

Parameters:
key - the key to bind the value to (usually the resource factory)
value - the value to bind (usually the active resource object)
Throws:
IllegalStateException - if there is already a value bound to the thread
See Also:
ResourceTransactionManager.getResourceFactory()

unbindResource

public static HTableInterface unbindResource(String key)
                                      throws IllegalStateException
Unbinds a resource for the given key from the current thread.

Parameters:
key - the key to unbind (usually the resource factory)
Returns:
the previously bound value (usually the active resource object)
Throws:
IllegalStateException - if there is no value bound to the thread
See Also:
ResourceTransactionManager.getResourceFactory()

unbindResourceIfPossible

public static Object unbindResourceIfPossible(Object key)
Unbinds a resource for the given key from the current thread.

Parameters:
key - the key to unbind (usually the resource factory)
Returns:
the previously bound value, or null if none bound

getTableNames

public static Set<String> getTableNames()
Returns the bound tables (by name).

Returns:
names of bound tables