001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/index/IndexStorage.java $
003: * $Id: IndexStorage.java 29635 2007-04-26 14:44:09Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.search.index;
021:
022: import java.io.IOException;
023: import java.util.List;
024:
025: import org.apache.lucene.analysis.Analyzer;
026: import org.apache.lucene.index.IndexReader;
027: import org.apache.lucene.index.IndexWriter;
028: import org.apache.lucene.search.IndexSearcher;
029: import org.sakaiproject.search.api.Diagnosable;
030:
031: /**
032: * Defines the IndexStorage mechanism used
033: * @author ieb
034: *
035: */
036: public interface IndexStorage extends Diagnosable {
037:
038: /**
039: * get an Index Reader for the IndexStorage type
040: * @return
041: * @throws IOException
042: */
043: IndexReader getIndexReader() throws IOException;
044:
045: /**
046: * get an index writer, and create if asked to
047: * @param create
048: * @return
049: * @throws IOException
050: */
051: IndexWriter getIndexWriter(boolean create) throws IOException;
052:
053: /**
054: * get an index searcher
055: * @return
056: * @throws IOException
057: */
058: IndexSearcher getIndexSearcher() throws IOException;
059:
060: /**
061: * perform all operations necessary after an update cycle
062: * @throws IOException
063: */
064: void doPostIndexUpdate() throws IOException;
065:
066: /**
067: * perform all operations before an update cycle
068: * @throws IOException
069: */
070: void doPreIndexUpdate() throws IOException;
071:
072: /**
073: * Does the index exist
074: * @return
075: */
076: boolean indexExists();
077:
078: /**
079: * Get an analyzer correct for the indexer being used.
080: * @return
081: */
082: Analyzer getAnalyzer();
083:
084: /**
085: * if set to true the IndexStorageWill automatically attempt to recover a corrupted index
086: * Not all IndexStorage implementations can do this,
087: *
088: */
089: void setRecoverCorruptedIndex(boolean recover);
090:
091: /**
092: * The location of the storage
093: * @param location
094: */
095: void setLocation(String location);
096:
097: long getLastUpdate();
098:
099: List getSegmentInfoList();
100:
101: /**
102: * This will close the index reader and release any locks
103: * @param indexReader
104: * @throws IOException
105: */
106: void closeIndexReader(IndexReader indexReader) throws IOException;
107:
108: /**
109: * this will close the index reader and release any locks
110: * @param indexWrite
111: * @throws IOException
112: */
113: void closeIndexWriter(IndexWriter indexWrite) throws IOException;
114:
115: /**
116: * Returns true if its ok to allow multiple indexers to run at the same time
117: * The index storage may manage its own locks.
118: * @return
119: */
120: boolean isMultipleIndexers();
121:
122: void closeIndexSearcher(IndexSearcher oldRunningIndexSearcher);
123:
124: /**
125: * A fast method that checks if the index exists in the cluster
126: * without opening or loading the index. Is local, looking on local
127: * disk is enough.
128: * @return
129: */
130: boolean centralIndexExists();
131:
132: }
|