org.sakaiproject.search.journal.impl
Class JournaledFSIndexStorage

java.lang.Object
  extended by org.sakaiproject.search.journal.impl.JournaledFSIndexStorage
All Implemented Interfaces:
IndexStorageProvider, JournaledIndex, JournaledObject

public class JournaledFSIndexStorage
extends Object
implements JournaledIndex, IndexStorageProvider

                 This is a Journaled savePoint of the local FSIndexStorage. It will merge in new
                 savePoints from the journal. This is going to be performed in a non
                 transactional way for the moment. 
                 
                 The index reader must maintain a single
                 index reader for the JVM. When performing a read update, the single index
                 reader must be used, but each time the index reader is provided we should
                 check that the index reader has not been updated.
                 
                 If the reader is being updated, then it is not safe to reload it.
 

Author:
ieb

Field Summary
 
Fields inherited from interface org.sakaiproject.search.journal.api.JournaledIndex
DELETE_ON_CLOSE_FILE
 
Constructor Summary
JournaledFSIndexStorage()
           
 
Method Summary
 void addIndexListener(IndexListener indexListener)
           
 void addSegment(File f)
          Add a transient segment to the journal index
 boolean aquireReadLock()
          Aquires a lock to read the object
 boolean aquireUpdateLock()
          get a lock on on the object for update
 boolean centralIndexExists()
           
 void closeIndexReader(org.apache.lucene.index.IndexReader indexReader)
           
 void closeIndexSearcher(org.apache.lucene.search.IndexSearcher indexSearcher)
           
 void closeIndexWriter(org.apache.lucene.index.IndexWriter indexWrite)
           
 void debugLock()
           
 void destroy()
           
 void doPostIndexUpdate()
           
 void doPreIndexUpdate()
           
protected  void fireIndexReaderClose(org.apache.lucene.index.IndexReader oldMultiReader)
           
