org.infinispan.lucene
Class InfinispanDirectory

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.infinispan.lucene.InfinispanDirectory
All Implemented Interfaces:
Closeable

public class InfinispanDirectory
extends org.apache.lucene.store.Directory

An implementation of Lucene's Directory which uses Infinispan to store Lucene indexes. As the RAMDirectory the data is stored in memory, but provides some additional flexibility:

Passivation, LRU or LIRS Bigger indexes can be configured to passivate cleverly selected chunks of data to a cache store. This can be a local filesystem, a network filesystem, a database or custom cloud stores like S3. See Infinispan's core documentation for a full list of available implementations, or CacheStore to implement more.

Non-volatile memory The contents of the index can be stored in it's entirety in such a store, so that on shutdown or crash of the system data is not lost. A copy of the index will be copied to the store in sync or async depending on configuration; In case you enable Infinispan's clustering even in case of async the segments are always duplicated synchronously to other nodes, so you can benefit from good reliability even while choosing the asynchronous mode to write the index to the slowest store implementations.

Real-time change propagation All changes done on a node are propagated at low latency to other nodes of the cluster; this was designed especially for interactive usage of Lucene, so that after an IndexWriter commits on one node new IndexReaders opened on any node of the cluster will be able to deliver updated search results.

Distributed heap Infinispan acts as a shared heap for the purpose of total memory consumption, so you can avoid hitting the slower disks even if the total size of the index can't fit in the memory of a single node: network is faster than disks, especially if the index is bigger than the memory available to cache it.

Distributed locking As default Lucene Directory implementations a global lock needs to protect the index from having more than an IndexWriter open; in case of a replicated or distributed index you need to enable a cluster-wide LockFactory. This implementation uses by default BaseLockFactory; in case you want to apply changes during a JTA transaction see also TransactionalLockFactory.

Combined store patterns It's possible to combine different stores and passivation policies, so that each nodes shares the index changes quickly to other nodes, offloads less frequently used data to a per-node local filesystem, and the cluster also coordinates to keeps a safe copy on a shared store.

Since:
4.0
Author:
Sanne Grinovero, Lukasz Moren
See Also:
Directory, LockFactory, BaseLockFactory, TransactionalLockFactory

Field Summary
static int DEFAULT_BUFFER_SIZE
          Used as default chunk size, can be overriden at construction time.
 
Fields inherited from class org.apache.lucene.store.Directory
lockFactory
 
Constructor Summary
InfinispanDirectory(Cache cache)
           
InfinispanDirectory(Cache metadataCache, Cache chunksCache, Cache distLocksCache, String indexName, int chunkSize)
          This constructor assumes that three different caches are being used with specialized configurations for each cache usage
InfinispanDirectory(Cache metadataCache, Cache chunksCache, String indexName, org.apache.lucene.store.LockFactory lf, int chunkSize, SegmentReadLocker readLocker)
           
InfinispanDirectory(Cache cache, String indexName)
           
InfinispanDirectory(Cache cache, String indexName, int chunkSize)
          Deprecated. 
InfinispanDirectory(Cache cache, String indexName, int chunkSize, SegmentReadLocker readLocker)
           
InfinispanDirectory(Cache cache, String indexName, org.apache.lucene.store.LockFactory lf)
          Deprecated. 
InfinispanDirectory(Cache cache, String indexName, org.apache.lucene.store.LockFactory lf, int chunkSize)
          Deprecated. 
InfinispanDirectory(Cache cache, String indexName, org.apache.lucene.store.LockFactory lf, int chunkSize, SegmentReadLocker readLocker)
          Deprecated. 
 
Method Summary
 void close()
          
 org.apache.lucene.store.IndexOutput createOutput(String name)
          
 void deleteFile(String name)
          
 boolean fileExists(String name)
          
 long fileLength(String name)
          
 long fileModified(String name)
          
 String getIndexName()
           
 String[] list()
          
 String[] listAll()
          new name for list() in Lucene 3.0
 org.apache.lucene.store.IndexInput openInput(String name)
          
 void renameFile(String from, String to)
          
 String toString()
           
 void touchFile(String fileName)
          
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, copy, ensureOpen, getLockFactory, getLockID, makeLock, openInput, setLockFactory, sync, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
Used as default chunk size, can be overriden at construction time. Each Lucene index segment is splitted into parts with default size defined here

