org.sakaiproject.search.index.impl
Class SegmentInfoImpl

java.lang.Object
  extended by org.sakaiproject.search.index.impl.SegmentInfoImpl
All Implemented Interfaces:
SegmentInfo

public class SegmentInfoImpl
extends Object
implements SegmentInfo

segment info contains information on the segment, name, version, in db

Author:
ieb

Field Summary
static String DELETED_FILE
           
static String NEW_FILE
           
static int STATE_CREATED
           
static int STATE_DELETED
           
static int STATE_NEW
           
static String TIMESTAMP_FILE
           
 
Method Summary
 boolean checkSegmentValidity(boolean logging, String message)
          get the checksum out of the segment by the segment name
 void compareTo(String message, SegmentInfo compare)
          Compares this segment to the supplied segment, based on the in memory state of the live segment state
 void debugSegment(String message)
           
static void deleteAll(File f)
          delete all files under this file and including this file
 void doFinalDelete()
          Perform a final delete removing all files from the local disk
 long getLocalSegmentLastModified()
          Get the time the segment was last modified
 long getLocalSegmentSize()
          Get the size of the segment on disk
 String getName()
          Get the name of the segment
 File getSegmentLocation()
          The File that is the segment location on the local filesystem (may not exist)
static File getSegmentLocation(String name, boolean structured, String searchIndexDirectory)
           
 long getSize()
          get the size of the segment.
 int getState()
           
 long getTotalSize()
          Get the size of the segment
 long getVersion()
          get the current version of the segment
 boolean isClusterSegment()
          Is the segment part of the cluster or just a stray directory.
 boolean isCreated()
          If the segment in a created state (ie not new and not deleted)
 boolean isDeleted()
          Was the segment deleted
 boolean isInDb()
          Is the segment in the DB
 boolean isLocalLock()
          Does this thread have a local lock on the segment
 boolean isNew()
           
 void loadSize()
          calculate the total size (this is expensive)
 void lockLocalSegment()
          Perform a lock on the segment for local operations
static SegmentInfo newLocalSegmentInfo(File file, boolean localStructuredStorage, String searchIndexDirectory)
           
static SegmentInfo newLocalSegmentInfo(SegmentInfo recoverSegInfo)
          Create a new copy of the segment refreshing from the local disk.
static SegmentInfo newSharedSegmentInfo(String name, long version, boolean localStructuredStorage, String searchIndexDirectory)
           
 void setCreated()
          Mark the segment as created
 void setDeleted()
          Mark the segment as deleted for later deletion
 void setInDb(boolean b)
           
 void setNew()
          Mark the segment as brand new
 void setState(int state)
           
 void setTimeStamp(long l)
          set the timestamp in the segment
 void setVersion(long l)
          Set the version of the segment
 String toString()
           
 void touchSegment()
          make the segment as updated
 void unlockLocalSegment()
          Unlock the segment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMESTAMP_FILE

public static final String TIMESTAMP_FILE
See Also:
Constant Field Values

NEW_FILE

public static final String NEW_FILE
See Also:
Constant Field Values

DELETED_FILE

public static final String DELETED_FILE
See Also:
Constant Field Values

STATE_NEW

public static final int STATE_NEW
See Also:
Constant Field Values

STATE_CREATED

public static final int STATE_CREATED
See Also:
Constant Field Values

STATE_DELETED

public static final int STATE_DELETED
See Also:
Constant Field Values
Method Detail

toString

public String toString()
Overrides:
toString in class Object

newSharedSegmentInfo

public static SegmentInfo newSharedSegmentInfo(String name,
                                               long version,
                                               boolean localStructuredStorage,
                                               String searchIndexDirectory)

newLocalSegmentInfo

public static SegmentInfo newLocalSegmentInfo(File file,
                                              boolean localStructuredStorage,
                                              String searchIndexDirectory)

newLocalSegmentInfo

public static SegmentInfo newLocalSegmentInfo(SegmentInfo recoverSegInfo)
Create a new copy of the segment refreshing from the local disk.

Parameters:
recoverSegInfo -
Returns:

setInDb

public void setInDb(boolean b)

getName

public String getName()
Description copied from interface: SegmentInfo
Get the name of the segment

Specified by:
getName in interface SegmentInfo
Returns:

isInDb

public boolean isInDb()
Description copied from interface: SegmentInfo
Is the segment in the DB

Specified by:
isInDb in interface SegmentInfo
Returns:

getVersion

public long getVersion()
Description copied from interface: SegmentInfo
get the current version of the segment

