com.sun.jini.mahalo.log
Class SimpleLogFile

java.lang.Object
  extended by com.sun.jini.mahalo.log.SimpleLogFile
All Implemented Interfaces:
ClientLog, Log

public class SimpleLogFile
extends Object
implements Log

An implementation of a re-usable Log.

Author:
Sun Microsystems, Inc.
See Also:
Log

Nested Class Summary
private static class SimpleLogFile.HeaderlessObjectInputStream
          This class extends ObjectInputStream and overrides the readStreamHeader method to a no-op operation.
private static class SimpleLogFile.HeaderlessObjectOutputStream
          This class extends ObjectOutputStream and overrides the writeStreamHeader method to a no-op operation.
 
Field Summary
private  long cookie
          Unique ID associated with this log
private static Logger initLogger
          Logger for initialization related messages
private  MultiLogManager.LogRemovalManager logMgr
          Reference to LogRemovalManager, which is called to remove this log from the managed set of logs.
private  String name
          (Relative) File name of the log file
private static Logger operationsLogger
          Logger for operations related messages
private  ObjectOutputStream out
          Output stream for writing log objects
private  FileOutputStream outfile
          File output stream associated with out.
private static Logger persistenceLogger
          Logger for persistence related messages
private  boolean readonly
          Flag to indicate that the log file has been created via the read-only constructor.
private  boolean valid
          Flag that indicates validity of this log.
 
Constructor Summary
SimpleLogFile(String name, long cookie, MultiLogManager.LogRemovalManager logMgr)
          Creates a SimpleLogFile.
SimpleLogFile(String name, MultiLogManager.LogRemovalManager logMgr)
          Creates a read-only SimpleLogFile To be used for read-only access to a named Log.
 
Method Summary
 long cookie()
          Returns the identifier associated with information in this Log.
private  void init(String name, long cookie, MultiLogManager.LogRemovalManager logMgr)
           
 void invalidate()
          Invalidate the log.
 void recover(LogRecovery client)
          Recover information from the log.
 void write(LogRecord rec)
          Add a LogRecord to the Log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cookie

private long cookie
Unique ID associated with this log


out

private ObjectOutputStream out
Output stream for writing log objects


outfile

private FileOutputStream outfile
File output stream associated with out. Used to get a handle to underlying file descriptor object.


name

private String name
(Relative) File name of the log file


logMgr

private MultiLogManager.LogRemovalManager logMgr
Reference to LogRemovalManager, which is called to remove this log from the managed set of logs.


valid

private boolean valid
Flag that indicates validity of this log. Set to false by call to invalidate().


readonly

private boolean readonly
Flag to indicate that the log file has been created via the read-only constructor. This flag is set to false via the non-read-only constructor or a call to recover()


persistenceLogger

private static final Logger persistenceLogger
Logger for persistence related messages


operationsLogger

private static final Logger operationsLogger
Logger for operations related messages


initLogger

private static final Logger initLogger
Logger for initialization related messages

Constructor Detail

SimpleLogFile

public SimpleLogFile(String name,
                     MultiLogManager.LogRemovalManager logMgr)
Creates a read-only SimpleLogFile To be used for read-only access to a named Log. This is desired when recovering information from a Log.

Parameters:
name - names the file in which information is stored.
logMgr - LogRemovalManager managing this log. This object is called back to remove this log from the manager's managed set of log files.
See Also:
Log, LogManager, MultiLogManager, MultiLogManager.LogRemovalManager

SimpleLogFile

public SimpleLogFile(String name,
                     long cookie,
                     MultiLogManager.LogRemovalManager logMgr)
Creates a SimpleLogFile.

Parameters:
name - names the file in which information is stored.
cookie - identifier representing information being stored.
logMgr - LogRemovalManager managing this log. This object is called back to remove this log from the manager's responsibility.
See Also:
Log, LogManager, MultiLogManager, MultiLogManager.LogRemovalManager
Method Detail

init

private void init(String name,
                  long cookie,
                  MultiLogManager.LogRemovalManager logMgr)

cookie

public long cookie()
Returns the identifier associated with information in this Log.

Specified by:
cookie in interface Log
See Also:
Log

write

public void write(LogRecord rec)
           throws LogException
Add a LogRecord to the Log.

Specified by:
write in interface ClientLog
Parameters:
rec - the record to be logged.
Throws:
LogException
See Also:
LogRecord

invalidate

public void invalidate()
                throws LogException
Invalidate the log.

Specified by:
invalidate in interface ClientLog
Throws:
LogException

recover

public void recover(LogRecovery client)
             throws LogException
Recover information from the log.

Specified by:
recover in interface Log
Parameters:
client - who to inform with information from the log.
Throws:
LogException
See Also:
LogRecovery


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.