001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/index/SegmentInfo.java $
003: * $Id: SegmentInfo.java 29315 2007-04-20 14:28:12Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006, 2007 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:
025: /**
026: * Represents Information about a search segment
027: * @author ieb
028: *
029: */
030: public interface SegmentInfo {
031:
032: /**
033: * Is the segment part of the cluster or just a stray directory.
034: * @return
035: */
036: boolean isClusterSegment();
037:
038: /**
039: * Get the name of the segment
040: * @return
041: */
042: String getName();
043:
044: /**
045: * get the current version of the segment
046: * @return
047: */
048: long getVersion();
049:
050: /**
051: * If the segment in a created state (ie not new and not deleted)
052: * @return
053: */
054: boolean isCreated();
055:
056: /**
057: * The File that is the segment location on the local filesystem (may not exist)
058: * @return
059: */
060: File getSegmentLocation();
061:
062: /**
063: * Mark the segment as deleted for later deletion
064: */
065: void setDeleted();
066:
067: /**
068: * Is the segment in the DB
069: * @return
070: */
071: boolean isInDb();
072:
073: /**
074: * Set the version of the segment
075: * @param newVersion
076: */
077: void setVersion(long newVersion);
078:
079: /**
080: * Reset the internal checkum of the segment
081: * @throws IOException
082: *
083: */
084: // void setCheckSum() throws IOException;
085: /**
086: * Was the segment deleted
087: * @return
088: */
089: boolean isDeleted();
090:
091: /**
092: * Set the timestamp on th segment
093: * @param l
094: * @throws IOException
095: */
096: void setTimeStamp(long l) throws IOException;
097:
098: /**
099: * Mark the segment as brand new
100: */
101: void setNew();
102:
103: /**
104: * Get the time the segment was last modified
105: * @return
106: */
107: long getLocalSegmentLastModified();
108:
109: /**
110: * Get the size of the segment on disk
111: * @return
112: */
113: long getLocalSegmentSize();
114:
115: /**
116: * Mark the segment as created
117: */
118: void setCreated();
119:
120: /**
121: * Check the validity of the segment
122: * @throws Exception
123: */
124: boolean checkSegmentValidity(boolean logging, String message)
125: throws Exception;
126:
127: /**
128: * Check the validity of segment
129: * @param force
130: * @param validate
131: * @return
132: * @throws Exception
133: */
134: //boolean checkSegmentValidity(boolean force, boolean validate) throws Exception;
135: /**
136: * Get the size of the segment
137: * @return
138: */
139: long getTotalSize();
140:
141: /**
142: * make the segment as updated
143: * @throws IOException
144: *
145: */
146: void touchSegment() throws IOException;
147:
148: /**
149: * calculate the total size (this is expensive)
150: */
151: void loadSize();
152:
153: /**
154: * get the size of the segment.
155: * @return
156: */
157: long getSize();
158:
159: /**
160: * Perform a final delete removing all files from the local disk
161: */
162: void doFinalDelete();
163:
164: }
|