Infinispan Distribution 5.2.6.Final-redhat-2

org.infinispan.lucene.cachestore
Class LuceneCacheLoader

java.lang.Object
  extended by org.infinispan.lucene.cachestore.LuceneCacheLoader
All Implemented Interfaces:
CacheLoader

public class LuceneCacheLoader
extends Object
implements CacheLoader

A CacheLoader meant to load Lucene index(es) from filesystem based Lucene index(es). This is exclusively suitable for keys being used by the InfinispanDirectory, any other key will be ignored. The InfinispanDirectory requires indexes to be named; this CacheLoader needs to be configured with the path of the root directory containing the indexes, and expects index names to match directory names under this common root path.

Since:
5.2
Author:
Sanne Grinovero

Constructor Summary
LuceneCacheLoader()
           
 
Method Summary
 boolean containsKey(Object key)
           
 Class<? extends CacheLoaderConfig> getConfigurationClass()
          This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding CacheLoaderConfig type.
 void init(CacheLoaderConfig config, Cache<?,?> cache, StreamingMarshaller m)
          Used to initialize a cache loader.
 Set<InternalCacheEntry> load(int maxEntries)
          Loads up to a specific number of entries.
 InternalCacheEntry load(Object key)
          Loads an entry mapped to by a given key.
 Set<InternalCacheEntry> loadAll()
          Loads all entries in the loader.
 Set<Object> loadAllKeys(Set keysToExclude)
          Loads a set of all keys, excluding a filter set.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneCacheLoader

public LuceneCacheLoader()
Method Detail

init

public void init(CacheLoaderConfig config,
                 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
Parameters:
config - 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

load

public InternalCacheEntry load(Object key)
                        throws CacheLoaderException
Description copied from interface: CacheLoader
Loads an entry mapped to by a given key. Should return null if the entry does not exist. Expired entries are not returned.

Specified by:
load in interface CacheLoader
Parameters:
key - key
Returns:
an entry
Throws:
CacheLoaderException - in the event of problems reading from source

containsKey

public boolean containsKey(Object key)
                    throws CacheLoaderException
Specified by:
containsKey in interface CacheLoader
Parameters:
key - key to test
Returns:
true if the key exists, false otherwise
Throws:
CacheLoaderException - in the event of problems reading from source

loadAll

public Set<InternalCacheEntry> loadAll()
                                throws CacheLoaderException
Description copied from interface: CacheLoader
Loads all entries in the loader. Expired entries are not returned.

Specified by:
loadAll in interface CacheLoader
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 maxEntries)
                             throws CacheLoaderException
Loads up to a specific number of entries. There is no guarantee about the order of loaded entries.

Specified by:
load in interface CacheLoader
Parameters:
maxEntries - maximum 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 keysToExclude)
                        throws CacheLoaderException
Description copied from interface: CacheLoader
Loads a set of all keys, excluding a filter set.

Specified by:
loadAllKeys in interface CacheLoader
Parameters:
keysToExclude - a set of keys to exclude. An empty set or null will indicate that all keys should be returned.
Returns:
A set containing keys of entries stored. An empty set is returned if the loader is empty.
Throws:
CacheLoaderException

start

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

stop

public void stop()
          throws CacheLoaderException
Specified by:
stop in interface CacheLoader
Throws:
CacheLoaderException

getConfigurationClass

public Class<? extends CacheLoaderConfig> getConfigurationClass()
Description copied from interface: CacheLoader
This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding CacheLoaderConfig type. This is usually done by instantiating the CacheLoader and then calling this method. This may result in 2 instances being created, however, since the instance created to get a hold of the configuration type is then discarded and another instance is created for actual use as a CacheLoader when the cache starts.

Since Infinispan 4.1, you can also annotate your CacheLoader implementation with CacheLoaderMetadata and provide this information via the annotation, which will prevent unnecessary instances being created.

Specified by:
getConfigurationClass in interface CacheLoader
Returns:
the type of the CacheLoaderConfig bean used to configure this implementation of CacheLoader.

Infinispan Distribution 5.2.6.Final-redhat-2

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