org.sakaiproject.search.index.impl
Class JDBCClusterIndexStore

java.lang.Object
  extended by org.sakaiproject.search.index.impl.JDBCClusterIndexStore
All Implemented Interfaces:
ClusterFilesystem

public class JDBCClusterIndexStore
extends Object
implements ClusterFilesystem

This is a JDBC implementation of the ClusterFilesystem. It syncronizes the local search index segments with the database, by sipping each segment and pushing it to the database. Each Segment has an extra file that contains an MD5 of the segment and a time stamp of the last update. If any segments are missing in the local segment store (including no segments at all, as with a new cluster node) the missing segments are downloaded from the JDBC store. If any of the segments on the local store are found to be dammaged they are reloaded from the database.

Author:
ieb

Constructor Summary
JDBCClusterIndexStore()
           
 
Method Summary
 boolean centralIndexExists()
          A low cost reliable mechanism for determining if an index exists in the cluster
 void dolog(String message)
           
 DataSource getDataSource()
           
 long getLastUpdate()
           
 List<SegmentInfo> getLocalSegments()
          get a list of local segments
 List<SegmentInfo> getLocalSegments(File searchDir, List<SegmentInfo> l)
          recurse into a list of segments
 void getLock()
          if the thread already has a lock ignore get a lock on the index so that it can be updated this should block untill a lock becomes free
 SearchService getSearchService()
           
 List<Object[]> getSegmentInfoList()
           
 long getSegmentInfoList(File searchDir, List<Object[]> seginfo)
           
 String getSegmentName(String segmentPath)
           
 String getSharedSegments()
           
 File getTemporarySegment(boolean delete)
          create a temporary index for indexing operations
 void init()
           
 boolean isLocalSegmentsOnly()
           
 boolean isLocalStructuredStorage()
           
 boolean isMultipleIndexers()
          can the Cluster Filesystem cope with multiple indexers running at the same time
 boolean isParallelIndex()
           
 boolean isSharedStructuredStorage()
           
 boolean isValidate()
           
 SegmentInfo newSegment()
          create a new local segment and mark its tiestamp
 void recoverSegment(SegmentInfo recoverSegInfo)
          Recover a dammaged segment from the DB
 void releaseLock()
          release the lock, only if there is one this should block untill a lock becomes free
 void removeLocalSegment(SegmentInfo rmsi)
          remove a local segment
 void removeTemporarySegment()
          removes the temporary segment
 List<SegmentInfo> saveAllSegments()
          Forces all segments from this system into the DB, does not delete any inthe db.
 List<SegmentInfo> saveSegments()
          save the local segments to the DB
 SegmentInfo saveTemporarySegment()
          Save the temporary segment into a permanent segment
 void setAutoDdl(boolean autoDdl)
           
 void setDataSource(DataSource dataSource)
           
 void setLocalSegmentsOnly(boolean localSegmentsOnly)
           
 void setLocalStructuredStorage(boolean localStructuredStorage)
           
 void setLocation(String location)
          set the location information for the cluster file store
 void setParallelIndex(boolean parallelIndex)
           
 void setSearchService(SearchService searchService)
           
 void setSharedSegments(String sharedSegments)
           
 void setSharedStructuredStorage(boolean sharedStructuredStorage)
           
 void setValidate(boolean validate)
           
protected  void updateDBPatch(Connection connection)
           
protected  void updateDBPatchBLOB(Connection connection)
          updat this save this local segment into the db
protected  void updateDBPatchFilesystem(Connection connection)
          updat this save this local segment into the db
protected  void updateDBSegment(Connection connection, SegmentInfo addsi)
           
protected  void updateDBSegmentBLOB(Connection connection, SegmentInfo addsi)
          updat this save this local segment into the db
protected  void updateDBSegmentFilesystem(Connection connection, SegmentInfo addsi)
          updat this save this local segment into the db
protected  void updateLocalPatch(Connection connection)
           
protected  void updateLocalPatchFilesystem(Connection connection)
           
protected  void updateLocalSegment(Connection connection, SegmentInfo addsi)
           
