|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.howl.log.LogObject
org.objectweb.howl.log.Logger
org.objectweb.howl.log.xa.XALogger
A specialized subclass of Logger
intended to provide functionality required by any XA Transaction Manager.
This class provides wrappers for all public methods of Logger to allow enforcement of policies that are in place for an XA TM log.
This class implements LogEventListener
.
During logOverflowNotification processing, entries in the activeTx[]
are re-logged and the active mark is moved.
If the application has called setLogEventListener, then Log events are forwarded to the application after they are processed by this class.
Field Summary |
Fields inherited from class org.objectweb.howl.log.Logger |
isClosed |
Fields inherited from interface org.objectweb.howl.log.LogEventListener |
DEBUG, ERROR, FATAL, INFO, TRACE, WARN |
Constructor Summary | |
XALogger()
Construct a Logger using default Configuration object. |
|
XALogger(Configuration config)
Construct a Logger using a Configuration supplied by the caller. |
Method Summary | |
void |
activeTxDisplay()
displays entries in the activeTx table. |
void |
close()
close the Log files and perform necessary cleanup tasks. |
int |
getActiveTxUsed()
Used by TM and test cases to obtain the number of entries in the activeTx table. |
java.lang.String |
getStats()
return an XML node containing statistics for this object along with the base Logger, the LogFile pool and the LogBuffer pool. |
boolean |
isLoggable(int level)
implements LogEventListener#isLoggable(). |
void |
log(int level,
java.lang.String message)
delegates log request to the callers event listener. |
void |
log(int level,
java.lang.String message,
java.lang.Throwable thrown)
delegates log request to the callers event listener. |
void |
logOverflowNotification(long overflowFence)
called by Logger when log file is about to overflow. |
void |
open()
Not supported for XALogger. |
void |
open(ReplayListener listener)
calls super.open() to perform standard open functionality then replays the log to rebuild the activeTx table. |
long |
put(byte[][] data,
boolean sync)
add a USER record consisting of byte[][] to the log. |
long |
put(byte[] data,
boolean sync)
add a USER record consisting of byte[] to the log. |
XACommittingTx |
putCommit(byte[][] record)
Write a begin COMMIT record to the log. |
long |
putDone(byte[][] record,
XACommittingTx tx)
Write a DONE record to the log. |
void |
replay(ReplayListener listener)
Wrapp Logger#replay(ReplayListener) so we can intercept onRecord() notifications to process XACOMMIT and XACOMMITMOVED records. |
void |
replay(ReplayListener listener,
long key)
Wrapp Logger#replay(ReplayListener, long) so we can intercept onRecord() notifications to process XACOMMIT and XACOMMITMOVED records. |
void |
replayActiveTx(ReplayListener listener)
Called by the TM to receive copies of the active transaction entries. |
void |
setLogEventListener(LogEventListener eventListener)
Saves a reference to callers LogEventListener. |
Methods inherited from class org.objectweb.howl.log.Logger |
get, getActiveMark, getNext, mark, mark, put, replay, setAutoMark |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XALogger() throws java.io.IOException
java.io.IOException
public XALogger(Configuration config) throws java.io.IOException
config
- Configuration object
java.io.IOException
Method Detail |
public long put(byte[] data, boolean sync) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, java.lang.InterruptedException, java.io.IOException
waits for overflow notification processing to complete prior to putting the data to the log.
put
in class Logger
data
- byte[] to be written to logsync
- true if caller wishes to block waiting for the
record to force to disk.
LogClosedException
- If the TM has called open() but has not called replay().
Also thrown if log is actually closed.
Check the toString() for details.
java.lang.InterruptedException
java.io.IOException
LogRecordSizeException
LogFileOverflowException
Logger.put(byte[], boolean)
public long put(byte[][] data, boolean sync) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, java.lang.InterruptedException, java.io.IOException
waits for overflow notification processing to complete prior to putting the data to the log.
put
in class Logger
data
- record datasync
- true if call should block until force
LogClosedException
- If the TM has called open() but has not called replay().
Also thrown if log is actually closed.
Check the toString() for details.
java.io.IOException
LogRecordSizeException
java.lang.InterruptedException
LogFileOverflowException
Logger.put(byte[][], boolean)
public XACommittingTx putCommit(byte[][] record) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, java.lang.InterruptedException, java.io.IOException
Call blocks until the data is forced to disk.
record
- byte[][] containing data to be logged
LogClosedException
- If the TM has called open() but has not called replay().
Also thrown if log is actually closed.
Check the toString() for details.
java.io.IOException
java.lang.InterruptedException
LogFileOverflowException
LogRecordSizeException
public long putDone(byte[][] record, XACommittingTx tx) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, java.lang.InterruptedException, java.io.IOException
Remove XACommittingTx object from the list of active transactions.
record
- byte[][] containing data to be logged.
If record
is null
then
no user data is written to the journal.
tx
- the XACommittingTx that was returned
by the putCommit() routine for this transaction.
record
byte[][].
If record is null, then return is 0L.
java.io.IOException
java.lang.InterruptedException
LogFileOverflowException
LogRecordSizeException
LogClosedException
- If the TM has called open() but has not called replay().
Also thrown if log is actually closed.
Check the toString() for details.
public boolean isLoggable(int level)
isLoggable
in interface LogEventListener
level
- a logging level defined by LogEventListener
java.util.logging.Logger#isLoggable()
public void log(int level, java.lang.String message)
log
in interface LogEventListener
level
- log levelmessage
- text to be loggedpublic void log(int level, java.lang.String message, java.lang.Throwable thrown)
log
in interface LogEventListener
level
- log levelmessage
- text to be loggedthrown
- Throwable related to event being loggedpublic void logOverflowNotification(long overflowFence)
copies XACommittingTx records forward to allow reuse of older log file space.
calls Logger.mark() to set the new active mark at the completion of the scan.
Exceptions are ignored. Hopefully they will be reported to the TM when a transaction thread attempts to write a log record.
While we are processing activeTx[] we publish the overflowFence so putCommit knows that any record it stores with a key below the fence must be re-put.
This notification is not forwarded to the LogEventListener eventListener that was registered by the TM.
logOverflowNotification
in interface LogEventListener
overflowFence
- COMMIT records with
log keys lower than fence must
be moved. All others can be ignored
for now.public java.lang.String getStats()
getStats
in class Logger
public void setLogEventListener(LogEventListener eventListener)
Some LogEventListener notifications may be passed onto the callers eventListener. Refer to javadocs in this source for individual notifications to determine if the notification is passed on to the TM.
setLogEventListener
in class Logger
eventListener
- object to be notified of logger events.public void open()
XALogger must rebuild the activeTx table prior to allowing
any calls to put() methods. To enforce this, callers must
use the open(ReplayListener)
method.
open
in class Logger
java.lang.UnsupportedOperationException
public void open(ReplayListener listener) throws InvalidFileSetException, LogConfigurationException, InvalidLogBufferException, LogClosedException, java.lang.ClassNotFoundException, java.io.IOException, java.lang.InterruptedException
Sets replayNeeded flag to block calls to put() methods until the replay is complete. (This may be unnecessary because the replay blocks until it is complete, but we do this to prevent the TM from trying to make log entries on another thread before the log is fully open.)
During the replay, the XALogger calls the TM's listener.onRecord() with an XALogRecord object. The TM is expected to call getTx() to obtain a reference to the XACommittingTx that will be used to complete the transaction usin putDone() later.
Note that XALogger does not call the TM's listener.getLogRecord().
listener
- The TM can receive replay events by
providing a ReplayListener.
TMs that do not wish to see all records during
the open replay should pass a null ReplayListener.
InvalidFileSetException
LogConfigurationException
InvalidLogBufferException
LogClosedException
java.lang.ClassNotFoundException
java.io.IOException
java.lang.InterruptedException
replayActiveTx(ReplayListener)
public void close() throws java.io.IOException, java.lang.InterruptedException
Logger
close
in class Logger
java.io.IOException
java.lang.InterruptedException
public int getActiveTxUsed()
TIP: if value does not agree with expected value in TM or test case, we probably have a bug somewhere.
public void activeTxDisplay()
useful for debug.
public void replay(ReplayListener listener) throws LogConfigurationException
replay
in class Logger
listener
- an object that implements ReplayListener interface.
LogConfigurationException
- most likely because the configured LogBuffer class cannot be found.Logger.replay(ReplayListener, long)
public void replay(ReplayListener listener, long key) throws InvalidLogKeyException, LogConfigurationException
replay
in class Logger
listener
- an object that implements ReplayListener interface.key
- a log key to begin replay from.
The mark should be a valid log key returned by the put() method. To replay the entire log beginning with the oldest available record, mark should be set to zero (0L).
LogConfigurationException
- most likely because the configured LogBuffer class cannot be found.
InvalidLogKeyException
- if mark is not a valid log key.public void replayActiveTx(ReplayListener listener)
TMs can use this method as an alternative to passing a ReplayListener to open. The advantage is that only active transaction entries are returned to the ReplayListener.onRecord() method.
listener
- The activeTx entries are passed
to the TM through this ReplayListener.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |