krati.core.segment
Class AbstractSegment
java.lang.Object
krati.core.segment.AbstractSegment
- All Implemented Interfaces:
- Segment
- Direct Known Subclasses:
- ChannelSegment, MappedSegment, MemorySegment, WriteBufferSegment
public abstract class AbstractSegment
- extends Object
- implements Segment
AbstractSegment
- Author:
- jwu
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface krati.core.segment.Segment |
append, append, appendInt, appendLong, appendShort, asReadOnly, canAppendToBuffer, canReadFromBuffer, close, force, getAppendPosition, isRecyclable, read, read, readInt, readLong, readShort, reinit, setAppendPosition, transferTo, transferTo |
_segId
protected final int _segId
_segFile
protected final File _segFile
_initSizeMB
protected final int _initSizeMB
_initSizeBytes
protected final long _initSizeBytes
_lastForcedTime
protected volatile long _lastForcedTime
_segMode
protected volatile Segment.Mode _segMode
_raf
protected RandomAccessFile _raf
_channel
protected FileChannel _channel
_storageVersion
protected long _storageVersion
AbstractSegment
protected AbstractSegment(int segmentId,
File segmentFile,
int initialSizeMB,
Segment.Mode mode)
throws IOException
- Throws:
IOException
init
protected abstract void init()
throws IOException
- Throws:
IOException
initHeader
protected void initHeader()
throws IOException
- Throws:
IOException
loadHeader
protected void loadHeader()
throws IOException
- Throws:
IOException
getHeader
protected String getHeader()
getChannelPosition
protected long getChannelPosition()
throws IOException
- Throws:
IOException
getStatus
public String getStatus()
- Specified by:
getStatus
in interface Segment
- Returns:
- the descriptive status of this Segment.
getMode
public final Segment.Mode getMode()
- Specified by:
getMode
in interface Segment
getSegmentId
public final int getSegmentId()
- Specified by:
getSegmentId
in interface Segment
getSegmentFile
public final File getSegmentFile()
- Specified by:
getSegmentFile
in interface Segment
getInitialSizeMB
public final int getInitialSizeMB()
- Specified by:
getInitialSizeMB
in interface Segment
getInitialSize
public final long getInitialSize()
- Specified by:
getInitialSize
in interface Segment
getLastForcedTime
public final long getLastForcedTime()
- Specified by:
getLastForcedTime
in interface Segment
- Returns:
- the last forced time in milliseconds since the epoch, January 01, 1970, 00:00:00 GMT.
getStorageVersion
public final long getStorageVersion()
- Specified by:
getStorageVersion
in interface Segment
- Returns:
- the storage version of this segment.
getLoadFactor
public final double getLoadFactor()
- Specified by:
getLoadFactor
in interface Segment
getLoadSize
public final int getLoadSize()
- Specified by:
getLoadSize
in interface Segment
incrLoadSize
public final void incrLoadSize(int byteCnt)
- Increases the load size.
This method is not synchronized. This is because that the writer and compactor
never write (i.e. append) data to the same segment. Consequently this method is
never concurrently called by the writer and compactor on the same segment.
- Specified by:
incrLoadSize
in interface Segment
decrLoadSize
public final void decrLoadSize(int byteCnt)
- Decreases the load size.
This method is not synchronized. This because that the writer is the only
thread calling this method on Segment(s) and the compact should never call
this method.
- Specified by:
decrLoadSize
in interface Segment
isReadOnly
public final boolean isReadOnly()
- Specified by:
isReadOnly
in interface Segment
Copyright © 2011. All Rights Reserved.