protected  void fireIndexReaderOpen(org.apache.lucene.index.IndexReader newMultiReader)
           
 org.apache.lucene.analysis.Analyzer getAnalyzer()
           
 AnalyzerFactory getAnalyzerFactory()
           
 org.sakaiproject.cluster.api.ClusterService getClusterService()
           
 DataSource getDatasource()
           
 org.apache.lucene.index.IndexReader getDeletionIndexReader()
          get an index reader suitable for processing deletes The underlying reader will be bound to the thread, and must be closed, but if closed and annother thread is using it, it will not be closed immediately.
 org.apache.lucene.index.IndexReader getIndexReader()
           
 org.apache.lucene.search.IndexSearcher getIndexSearcher()
           
 org.apache.lucene.index.IndexWriter getIndexWriter(boolean create)
           
 JournalManager getJournalManager()
           
 long getJournalSavePoint()
          Since this is a singleton, we can cache the savePoint only updating on change.
 JournalSettings getJournalSettings()
           
 long getLastJournalEntry()
          get the last journal entry we tried to migrate to
 long getLastLoad()
           
 long getLastLoadTime()
           
 long getLastUpdate()
           
 org.apache.lucene.index.IndexWriter getPermanentIndexWriter()
          Get an index writer to the permanent index, a write lock should have been taken before doing this
 List<Object[]> getSegmentInfoList()
           
 File[] getSegments()
          get a copy of the segments currently active
 org.sakaiproject.component.api.ServerConfigurationService getServerConfigurationService()
           
 org.apache.lucene.store.Directory getSpellDirectory()
          Get the SpellIndexDirectory
 org.sakaiproject.thread_local.api.ThreadLocalManager getThreadLocalManager()
           
 String getWorkingSpace()
          The workign space associated with the index
 boolean indexExists()
           
 void init()
           
 boolean isMultipleIndexers()
           
 void loadIndexReader()
          load the shared index reader, but dont return it or bind it to the current thread
 void loadSegmentList()
           
 void markModified()
           
 void releaseReadLock()
          releases a lock to read object
 void releaseUpdateLock()
          release the update lock
 void saveSegmentList()
           
 void setAnalyzerFactory(AnalyzerFactory analzyserFactory)
           
 void setClusterService(org.sakaiproject.cluster.api.ClusterService clusterService)
           
 void setDatasource(DataSource datasource)
           
 void setIndexListener(List<IndexListener> indexListeners)
           
 void setJournalIndexEntry(long journalEntry)
          Set the current index entry for the journal
 void setJournalManager(JournalManager journalManager)
           
 void setJournalSettings(JournalSettings journalSettings)
           
 void setLastJournalEntry(long lastJournalEntry)
          Set the last journal entry we tried to migrate to
 void setRecoverCorruptedIndex(boolean recover)
           
 void setSegments(List<File> keep)
          Set the list of segments
 void setServerConfigurationService(org.sakaiproject.component.api.ServerConfigurationService serverConfigurationService)
           
 void setThreadLocalManager(org.sakaiproject.thread_local.api.ThreadLocalManager threadLocalManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JournaledFSIndexStorage

public JournaledFSIndexStorage()
Method Detail

destroy

public void destroy()

init

public void init()
See Also:
FSIndexStorage.init()

getJournalSavePoint

public long getJournalSavePoint()
Since this is a singleton, we can cache the savePoint only updating on change. The Save Point is the number of the journal entry that this node has merged upto and including

Specified by:
getJournalSavePoint in interface JournaledObject
Returns:
See Also:
org.sakaiproject.search.maintanence.impl.JournaledObject#getJounalSavePoint()

aquireUpdateLock

public boolean aquireUpdateLock()
Description copied from interface: JournaledObject
get a lock on on the object for update

Specified by:
aquireUpdateLock in interface JournaledObject
Returns:
true is lock was granted, false if not
See Also:
JournaledObject.aquireUpdateLock()

releaseUpdateLock

public void releaseUpdateLock()
Description copied from interface: JournaledObject
release the update lock

Specified by:
releaseUpdateLock in interface JournaledObject
See Also:
JournaledObject.releaseUpdateLock()

aquireReadLock

public boolean aquireReadLock()
Description copied from interface: JournaledObject
Aquires a lock to read the object

Specified by:
aquireReadLock in interface JournaledObject
Returns:
true if lock was granted, false if not
See Also:
org.sakaiproject.search.journal.api.JournaledObject#auquireReadLock()

releaseReadLock

public void releaseReadLock()
Description copied from interface: JournaledObject
releases a lock to read object

Specified by:
releaseReadLock in interface JournaledObject
See Also:
JournaledObject.releaseReadLock()

setLastJournalEntry

public void setLastJournalEntry(long lastJournalEntry)
Description copied from interface: JournaledObject
Set the last journal entry we tried to migrate to

Specified by:
setLastJournalEntry in interface JournaledObject
Parameters:
nextJournalEntry -

getLastJournalEntry

public long getLastJournalEntry()
Description copied from interface: JournaledObject
get the last journal entry we tried to migrate to

Specified by:
getLastJournalEntry in interface JournaledObject
Returns:

addSegment

public void addSegment(File f)
Description copied from interface: JournaledIndex
Add a transient segment to the journal index

Specified by:
addSegment in interface JournaledIndex
See Also:
JournaledIndex.addSegment(java.io.File)

getWorkingSpace

public String getWorkingSpace()
Description copied from interface: JournaledIndex
The workign space associated with the index

Specified by:
getWorkingSpace in interface JournaledIndex
Returns:
See Also:
JournaledIndex.getWorkingSpace()

getIndexSearcher

public org.apache.lucene.search.IndexSearcher getIndexSearcher()
                                                        throws IOException
Specified by:
getIndexSearcher in interface IndexStorageProvider
Returns:
Throws:
IOException
See Also:
BaseIndexStorage.getIndexSearcher()

getDeletionIndexReader

public org.apache.lucene.index.IndexReader getDeletionIndexReader()
                                                           throws IOException
Description copied from interface: JournaledIndex
get an index reader suitable for processing deletes The underlying reader will be bound to the thread, and must be closed, but if closed and annother thread is using it, it will not be closed immediately. Although this is implementation specific the implementation should be thread safe.

Specified by:
getDeletionIndexReader in interface JournaledIndex
Returns:
Throws:
IOException

centralIndexExists

public boolean centralIndexExists()

closeIndexReader

public void closeIndexReader(org.apache.lucene.index.IndexReader indexReader)
                      throws IOException
Throws:
IOException

closeIndexSearcher

public void closeIndexSearcher(org.apache.lucene.search.IndexSearcher indexSearcher)

closeIndexWriter

public void closeIndexWriter(org.apache.lucene.index.IndexWriter indexWrite)
                      throws IOException
Throws:
IOException

doPostIndexUpdate

public void doPostIndexUpdate()
                       throws IOException
Throws:
IOException

doPreIndexUpdate

public void doPreIndexUpdate()
                      throws IOException
Throws:
IOException

getIndexReader

public org.apache.lucene.index.IndexReader getIndexReader()
                                                   throws IOException
Specified by:
getIndexReader in interface IndexStorageProvider
Returns:
Throws:
IOException

getIndexWriter

public org.apache.lucene.index.IndexWriter getIndexWriter(boolean create)
                                                   throws IOException
Throws:
IOException

getLastUpdate

public long getLastUpdate()
Specified by:
getLastUpdate in interface IndexStorageProvider
Returns:

getSegmentInfoList

public List<Object[]> getSegmentInfoList()
Specified by:
getSegmentInfoList in interface IndexStorageProvider
Returns:

indexExists

public boolean indexExists()

isMultipleIndexers

public boolean isMultipleIndexers()

setRecoverCorruptedIndex

public void setRecoverCorruptedIndex(boolean recover)
See Also:
IndexStorage.setRecoverCorruptedIndex(boolean)

getDatasource

public DataSource getDatasource()
Returns:
the datasource

setDatasource

public void setDatasource(DataSource datasource)
Parameters:
datasource - the datasource to set

getJournalManager

public JournalManager getJournalManager()
Returns:
the journalMonitor

setJournalManager

public void setJournalManager(JournalManager journalManager)
Parameters:
journalMonitor - the journalMonitor to set

getServerConfigurationService

public org.sakaiproject.component.api.ServerConfigurationService getServerConfigurationService()
Returns:
the serverConfigurationService

setServerConfigurationService

public void setServerConfigurationService(org.sakaiproject.component.api.ServerConfigurationService serverConfigurationService)
Parameters:
serverConfigurationService - the serverConfigurationService to set

setJournalIndexEntry

public void setJournalIndexEntry(long journalEntry)
Description copied from interface: JournaledObject
Set the current index entry for the journal

Specified by:
setJournalIndexEntry in interface JournaledObject

fireIndexReaderClose

protected void fireIndexReaderClose(org.apache.lucene.index.IndexReader oldMultiReader)
                             throws IOException
Parameters:
oldMultiReader -
Throws:
IOException

fireIndexReaderOpen

protected void fireIndexReaderOpen(org.apache.lucene.index.IndexReader newMultiReader)
Parameters:
newMultiReader -

addIndexListener

public void addIndexListener(IndexListener indexListener)
Specified by:
addIndexListener in interface IndexStorageProvider

setIndexListener

public void setIndexListener(List<IndexListener> indexListeners)

getPermanentIndexWriter

public org.apache.lucene.index.IndexWriter getPermanentIndexWriter()
                                                            throws IndexTransactionException
Get an index writer to the permanent index, a write lock should have been taken before doing this

Specified by:
getPermanentIndexWriter in interface JournaledIndex
Returns:
Throws:
IndexTransactionException
See Also:
JournaledIndex.getPermanentIndexWriter()

getSegments

public File[] getSegments()
Description copied from interface: JournaledIndex
get a copy of the segments currently active

Specified by:
getSegments in interface JournaledIndex
Returns:
See Also:
JournaledIndex.getSegments()

setSegments

public void setSegments(List<File> keep)
Description copied from interface: JournaledIndex
Set the list of segments

Specified by:
setSegments in interface JournaledIndex
See Also:
JournaledIndex.setSegments(java.util.List)

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer()
Specified by:
getAnalyzer in interface IndexStorageProvider
Returns:

getAnalyzerFactory

public AnalyzerFactory getAnalyzerFactory()
Returns:
Returns the analzyserFactory.

setAnalyzerFactory

public void setAnalyzerFactory(AnalyzerFactory analzyserFactory)
Parameters:
analzyserFactory - The analzyserFactory to set.

saveSegmentList

public void saveSegmentList()
                     throws IOException
Specified by:
saveSegmentList in interface JournaledIndex
Throws:
IOException

loadSegmentList

public void loadSegmentList()
                     throws IOException
Throws:
IOException

getClusterService

public org.sakaiproject.cluster.api.ClusterService getClusterService()
Returns:
the clusterService

setClusterService

public void setClusterService(org.sakaiproject.cluster.api.ClusterService clusterService)
Parameters:
clusterService - the clusterService to set

loadIndexReader

public void loadIndexReader()
                     throws IOException
Description copied from interface: JournaledIndex
load the shared index reader, but dont return it or bind it to the current thread

Specified by:
loadIndexReader in interface JournaledIndex
Throws:
IOException

debugLock

public void debugLock()
Specified by:
debugLock in interface JournaledObject

getLastLoad

public long getLastLoad()
Specified by:
getLastLoad in interface IndexStorageProvider
Returns:

getLastLoadTime

public long getLastLoadTime()
Specified by:
getLastLoadTime in interface IndexStorageProvider
Returns:

getJournalSettings

public JournalSettings getJournalSettings()
Returns:
the journalSettings

setJournalSettings

public void setJournalSettings(JournalSettings journalSettings)
Parameters:
journalSettings - the journalSettings to set

markModified

public void markModified()
                  throws IOException
Throws:
IOException

getThreadLocalManager

public org.sakaiproject.thread_local.api.ThreadLocalManager getThreadLocalManager()
Returns:
the threadLocalManager

setThreadLocalManager

public void setThreadLocalManager(org.sakaiproject.thread_local.api.ThreadLocalManager threadLocalManager)
Parameters:
threadLocalManager - the threadLocalManager to set

getSpellDirectory

public org.apache.lucene.store.Directory getSpellDirectory()
Description copied from interface: IndexStorageProvider
Get the SpellIndexDirectory

Specified by:
getSpellDirectory in interface IndexStorageProvider
Returns:


Copyright © 2003-2012 Sakai Project. All Rights Reserved.