Package bitronix.tm.journal
Class TransactionLogHeader
java.lang.Object
bitronix.tm.journal.TransactionLogHeader
Used to control a log file's header.
The physical data is read when this object is created then cached. Calling setter methods sets the header field then moves the file pointer back to the previous location.
- Author:
- lorban
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteState of the log file when it has been closed properly.static final intPosition of the current log position in the header.static final intPosition of the format ID in the header (seeBitronixXid.FORMAT_ID).static final intTotal length of the header.static final intPosition of the log file state in the header.static final intPosition of the timestamp in the header.static final byteState of the log file when it hasn't been closed properly or it is still open. -
Constructor Summary
ConstructorsConstructorDescriptionTransactionLogHeader(FileChannel fc, long maxFileLength) TransactionLogHeader are used to control headers of the specified RandomAccessFile. -
Method Summary
Modifier and TypeMethodDescriptionintGet FORMAT_ID_HEADER.longGet CURRENT_POSITION_HEADER.bytegetState()Get STATE_HEADER.longGet TIMESTAMP_HEADER.voidgoAhead(long distance) Advance CURRENT_POSITION_HEADER.voidrewind()Rewind CURRENT_POSITION_HEADER back to the beginning of the file.voidsetFormatId(int formatId) Set FORMAT_ID_HEADER.voidsetPosition(long position) Set CURRENT_POSITION_HEADER.voidsetState(byte state) Set STATE_HEADER.voidsetTimestamp(long timestamp) Set TIMESTAMP_HEADER.toString()Create human-readable String representation.
-
Field Details
-
FORMAT_ID_HEADER
public static final int FORMAT_ID_HEADERPosition of the format ID in the header (seeBitronixXid.FORMAT_ID).- See Also:
-
TIMESTAMP_HEADER
public static final int TIMESTAMP_HEADERPosition of the timestamp in the header.- See Also:
-
STATE_HEADER
public static final int STATE_HEADERPosition of the log file state in the header.- See Also:
-
CURRENT_POSITION_HEADER
public static final int CURRENT_POSITION_HEADERPosition of the current log position in the header.- See Also:
-
HEADER_LENGTH
public static final int HEADER_LENGTHTotal length of the header.- See Also:
-
CLEAN_LOG_STATE
public static final byte CLEAN_LOG_STATEState of the log file when it has been closed properly.- See Also:
-
UNCLEAN_LOG_STATE
public static final byte UNCLEAN_LOG_STATEState of the log file when it hasn't been closed properly or it is still open.- See Also:
-
-
Constructor Details
-
TransactionLogHeader
TransactionLogHeader are used to control headers of the specified RandomAccessFile. All calls to setters are synchronized on the passed-in RandomAccessFile.- Parameters:
fc- the file channel to read from.maxFileLength- the max file length.- Throws:
IOException- if an I/O error occurs.
-
-
Method Details
-
getFormatId
public int getFormatId()Get FORMAT_ID_HEADER.- Returns:
- the FORMAT_ID_HEADER value.
- See Also:
-
getTimestamp
public long getTimestamp()Get TIMESTAMP_HEADER.- Returns:
- the TIMESTAMP_HEADER value.
- See Also:
-
getState
public byte getState()Get STATE_HEADER.- Returns:
- the STATE_HEADER value.
- See Also:
-
getPosition
public long getPosition()Get CURRENT_POSITION_HEADER.- Returns:
- the CURRENT_POSITION_HEADER value.
- See Also:
-
setFormatId
Set FORMAT_ID_HEADER.- Parameters:
formatId- the FORMAT_ID_HEADER value.- Throws:
IOException- if an I/O error occurs.- See Also:
-
setTimestamp
Set TIMESTAMP_HEADER.- Parameters:
timestamp- the TIMESTAMP_HEADER value.- Throws:
IOException- if an I/O error occurs.- See Also:
-
setState
Set STATE_HEADER.- Parameters:
state- the STATE_HEADER value.- Throws:
IOException- if an I/O error occurs.- See Also:
-
setPosition
Set CURRENT_POSITION_HEADER.- Parameters:
position- the CURRENT_POSITION_HEADER value.- Throws:
IOException- if an I/O error occurs.- See Also:
-
goAhead
Advance CURRENT_POSITION_HEADER.- Parameters:
distance- the value to add to the current position.- Throws:
IOException- if an I/O error occurs.- See Also:
-
rewind
Rewind CURRENT_POSITION_HEADER back to the beginning of the file.- Throws:
IOException- if an I/O error occurs.- See Also:
-
toString
Create human-readable String representation.
-