bitronix.tm.journal
Class TransactionLogHeader

java.lang.Object
  extended by bitronix.tm.journal.TransactionLogHeader

public class TransactionLogHeader
extends Object

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
static byte CLEAN_LOG_STATE
          State of the log file when it has been closed properly.
static int CURRENT_POSITION_HEADER
          Position of the current log position in the header.
static int FORMAT_ID_HEADER
          Position of the format ID in the header (see BitronixXid.FORMAT_ID).
static int HEADER_LENGTH
          Total length of the header.
static int STATE_HEADER
          Position of the log file state in the header.
static int TIMESTAMP_HEADER
          Position of the timestamp in the header.
static byte UNCLEAN_LOG_STATE
          State of the log file when it hasn't been closed properly or it is still open.
 
Constructor Summary
TransactionLogHeader(FileChannel fc, long maxFileLength)
          TransactionLogHeader are used to control headers of the specified RandomAccessFile.
 
Method Summary
 int getFormatId()
          Get FORMAT_ID_HEADER.
 long getPosition()
          Get CURRENT_POSITION_HEADER.
 byte getState()
          Get STATE_HEADER.
 long getTimestamp()
          Get TIMESTAMP_HEADER.
 void goAhead(long distance)
          Advance CURRENT_POSITION_HEADER.
 void rewind()
          Rewind CURRENT_POSITION_HEADER back to the beginning of the file.
 void setFormatId(int formatId)
          Set FORMAT_ID_HEADER.
 void setPosition(long position)
          Set CURRENT_POSITION_HEADER.
 void setState(byte state)
          Set STATE_HEADER.
 void setTimestamp(long timestamp)
          Set TIMESTAMP_HEADER.
 String toString()
          Create human-readable String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMAT_ID_HEADER

public static final int FORMAT_ID_HEADER
Position of the format ID in the header (see BitronixXid.FORMAT_ID).

See Also:
Constant Field Values

TIMESTAMP_HEADER

public static final int TIMESTAMP_HEADER
Position of the timestamp in the header.

See Also:
Constant Field Values

STATE_HEADER

public static final int STATE_HEADER
Position of the log file state in the header.

See Also:
Constant Field Values

CURRENT_POSITION_HEADER

public static final int CURRENT_POSITION_HEADER
Position of the current log position in the header.

See Also:
Constant Field Values

HEADER_LENGTH

public static final int HEADER_LENGTH
Total length of the header.

See Also:
Constant Field Values

CLEAN_LOG_STATE

public static final byte CLEAN_LOG_STATE
State of the log file when it has been closed properly.

See Also:
Constant Field Values

UNCLEAN_LOG_STATE

public static final byte UNCLEAN_LOG_STATE
State of the log file when it hasn't been closed properly or it is still open.

See Also:
Constant Field Values
Constructor Detail

TransactionLogHeader

public TransactionLogHeader(FileChannel fc,
                            long maxFileLength)
                     throws IOException
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 Detail

getFormatId

public int getFormatId()
Get FORMAT_ID_HEADER.

Returns:
the FORMAT_ID_HEADER value.
See Also:
FORMAT_ID_HEADER

getTimestamp

public long getTimestamp()
Get TIMESTAMP_HEADER.

Returns:
the TIMESTAMP_HEADER value.
See Also:
TIMESTAMP_HEADER

getState

public byte getState()
Get STATE_HEADER.

Returns:
the STATE_HEADER value.
See Also:
STATE_HEADER

getPosition

public long getPosition()
Get CURRENT_POSITION_HEADER.

Returns:
the CURRENT_POSITION_HEADER value.
See Also:
CURRENT_POSITION_HEADER

setFormatId

public void setFormatId(int formatId)
                 throws IOException
Set FORMAT_ID_HEADER.

Parameters:
formatId - the FORMAT_ID_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
FORMAT_ID_HEADER

setTimestamp

public void setTimestamp(long timestamp)
                  throws IOException
Set TIMESTAMP_HEADER.

Parameters:
timestamp - the TIMESTAMP_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
TIMESTAMP_HEADER

setState

public void setState(byte state)
              throws IOException
Set STATE_HEADER.

Parameters:
state - the STATE_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
STATE_HEADER

setPosition

public void setPosition(long position)
                 throws IOException
Set CURRENT_POSITION_HEADER.

Parameters:
position - the CURRENT_POSITION_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
CURRENT_POSITION_HEADER

goAhead

public void goAhead(long distance)
             throws IOException
Advance CURRENT_POSITION_HEADER.

Parameters:
distance - the value to add to the current position.
Throws:
IOException - if an I/O error occurs.
See Also:
setPosition(long)

rewind

public void rewind()
            throws IOException
Rewind CURRENT_POSITION_HEADER back to the beginning of the file.

Throws:
IOException - if an I/O error occurs.
See Also:
setPosition(long)

toString

public String toString()
Create human-readable String representation.

Overrides:
toString in class Object
Returns:
a human-readable String representing this object's state.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved.