|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.thl.log.DiskLog
public class DiskLog
This class implements a multi-thread disk log store.
| Field Summary | |
|---|---|
protected int |
bufferSize
I/O buffer size for log file access. |
protected java.lang.String |
eventSerializerClass
Name of the class used to serialize events. |
protected int |
logConnectionTimeoutMillis
Number of milliseconds before timing out idle log connections. |
protected java.lang.String |
logDirName
Name of the log directory. |
protected long |
logFileRetainMillis
Number of milliseconds to retain old logs. |
protected int |
logFileSize
Log file maximum size in bytes. |
protected int |
logRotateMillis
Special timeout when waiting for a new log file after a rotate log. |
protected boolean |
readOnly
Indicates whether access should be read only or not |
protected int |
timeoutMillis
Wait timeout. |
protected WriteLock |
writeLock
Write lock to prevent log file corruption by concurrent access. |
| Constructor Summary | |
|---|---|
DiskLog()
Creates a new log instance. |
|
| Method Summary | |
|---|---|
LogConnection |
connect(boolean readonly)
Creates a new log connection. |
void |
delete(LogConnection client,
java.lang.Long low,
java.lang.Long high)
Deletes a portion of the log. |
int |
fileCount()
Returns the count of files in the log. |
long |
getActiveSeqno()
Returns the active sequence number. |
Serializer |
getEventSerializer()
Returns the event serializer instance. |
java.lang.String |
getFilePrefix()
Returns THL log filename prefix. |
java.lang.String |
getFirstFile()
Returns the first index file or null if no such file exists. |
long |
getFlushIntervalMillis()
Return flush interval in milliseconds. |
java.lang.String |
getIndex()
getIndex returns a String representation of the index, built from the configured log directory. |
java.lang.String |
getLastFile()
Returns the last index file or null if no such file exists. |
java.lang.String |
getLogDir()
Returns the log directory. |
java.lang.String[] |
getLogFileNames()
Returns an array of log files. |
int |
getLogFileSize()
Returns the log file size. |
int |
getLogRotateMillis()
Returns the current timeout value for log rotation. |
long |
getMaxSeqno()
Return the maximum sequence number stored in the log. |
long |
getMinSeqno()
Return the minimum sequence number stored in the log. |
int |
getTimeoutMillis()
Returns the current timeout value for blocking reads. |
boolean |
isDoChecksum()
Return true if checksums are enabled. |
boolean |
isWritable()
Returns true if this log is writable. |
static java.io.File[] |
listLogFiles(java.io.File logDir,
java.lang.String logFilePrefix)
Returns a sorted list of log files. |
void |
prepare()
Prepare the log for use, which includes ensuring that the log is created automatically on first use and building an index of log file contents. |
void |
release()
Releases the log resources. |
void |
release(LogConnection connection)
Releases a log connection. |
void |
setActiveSeqno(long activeSeqno)
Updates the active sequence number. |
void |
setBufferSize(int bufferSize)
Sets the log buffer size. |
void |
setDoChecksum(boolean doChecksum)
Determines whether to checksum log records. |
void |
setEventSerializerClass(java.lang.String eventSerializerClass)
Sets the event serializer class name. |
void |
setFlushIntervalMillis(long flushIntervalMillis)
Set write flush interval in milliseconds. |
void |
setFsyncOnFlush(boolean fsyncOnFlush)
If set to true, perform an fsync with every flush. |
void |
setLogConnectionTimeoutMillis(int logConnectionTimeoutMillis)
Set the number of milliseconds before timing out idle log connections. |
void |
setLogDir(java.lang.String path)
Sets the directory that will be used to store the log files |
void |
setLogFileRetainMillis(long logFileRetainMillis)
Set the number of milliseconds to retain old log files. |
void |
setLogFileSize(int size)
Sets the log file size. |
void |
setLogRotateMillis(int logRotateMillis)
Sets the timeout value for reading a new file after a log rotation. |
void |
setMaxSeqno(long seqno)
Sets the maximum sequence number stored in the log. |
void |
setReadOnly(boolean readOnly)
|
void |
setTimeoutMillis(int timeoutMillis)
Sets the timeout value for blocking reads. |
void |
validate()
Validates the log to ensure there are no inconsistencies. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String logDirName
protected java.lang.String eventSerializerClass
protected int logFileSize
protected int timeoutMillis
protected int logRotateMillis
protected long logFileRetainMillis
protected int logConnectionTimeoutMillis
protected int bufferSize
protected WriteLock writeLock
protected boolean readOnly
| Constructor Detail |
|---|
public DiskLog()
| Method Detail |
|---|
public void setLogDir(java.lang.String path)
path - directory to be used. Last / is optional.public java.lang.String getLogDir()
public java.lang.String getFilePrefix()
public void setLogFileSize(int size)
size - file sizepublic int getLogFileSize()
public void setDoChecksum(boolean doChecksum)
doChecksum - If true use checksumspublic boolean isDoChecksum()
public void setLogFileRetainMillis(long logFileRetainMillis)
logFileRetainMillis - If other than 0, logs are retained for this
amount of timepublic void setLogConnectionTimeoutMillis(int logConnectionTimeoutMillis)
logConnectionTimeoutMillis - Time in millisecondspublic void setEventSerializerClass(java.lang.String eventSerializerClass)
public Serializer getEventSerializer()
public void setTimeoutMillis(int timeoutMillis)
public int getTimeoutMillis()
public void setLogRotateMillis(int logRotateMillis)
public int getLogRotateMillis()
public void setBufferSize(int bufferSize)
public void setFlushIntervalMillis(long flushIntervalMillis)
public long getFlushIntervalMillis()
public void setFsyncOnFlush(boolean fsyncOnFlush)
public void setReadOnly(boolean readOnly)
public void prepare()
throws ReplicatorException,
java.lang.InterruptedException
ReplicatorException
java.lang.InterruptedException
public void release()
throws ReplicatorException,
java.lang.InterruptedException
ReplicatorException
java.lang.InterruptedExceptionpublic void setActiveSeqno(long activeSeqno)
public long getActiveSeqno()
public long getMaxSeqno()
public void setMaxSeqno(long seqno)
public long getMinSeqno()
public int fileCount()
public java.lang.String[] getLogFileNames()
public boolean isWritable()
public LogConnection connect(boolean readonly)
throws ReplicatorException
readonly - If true, for read only. Only one active connection may
write at any given time.
ReplicatorExceptionpublic void release(LogConnection connection)
connection - Connection to release
public void validate()
throws LogConsistencyException
LogConsistencyException - Thrown if log is not consistent
public void delete(LogConnection client,
java.lang.Long low,
java.lang.Long high)
throws ReplicatorException,
java.lang.InterruptedException
client - Disk log client used for deletionlow - Sequence number specifying the beginning of the range. Leave
null to start from the current beginning of the log.high - Sequence number specifying the end of the range. Leave null
to delete to the end of the log.
ReplicatorException - Thrown if delete fails
java.lang.InterruptedExceptionpublic java.lang.String getIndex()
public java.lang.String getFirstFile()
public java.lang.String getLastFile()
public static java.io.File[] listLogFiles(java.io.File logDir,
java.lang.String logFilePrefix)
logDir - Directory containing logslogFilePrefix - Prefix for log file names
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||