org.infinispan.loaders.hbase
Class HBaseCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
          extended by org.infinispan.loaders.hbase.HBaseCacheStore
All Implemented Interfaces:
CacheLoader, CacheStore

public class HBaseCacheStore
extends AbstractCacheStore

Cache store using HBase as the implementation.

Since:
5.2
Author:
Justin Hayes

Field Summary
 
Fields inherited from class org.infinispan.loaders.AbstractCacheStore
multiThreadedPurge, purgerService
 
Fields inherited from class org.infinispan.loaders.AbstractCacheLoader
cache, marshaller, timeService
 
Constructor Summary
HBaseCacheStore()
           
 
Method Summary
 void clear()
          Removes all entries from the cache.
 void fromStream(ObjectInput in)
          Stores an object that has been unmarshalled to a stream into the cache.
 Class<? extends CacheLoaderConfig> getConfigurationClass()
          Returns the class that represents this cache store's configuration.
 void init(CacheLoaderConfig clc, Cache<?,?> cache, StreamingMarshaller m)
          Used to initialize a cache loader.
 Set<InternalCacheEntry> load(int numEntries)
          Loads entries from the cache up to a certain number.
 InternalCacheEntry load(Object key)
          Loads an entry from the cache, given its key.
 Set<InternalCacheEntry> loadAll()
          Loads all entries from the cache.
 Set<Object> loadAllKeys(Set<Object> keysToExclude)
          Loads all keys from the cache, optionally excluding some.
protected  void purgeInternal()
          Purges any expired entries from the cache.
 boolean remove(Object key)
          Removes an entry from the cache, given its key.
 void start()
           
 void store(InternalCacheEntry entry)
          Stores an entry into the cache.
 void toStream(ObjectOutput out)
          Loads all entries from the cache and marshalls them to an object stream.
 String toString()
           
 
Methods inherited from class org.infinispan.loaders.AbstractCacheStore
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, stop, supportsMultiThreadedPurge
 
Methods inherited from class org.infinispan.loaders.AbstractCacheLoader
containsKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.infinispan.loaders.CacheLoader
containsKey
 

Constructor Detail

HBaseCacheStore

public HBaseCacheStore()
Method Detail

init

public void init(CacheLoaderConfig clc,
                 Cache<?,?> cache,
                 StreamingMarshaller m)
          throws CacheLoaderException
Description copied from interface: CacheLoader
Used to initialize a cache loader. Typically invoked by the CacheLoaderManager when setting up cache loaders.

Specified by:
init in interface CacheLoader
Overrides:
init in class AbstractCacheStore
Parameters:
clc - the cache loader configuration bean
cache - cache associated with this cache loader. Implementations may use this to determine cache name when selecting where refer to state in storage, for example, a different database table name.
m - marshaller to use when loading state from a stream, if supported by the implementation.
Throws:
CacheLoaderException

start

public void start()
           throws CacheLoaderException
Specified by:
start in interface CacheLoader
Overrides:
start in class AbstractCacheStore
Throws:
CacheLoaderException

store

public void store(InternalCacheEntry entry)
           throws CacheLoaderException
Stores an entry into the cache. If this entry can expire, it also adds a row to the expiration table so we can purge it later on after it has expired.

Parameters:
entry - the object to store in the cache
Throws:
CacheLoaderException - in the event of problems writing to the store

fromStream

public void fromStream(ObjectInput in)
                throws CacheLoaderException
Stores an object that has been unmarshalled to a stream into the cache.

Parameters:
in - the object input stream
Throws:
CacheLoaderException - in the event of problems writing to the store

toStream

public void toStream(ObjectOutput out)
              throws CacheLoaderException
Loads all entries from the cache and marshalls them to an object stream.

Parameters:
out - the output stream to marshall the entries to
Throws:
CacheLoaderException - in the event of problems reading from the store

clear

public void clear()
           throws CacheLoaderException
Removes all entries from the cache. This include removing items from the expiration table.

Throws:
CacheLoaderException - in the event of problems writing to the store

remove

public boolean remove(Object key)
               throws CacheLoaderException
Removes an entry from the cache, given its key.

Parameters:
key - the key for the entry to remove.
Returns:
true if the entry was removed; false if the entry wasn't found.
Throws:
CacheLoaderException - in the event of problems writing to the store

load

public InternalCacheEntry load(Object key)
                        throws CacheLoaderException
Loads an entry from the cache, given its key.

Parameters:
key - the key for the entry to load.
Returns:
an entry
Throws:
CacheLoaderException - in the event of problems reading from source

loadAll

public Set<InternalCacheEntry> loadAll()
                                throws CacheLoaderException
Loads all entries from the cache.

Returns:
a set of entries, or an empty set if the loader is emptied.
Throws:
CacheLoaderException - in the event of problems reading from source

load

public Set<InternalCacheEntry> load(int numEntries)
                             throws CacheLoaderException
Loads entries from the cache up to a certain number.

Parameters:
numEntries - the max number of entries to load.
Returns:
a set of entries, which would contain between 0 and numEntries entries.
Throws:
CacheLoaderException

loadAllKeys

public Set<Object> loadAllKeys(Set<Object> keysToExclude)
                        throws CacheLoaderException
Loads all keys from the cache, optionally excluding some.

Parameters:
keysToExclude - a set of keys that should not be returned.
Returns:
A set containing keys of entries stored. An empty set is returned if the loader is empty.
Throws:
CacheLoaderException

getConfigurationClass

public Class<? extends CacheLoaderConfig> getConfigurationClass()
Returns the class that represents this cache store's configuration.

Returns:
the type of the CacheLoaderConfig bean used to configure this implementation of CacheLoader.

purgeInternal

protected void purgeInternal()
                      throws CacheLoaderException
Purges any expired entries from the cache.

Specified by:
purgeInternal in class AbstractCacheStore
Throws:
CacheLoaderException

toString

public String toString()
Overrides:
toString in class Object

-->

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.