See Also:
Constant Field Values
Constructor Detail

InfinispanDirectory

public InfinispanDirectory(Cache metadataCache,
                           Cache chunksCache,
                           String indexName,
                           org.apache.lucene.store.LockFactory lf,
                           int chunkSize,
                           SegmentReadLocker readLocker)
Parameters:
metadataCache - the cache to be used for all smaller metadata: prefer replication over distribution, avoid eviction
chunksCache - the cache to use for the space consuming segments: prefer distribution, enable eviction if needed
indexName - the unique index name, useful to store multiple indexes in the same caches
lf - the LockFactory to be used by IndexWriters. @see org.infinispan.lucene.locking
chunkSize - segments are fragmented in chunkSize bytes; larger values are more efficient for searching but less for distribution and network replication
readLocker - @see org.infinispan.lucene.readlocks for some implementations; you might be able to provide more efficient implementations by controlling the IndexReader's lifecycle.

InfinispanDirectory

@Deprecated
public InfinispanDirectory(Cache cache,
                                      String indexName,
                                      org.apache.lucene.store.LockFactory lf,
                                      int chunkSize,
                                      SegmentReadLocker readLocker)
Deprecated. 


InfinispanDirectory

@Deprecated
public InfinispanDirectory(Cache cache,
                                      String indexName,
                                      org.apache.lucene.store.LockFactory lf,
                                      int chunkSize)
Deprecated. 


InfinispanDirectory

public InfinispanDirectory(Cache cache,
                           String indexName,
                           int chunkSize,
                           SegmentReadLocker readLocker)

InfinispanDirectory

public InfinispanDirectory(Cache metadataCache,
                           Cache chunksCache,
                           Cache distLocksCache,
                           String indexName,
                           int chunkSize)
This constructor assumes that three different caches are being used with specialized configurations for each cache usage

Parameters:
metadataCache - contains the metadata of stored elements
chunksCache - cache containing the bulk of the index; this is the larger part of data
distLocksCache - cache to store locks; should be replicated and not using a persistent CacheStore
indexName - identifies the index; you can store different indexes in the same set of caches using different identifiers
chunkSize - the maximum size in bytes for each chunk of data: larger sizes offer better search performance but might be problematic to handle during network replication or storage

InfinispanDirectory

@Deprecated
public InfinispanDirectory(Cache cache,
                                      String indexName,
                                      org.apache.lucene.store.LockFactory lf)
Deprecated. 


InfinispanDirectory

@Deprecated
public InfinispanDirectory(Cache cache,
                                      String indexName,
                                      int chunkSize)
Deprecated. 


InfinispanDirectory

public InfinispanDirectory(Cache cache,
                           String indexName)
Parameters:
cache - the cache to use to store the index
indexName - identifies the index; you can store different indexes in the same set of caches using different identifiers

InfinispanDirectory

public InfinispanDirectory(Cache cache)
Method Detail

list

public String[] list()


fileExists

public boolean fileExists(String name)

Specified by:
fileExists in class org.apache.lucene.store.Directory

fileModified

public long fileModified(String name)

Specified by:
fileModified in class org.apache.lucene.store.Directory

touchFile

public void touchFile(String fileName)

Specified by:
touchFile in class org.apache.lucene.store.Directory

deleteFile

public void deleteFile(String name)

Specified by:
deleteFile in class org.apache.lucene.store.Directory

renameFile

public void renameFile(String from,
                       String to)


fileLength

public long fileLength(String name)

Specified by:
fileLength in class org.apache.lucene.store.Directory

createOutput

public org.apache.lucene.store.IndexOutput createOutput(String name)

Specified by:
createOutput in class org.apache.lucene.store.Directory

openInput

public org.apache.lucene.store.IndexInput openInput(String name)
                                             throws IOException

Specified by:
openInput in class org.apache.lucene.store.Directory
Throws:
IOException

close

public void close()

Specified by:
close in interface Closeable
Specified by:
close in class org.apache.lucene.store.Directory

toString

public String toString()
Overrides:
toString in class org.apache.lucene.store.Directory

listAll

public String[] listAll()
new name for list() in Lucene 3.0

Specified by:
listAll in class org.apache.lucene.store.Directory

getIndexName

public String getIndexName()
Returns:
The value of indexName, same constant as provided to the constructor.

-->

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