protected  void updateLocalSegmentBLOB(Connection connection, SegmentInfo addsi)
          updte a segment from the database
protected  void updateLocalSegmentFilesystem(Connection connection, SegmentInfo addsi)
          updte a segment from the database
 List<SegmentInfo> updateSegments()
          Ther might need to be some locking here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCClusterIndexStore

public JDBCClusterIndexStore()
Method Detail

init

public void init()

updateSegments

public List<SegmentInfo> updateSegments()
Ther might need to be some locking here. When readers use this, they will update the local segments with more information, update the local Segmetns from the DB

Specified by:
updateSegments in interface ClusterFilesystem
Parameters:
locked - A locak has been taken on the index
Returns:

saveSegments

public List<SegmentInfo> saveSegments()
save the local segments to the DB

Specified by:
saveSegments in interface ClusterFilesystem
Returns:

saveAllSegments

public List<SegmentInfo> saveAllSegments()
Description copied from interface: ClusterFilesystem
Forces all segments from this system into the DB, does not delete any inthe db.

Specified by:
saveAllSegments in interface ClusterFilesystem
Returns:

updateLocalSegment

protected void updateLocalSegment(Connection connection,
                                  SegmentInfo addsi)
                           throws SQLException,
                                  IOException
Throws:
SQLException
IOException

updateLocalSegmentBLOB

protected void updateLocalSegmentBLOB(Connection connection,
                                      SegmentInfo addsi)
                               throws SQLException,
                                      IOException
updte a segment from the database

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

removeLocalSegment

public void removeLocalSegment(SegmentInfo rmsi)
remove a local segment

Specified by:
removeLocalSegment in interface ClusterFilesystem
Parameters:
rmsi -

updateDBPatch

protected void updateDBPatch(Connection connection)
                      throws SQLException,
                             IOException
Throws:
SQLException
IOException

updateDBPatchBLOB

protected void updateDBPatchBLOB(Connection connection)
                          throws SQLException,
                                 IOException
updat this save this local segment into the db

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

updateDBPatchFilesystem

protected void updateDBPatchFilesystem(Connection connection)
                                throws SQLException,
                                       IOException
updat this save this local segment into the db

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

updateDBSegment

protected void updateDBSegment(Connection connection,
                               SegmentInfo addsi)
                        throws SQLException,
                               IOException
Throws:
SQLException
IOException

updateDBSegmentBLOB

protected void updateDBSegmentBLOB(Connection connection,
                                   SegmentInfo addsi)
                            throws SQLException,
                                   IOException
updat this save this local segment into the db

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

newSegment

public SegmentInfo newSegment()
                       throws IOException
create a new local segment and mark its tiestamp

Specified by:
newSegment in interface ClusterFilesystem
Returns:
Throws:
IOException

getLocalSegments

public List<SegmentInfo> getLocalSegments()
                                   throws IOException
get a list of local segments

Returns:
Throws:
IOException

getLocalSegments

public List<SegmentInfo> getLocalSegments(File searchDir,
                                          List<SegmentInfo> l)
                                   throws IOException
recurse into a list of segments

Parameters:
searchDir -
l -
Returns:
Throws:
IOException

getDataSource

public DataSource getDataSource()
Returns:
Returns the dataSource.

setDataSource

public void setDataSource(DataSource dataSource)
Parameters:
dataSource - The dataSource to set.

setLocation

public void setLocation(String location)
Description copied from interface: ClusterFilesystem
set the location information for the cluster file store

Specified by:
setLocation in interface ClusterFilesystem

setAutoDdl

public void setAutoDdl(boolean autoDdl)
Parameters:
autoDdl - The autoDdl to set.

getTemporarySegment

public File getTemporarySegment(boolean delete)
create a temporary index for indexing operations

Specified by:
getTemporarySegment in interface ClusterFilesystem
Parameters:
delete - if true the temp index will be deleted first, there is only 1 temp index per location
Returns:

removeTemporarySegment

public void removeTemporarySegment()
Description copied from interface: ClusterFilesystem
removes the temporary segment

Specified by:
removeTemporarySegment in interface ClusterFilesystem

saveTemporarySegment

