org.jwall.web.audit.io
Class ConcurrentAuditReader

java.lang.Object
  extended by org.jwall.web.audit.io.ConcurrentAuditReader
All Implemented Interfaces:
AuditEventReader

public class ConcurrentAuditReader
extends java.lang.Object
implements AuditEventReader

This class read the index-file of a concurrent auditlog and creates audit-events from the appopriate event-files, if available.

Author:
Christian Bockermann <chris@jwall.org>

Constructor Summary
ConcurrentAuditReader(java.io.File dataDir)
           
ConcurrentAuditReader(java.io.File dataDir, boolean tail)
          This constructor creates a new concurrent audit-reader that listens on the index file in the given data-directory.
ConcurrentAuditReader(java.io.File data, java.io.File index)
           
ConcurrentAuditReader(java.io.File dataDir, java.io.File indexFile, boolean tail)
          This constructor creates a new concurrent audit-reader that reads from the given index file and expects the audit data-files to exist relative to the given data-directory.
 
Method Summary
 long bytesAvailable()
           
 long bytesRead()
           
 void close()
           
 void finish()
           
 AuditEvent readEvent(java.lang.String s)
          This method creates an audit-event instance from a file.
 AuditEvent readNext()
          This method read the next event from the file-system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentAuditReader

public ConcurrentAuditReader(java.io.File dataDir,
                             java.io.File indexFile,
                             boolean tail)
                      throws java.io.IOException
This constructor creates a new concurrent audit-reader that reads from the given index file and expects the audit data-files to exist relative to the given data-directory.

Parameters:
dataDir - The base directory of the data-files.
indexFile - The file containing the summary-lines for all events.
Throws:
java.io.IOException - In case any of the files cannot be read or does not exist.

ConcurrentAuditReader

public ConcurrentAuditReader(java.io.File data,
                             java.io.File index)
                      throws java.io.IOException
Throws:
java.io.IOException

ConcurrentAuditReader

public ConcurrentAuditReader(java.io.File dataDir,
                             boolean tail)
                      throws java.io.IOException
This constructor creates a new concurrent audit-reader that listens on the index file in the given data-directory. The index-file is assumed to be called index and has to exists in the given data-directory.

Parameters:
dataDir - The directory where all audit-data is stored.
Throws:
java.lang.Exception - In case the index file does not exists or cannot be read.
java.io.IOException

ConcurrentAuditReader

public ConcurrentAuditReader(java.io.File dataDir)
                      throws java.io.IOException
Throws:
java.io.IOException
Method Detail

readNext

public AuditEvent readNext()
                    throws java.io.IOException,
                           ParseException
This method read the next event from the file-system. If there is none available it waits and listens for another one to be appended to the index-file.

Specified by:
readNext in interface AuditEventReader
Returns:
The next audit-event from or NULL if no event is available.
Throws:
java.io.IOException
ParseException

readEvent

public AuditEvent readEvent(java.lang.String s)
                     throws java.io.IOException,
                            ParseException
This method creates an audit-event instance from a file. The filename is extracted from the given index-entry line s and the basic data directory that was specified at creation of this audit-reader.

Parameters:
s - The index entry line.
Returns:
An audit-event.
Throws:
java.io.IOException - In case the file cannot be read (due to non-existence or missing rights) an exception is thrown.
ParseException

finish

public void finish()

close

public void close()
           throws java.io.IOException
Specified by:
close in interface AuditEventReader
Throws:
java.io.IOException

bytesRead

public long bytesRead()
Specified by:
bytesRead in interface AuditEventReader

bytesAvailable

public long bytesAvailable()
Specified by:
bytesAvailable in interface AuditEventReader