alma::acs::logtools::monitor::file::FileHelper Class Reference

Collaboration diagram for alma::acs::logtools::monitor::file::FileHelper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileHelper (String folder, String ext, String header)
synchronized void put (String s)
synchronized void close ()

Public Attributes

final String folder
final String extension

Private Member Functions

void checkFile ()
void getNewFile ()
void closeFile ()

Private Attributes

int currentWritingOps = 0
final long MAX_LOG_FILE_SIZE = 1024*1024*1024
final String header
PrintStream outStream = null
File outputFile = null
volatile boolean closed = false

Static Private Attributes

static final int CHECK_INTERVAL = 6

Detailed Description

Help managing the text file to write stats into.

The helper generates a new file when the size of the current size is greater then a threshold.

The name of each file is composed of the extension plus the time stamp of the creation.

Note: in case of error creating a file, the object will discard all next writing requests.

Author:
acaproni
Since:
ACS 8.1.0

Constructor & Destructor Documentation

alma::acs::logtools::monitor::file::FileHelper::FileHelper ( String  folder,
String  ext,
String  header 
) [inline]

Constructor

Parameters:
folder The folder
ext The extension
header The header to write on top of each new file (can be null and empty)

References extension, and getNewFile().


Member Function Documentation

void alma::acs::logtools::monitor::file::FileHelper::checkFile (  )  [inline, private]

Check if the file is valid and eventually creates a new one

References getNewFile(), MAX_LOG_FILE_SIZE, and outputFile.

Referenced by put().

synchronized void alma::acs::logtools::monitor::file::FileHelper::close (  )  [inline]

Close the object in order to reject any further writing request and release the file.

References closed, and closeFile().

Referenced by alma::acs::logtools::monitor::file::FileStatistics::close().

void alma::acs::logtools::monitor::file::FileHelper::closeFile (  )  [inline, private]

Close the current file

References outputFile, and outStream.

Referenced by close(), and getNewFile().

void alma::acs::logtools::monitor::file::FileHelper::getNewFile (  )  [inline, private]

Check the length of the file and eventually creates a new one.

References closed, closeFile(), extension, header, outputFile, and outStream.

Referenced by checkFile(), and FileHelper().

synchronized void alma::acs::logtools::monitor::file::FileHelper::put ( String  s  )  [inline]

Write the string in the file.

Parameters:
s The string to append to the file

References CHECK_INTERVAL, checkFile(), closed, currentWritingOps, and outStream.

Referenced by alma::acs::logtools::monitor::file::FileStatistics::recvLogs(), and alma::acs::logtools::monitor::file::FileStatistics::run().


Member Data Documentation

To improve performance the checking of the length of the files is done after CHECK_INTERVAL writings.

Referenced by put().

volatile boolean alma::acs::logtools::monitor::file::FileHelper::closed = false [private]

If true the object has been closed

Referenced by close(), getNewFile(), and put().

The property remember how many writings have been done since the last time the length of the file was checked.

Referenced by put().

The folder to create file into

Referenced by FileHelper(), and getNewFile().

The folder to create file into

The header to write on top of each new file (can be null and empty)

Referenced by getNewFile().

The max dimension of each file of log in bytes.

Referenced by checkFile().

The file for output

Referenced by checkFile(), closeFile(), and getNewFile().

The writer for output

Referenced by closeFile(), getNewFile(), and put().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2