public SegmentInfo saveTemporarySegment()
                                 throws IOException
Description copied from interface: ClusterFilesystem
Save the temporary segment into a permanent segment

Specified by:
saveTemporarySegment in interface ClusterFilesystem
Returns:
Throws:
IOException

recoverSegment

public void recoverSegment(SegmentInfo recoverSegInfo)
Description copied from interface: ClusterFilesystem
Recover a dammaged segment from the DB

Specified by:
recoverSegment in interface ClusterFilesystem

updateLocalPatch

protected void updateLocalPatch(Connection connection)
                         throws SQLException,
                                IOException
Throws:
SQLException
IOException

updateLocalPatchFilesystem

protected void updateLocalPatchFilesystem(Connection connection)
                                   throws SQLException,
                                          IOException
Throws:
SQLException
IOException

getSegmentName

public String getSegmentName(String segmentPath)

isValidate

public boolean isValidate()
Returns:
Returns the validate.

setValidate

public void setValidate(boolean validate)
Parameters:
validate - The validate to set.

updateDBSegmentFilesystem

protected void updateDBSegmentFilesystem(Connection connection,
                                         SegmentInfo addsi)
                                  throws SQLException,
                                         IOException
updat this save this local segment into the db

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

updateLocalSegmentFilesystem

protected void updateLocalSegmentFilesystem(Connection connection,
                                            SegmentInfo addsi)
                                     throws SQLException,
                                            IOException
updte a segment from the database

Parameters:
connection -
addsi -
Throws:
SQLException
IOException

getSharedSegments

public String getSharedSegments()

setSharedSegments

public void setSharedSegments(String sharedSegments)

dolog

public void dolog(String message)

getLastUpdate

public long getLastUpdate()
Specified by:
getLastUpdate in interface ClusterFilesystem

getSegmentInfoList

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

getSegmentInfoList

public long getSegmentInfoList(File searchDir,
                               List<Object[]> seginfo)

getLock

public void getLock()
             throws IOException
Description copied from interface: ClusterFilesystem
if the thread already has a lock ignore get a lock on the index so that it can be updated this should block untill a lock becomes free

Specified by:
getLock in interface ClusterFilesystem
Throws:
IOException

releaseLock

public void releaseLock()
Description copied from interface: ClusterFilesystem
release the lock, only if there is one this should block untill a lock becomes free

Specified by:
releaseLock in interface ClusterFilesystem

isMultipleIndexers

public boolean isMultipleIndexers()
Description copied from interface: ClusterFilesystem
can the Cluster Filesystem cope with multiple indexers running at the same time

Specified by:
isMultipleIndexers in interface ClusterFilesystem
Returns:

isParallelIndex

public boolean isParallelIndex()

setParallelIndex

public void setParallelIndex(boolean parallelIndex)

isLocalStructuredStorage

public boolean isLocalStructuredStorage()
Returns:
Returns the localStructuredStorage.

setLocalStructuredStorage

public void setLocalStructuredStorage(boolean localStructuredStorage)
Parameters:
localStructuredStorage - The localStructuredStorage to set.

isSharedStructuredStorage

public boolean isSharedStructuredStorage()
Returns:
Returns the sharedStructuredStorage.

setSharedStructuredStorage

public void setSharedStructuredStorage(boolean sharedStructuredStorage)
Parameters:
sharedStructuredStorage - The sharedStructuredStorage to set.

isLocalSegmentsOnly

public boolean isLocalSegmentsOnly()
Returns:
the localSegmentsOnly

setLocalSegmentsOnly

public void setLocalSegmentsOnly(boolean localSegmentsOnly)
Parameters:
localSegmentsOnly - the localSegmentsOnly to set

getSearchService

public SearchService getSearchService()
Returns:
the searchService

setSearchService

public void setSearchService(SearchService searchService)
Parameters:
searchService - the searchService to set

centralIndexExists

public boolean centralIndexExists()
Description copied from interface: ClusterFilesystem
A low cost reliable mechanism for determining if an index exists in the cluster

Specified by:
centralIndexExists in interface ClusterFilesystem
Returns:


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