001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/index/ClusterFilesystem.java $
003: * $Id: ClusterFilesystem.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.File;
023: import java.io.IOException;
024: import java.util.List;
025:
026: /**
027: * ClusterFilesystem provides the mechanism by which the local search index is
028: * syncronsed with the clustered file system
029: *
030: * @author ieb
031: */
032: public interface ClusterFilesystem {
033:
034: /**
035: * Update all the segments in the cluster file system, retruning a list of
036: * segment names with the current segment as the last in the list.
037: *
038: * @return
039: */
040: List<SegmentInfo> updateSegments();
041:
042: /**
043: * get the total size of a segment
044: *
045: * @param currentSegment
046: * @return
047: */
048: // long getTotalSize(File currentSegment);
049: /**
050: * saves the segments returning a list of segments that were sent to the
051: * central store
052: *
053: * @return
054: */
055: List<SegmentInfo> saveSegments();
056:
057: /**
058: * Forces all segments from this system into the DB, does not delete any
059: * inthe db.
060: *
061: * @return
062: */
063: List<SegmentInfo> saveAllSegments();
064:
065: /**
066: * create a new segment
067: *
068: * @return
069: * @throws IOException
070: */
071: SegmentInfo newSegment() throws IOException;
072:
073: /**
074: * set the location information for the cluster file store
075: *
076: * @param location
077: */
078:
079: void setLocation(String location);
080:
081: /**
082: * Update the timestamp on the segment
083: *
084: * @param currentSegment
085: * @throws IOException
086: */
087: // void touchSegment(File currentSegment) throws IOException;
088: /**
089: * get a clean temporary index space for building a detached segment
090: *
091: * @param delete
092: * if true the temp index will be deleted first, there is only 1 temp
093: * index per location
094: * @return
095: */
096: File getTemporarySegment(boolean delete);
097:
098: /**
099: * removes the temporary segment
100: */
101: void removeTemporarySegment();
102:
103: /**
104: * Recover a dammaged segment from the DB
105: *
106: * @param segment
107: */
108: void recoverSegment(SegmentInfo segment);
109:
110: /**
111: * gets the segment name from a path
112: *
113: * @param segment
114: * @return
115: */
116: // String getSegmentName(String segment);
117: /**
118: * Checks that a segment is valid
119: *
120: * @param segmentName
121: * @throws Exception
122: */
123: // boolean checkSegmentValidity(String segmentName) throws Exception;
124: /**
125: * Remove a segment from the index.
126: *
127: * @param mergeSegment
128: */
129: void removeLocalSegment(SegmentInfo mergeSegment);
130:
131: long getLastUpdate();
132:
133: List getSegmentInfoList();
134:
135: /**
136: * if the thread already has a lock ignore get a lock on the index so that
137: * it can be updated this should block untill a lock becomes free
138: */
139: void getLock();
140:
141: /**
142: * release the lock, only if there is one this should block untill a lock
143: * becomes free
144: */
145: void releaseLock();
146:
147: /**
148: * can the Cluster Filesystem cope with multiple indexers running at the
149: * same time
150: *
151: * @return
152: */
153: boolean isMultipleIndexers();
154:
155: /**
156: * Save the temporary segment into a permanent segment
157: * @return
158: * @throws IOException
159: */
160: SegmentInfo saveTemporarySegment() throws IOException;
161:
162: /**
163: * A low cost reliable mechanism for determining if an index exists in the cluster
164: * @return
165: */
166: boolean centralIndexExists();
167:
168: }
|