org.csc.phynixx.loggersystem.logger.channellogger
Class FileChannelDataLogger

java.lang.Object
  extended by org.csc.phynixx.loggersystem.logger.channellogger.FileChannelDataLogger
All Implemented Interfaces:
IDataLogger

public class FileChannelDataLogger
extends Object
implements IDataLogger

Logger uses a TAEnabledRandomAccessFile to persist the data. If the Logger is open, it holds a lock on This class is not thread safe . Use facades to protect instances


Constructor Summary
FileChannelDataLogger(File logFileAccess, AccessMode aceessMode)
          Opens a logger on base of die given logfile.
 
Method Summary
 void close()
          close the Log files and perform necessary cleanup tasks.
 void destroy()
          destroys the logger and removes its resources.
 AccessMode getAccessMode()
           
 boolean isClosed()
           
 void open(AccessMode accessMode)
          opens the logger with the specified ACCESS_MODE.
 void reopen(AccessMode accessMode)
          reopens the datalogger.
 void replay(ILogRecordReplayListener replay)
          the records a recovered from the format described in write(short, byte[][])
 String toString()
           
 void write(short type, byte[] record)
           
 long write(short type, byte[][] records)
           +-- length of records[0] +-- data of records[0] +-- length of records[1] +-- data of records[1] . . .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileChannelDataLogger

public FileChannelDataLogger(File logFileAccess,
                             AccessMode aceessMode)
                      throws IOException
Opens a logger on base of die given logfile. A RandomAccessFile is created . The accessMode of the logger is AccessMode.WRITE, so you can start writting date

Parameters:
logFileAccess -
Throws:
IOException
Method Detail

getAccessMode

public AccessMode getAccessMode()

open

public void open(AccessMode accessMode)
          throws IOException
opens the logger with the specified ACCESS_MODE. If the logger isn't closed it is closed

Specified by:
open in interface IDataLogger
Parameters:
accessMode -
Throws:
IOException
See Also:
IDataLogger.reopen(org.csc.phynixx.loggersystem.logger.channellogger.AccessMode)

reopen

public void reopen(AccessMode accessMode)
            throws IOException
reopens the datalogger. It is assumed that the logger is open.

Specified by:
reopen in interface IDataLogger
Parameters:
accessMode -
Throws:
IOException
IllegalStateException - logger isn't open

write

public void write(short type,
                  byte[] record)
           throws IOException
Throws:
IOException

write

public long write(short type,
                  byte[][] records)
           throws IOException
    +-- length of records[0]
    +-- data of records[0]
    +-- length of records[1]
    +-- data of records[1]
    . . .

 

this format ensures that the record could be recovered

Specified by:
write in interface IDataLogger
Parameters:
type - a record type defined in LogRecordType.
records -
Returns:
the file position before writing the data
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: IDataLogger
close the Log files and perform necessary cleanup tasks. The logger could be reopen

Specified by:
close in interface IDataLogger
Throws:
IOException

replay

public void replay(ILogRecordReplayListener replay)
            throws IOException
the records a recovered from the format described in write(short, byte[][])

Specified by:
replay in interface IDataLogger
Parameters:
replay - replayListener
Throws:
IOException

isClosed

public boolean isClosed()
Specified by:
isClosed in interface IDataLogger
Returns:
true if and if the logger is closed

destroy

public void destroy()
             throws IOException
Description copied from interface: IDataLogger
destroys the logger and removes its resources. The logger cannot be reopened

Specified by:
destroy in interface IDataLogger
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015. All rights reserved.