de.pangaea.metadataportal.config
Class IndexConfig

java.lang.Object
  extended by de.pangaea.metadataportal.config.IndexConfig
Direct Known Subclasses:
SingleIndexConfig, VirtualIndexConfig

public abstract class IndexConfig
extends Object

Abstract configuration of an panFMP index. It not only configures its properties like name/id, it also contains methods to get some index access objects (IndexReader, Searcher) and status information.

Author:
Uwe Schindler

Field Summary
protected  boolean checked
           
 String displayName
           
 String id
           
protected  AutoCloseIndexReader indexReader
           
protected  WeakReference<AutoCloseIndexReader> oldReaderRef
           
 Config parent
           
 
Constructor Summary
IndexConfig(Config parent)
          Default constructor
 
Method Summary
 void check()
          Checks, if configuration is ok.
protected  void finalize()
           
abstract  org.apache.lucene.index.IndexReader getSharedIndexReader()
          returns a shared, read-only IndexReader.
abstract  boolean isIndexAvailable()
          checks, if index is available (a segment file is available)
 boolean isSharedIndexCurrent()
          checks, if shared IndexReader is current and the underlying disk store was not changed
abstract  org.apache.lucene.index.IndexReader newIndexReader(boolean readOnly)
          returns a new IndexReader, optionally read-only.
 org.apache.lucene.search.Searcher newSearcher()
          returns a Searcher on the shared IndexReader, should be closed after using.
 void releaseOldSharedReader()
          called by LuceneCache to release the old reader, if not done automatically by GC.
abstract  void reopenSharedIndex()
          reopens the shared index reader.
protected  void replaceSharedIndexReader(AutoCloseIndexReader indexReader)
          this saves the old indexReader instance in a weak reference and replaces by new (reopened) one
 void setDisplayName(String v)
          Sets the user-readable name of this index configuration.
 void setId(String v)
          Sets the ID of this index configuration.
abstract  void warmSharedIndexReader()
          called by SearchService to warm the shared index reader during webapp initialization
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexReader

protected volatile AutoCloseIndexReader indexReader

oldReaderRef

protected volatile WeakReference<AutoCloseIndexReader> oldReaderRef

checked

protected boolean checked

displayName

public String displayName

id

public String id

parent

public final Config parent
Constructor Detail

IndexConfig

public IndexConfig(Config parent)
Default constructor

Method Detail

setId

public void setId(String v)
Sets the ID of this index configuration.


setDisplayName

public void setDisplayName(String v)
Sets the user-readable name of this index configuration.


check

public void check()
           throws Exception
Checks, if configuration is ok. After calling this, you are not able to change anything in this instance.

Throws:
Exception

newSearcher

public org.apache.lucene.search.Searcher newSearcher()
                                              throws IOException
returns a Searcher on the shared IndexReader, should be closed after using.

Throws:
IOException

isSharedIndexCurrent

public boolean isSharedIndexCurrent()
                             throws IOException
checks, if shared IndexReader is current and the underlying disk store was not changed

Throws:
IOException

getSharedIndexReader

public abstract org.apache.lucene.index.IndexReader getSharedIndexReader()
                                                                  throws IOException
returns a shared, read-only IndexReader. This reader may not be closed by IndexReader.close().

Throws:
IOException

newIndexReader

public abstract org.apache.lucene.index.IndexReader newIndexReader(boolean readOnly)
                                                            throws IOException
returns a new IndexReader, optionally read-only. This reader must be closed after using.

Throws:
IOException

isIndexAvailable

public abstract boolean isIndexAvailable()
                                  throws IOException
checks, if index is available (a segment file is available)

Throws:
IOException

reopenSharedIndex

public abstract void reopenSharedIndex()
                                throws IOException
reopens the shared index reader.

Throws:
IOException

warmSharedIndexReader

public abstract void warmSharedIndexReader()
                                    throws IOException
called by SearchService to warm the shared index reader during webapp initialization

Throws:
IOException

releaseOldSharedReader

public void releaseOldSharedReader()
                            throws IOException
called by LuceneCache to release the old reader, if not done automatically by GC.

Throws:
IOException

replaceSharedIndexReader

protected void replaceSharedIndexReader(AutoCloseIndexReader indexReader)
                                 throws IOException
this saves the old indexReader instance in a weak reference and replaces by new (reopened) one

Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright ©2007-2009 panFMP Developers c/o Uwe Schindler