Specified by:
getVersion in interface SegmentInfo
Returns:

setVersion

public void setVersion(long l)
Description copied from interface: SegmentInfo
Set the version of the segment

Specified by:
setVersion in interface SegmentInfo

setState

public void setState(int state)

getState

public int getState()

getSegmentLocation

public File getSegmentLocation()
Description copied from interface: SegmentInfo
The File that is the segment location on the local filesystem (may not exist)

Specified by:
getSegmentLocation in interface SegmentInfo
Returns:

getSegmentLocation

public static File getSegmentLocation(String name,
                                      boolean structured,
                                      String searchIndexDirectory)

setNew

public void setNew()
Description copied from interface: SegmentInfo
Mark the segment as brand new

Specified by:
setNew in interface SegmentInfo

setCreated

public void setCreated()
Description copied from interface: SegmentInfo
Mark the segment as created

Specified by:
setCreated in interface SegmentInfo

setDeleted

public void setDeleted()
Description copied from interface: SegmentInfo
Mark the segment as deleted for later deletion

Specified by:
setDeleted in interface SegmentInfo

isNew

public boolean isNew()

isCreated

public boolean isCreated()
Description copied from interface: SegmentInfo
If the segment in a created state (ie not new and not deleted)

Specified by:
isCreated in interface SegmentInfo
Returns:

isDeleted

public boolean isDeleted()
Description copied from interface: SegmentInfo
Was the segment deleted

Specified by:
isDeleted in interface SegmentInfo
Returns:

setTimeStamp

public void setTimeStamp(long l)
                  throws IOException
set the timestamp in the segment

Specified by:
setTimeStamp in interface SegmentInfo
Parameters:
l -
Throws:
IOException

isClusterSegment

public boolean isClusterSegment()
Description copied from interface: SegmentInfo
Is the segment part of the cluster or just a stray directory.

Specified by:
isClusterSegment in interface SegmentInfo
Returns:

checkSegmentValidity

public boolean checkSegmentValidity(boolean logging,
                                    String message)
get the checksum out of the segment by the segment name

Specified by:
checkSegmentValidity in interface SegmentInfo
Parameters:
segmentName -
Returns:
Throws:
Exception
IOException

getLocalSegmentLastModified

public long getLocalSegmentLastModified()
Description copied from interface: SegmentInfo
Get the time the segment was last modified

Specified by:
getLocalSegmentLastModified in interface SegmentInfo
Returns:

getLocalSegmentSize

public long getLocalSegmentSize()
Description copied from interface: SegmentInfo
Get the size of the segment on disk

Specified by:
getLocalSegmentSize in interface SegmentInfo
Returns:

getTotalSize

public long getTotalSize()
Description copied from interface: SegmentInfo
Get the size of the segment

Specified by:
getTotalSize in interface SegmentInfo
Returns:

touchSegment

public void touchSegment()
                  throws IOException
Description copied from interface: SegmentInfo
make the segment as updated

Specified by:
touchSegment in interface SegmentInfo
Throws:
IOException

getSize

public long getSize()
Description copied from interface: SegmentInfo
get the size of the segment.

Specified by:
getSize in interface SegmentInfo
Returns:

loadSize

public void loadSize()
Description copied from interface: SegmentInfo
calculate the total size (this is expensive)

Specified by:
loadSize in interface SegmentInfo

doFinalDelete

public void doFinalDelete()
Description copied from interface: SegmentInfo
Perform a final delete removing all files from the local disk

Specified by:
doFinalDelete in interface SegmentInfo

deleteAll

public static void deleteAll(File f)
delete all files under this file and including this file

Parameters:
f -

isLocalLock

public boolean isLocalLock()
Description copied from interface: SegmentInfo
Does this thread have a local lock on the segment

Specified by:
isLocalLock in interface SegmentInfo
Returns:

lockLocalSegment

public void lockLocalSegment()
Description copied from interface: SegmentInfo
Perform a lock on the segment for local operations

Specified by:
lockLocalSegment in interface SegmentInfo

unlockLocalSegment

public void unlockLocalSegment()
Description copied from interface: SegmentInfo
Unlock the segment

Specified by:
unlockLocalSegment in interface SegmentInfo

debugSegment

public void debugSegment(String message)
Specified by:
debugSegment in interface SegmentInfo

compareTo

public void compareTo(String message,
                      SegmentInfo compare)
Description copied from interface: SegmentInfo
Compares this segment to the supplied segment, based on the in memory state of the live segment state

Specified by:
compareTo in interface SegmentInfo


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