
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 |
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.
| alma::acs::logtools::monitor::file::FileHelper::FileHelper | ( | String | folder, | |
| String | ext, | |||
| String | header | |||
| ) | [inline] |
Constructor
| 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().
| 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.
| 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().
final int alma::acs::logtools::monitor::file::FileHelper::CHECK_INTERVAL = 6 [static, private] |
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().
int alma::acs::logtools::monitor::file::FileHelper::currentWritingOps = 0 [private] |
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
final String alma::acs::logtools::monitor::file::FileHelper::header [private] |
The header to write on top of each new file (can be null and empty)
Referenced by getNewFile().
final long alma::acs::logtools::monitor::file::FileHelper::MAX_LOG_FILE_SIZE = 1024*1024*1024 [private] |
The max dimension of each file of log in bytes.
Referenced by checkFile().
File alma::acs::logtools::monitor::file::FileHelper::outputFile = null [private] |
The file for output
Referenced by checkFile(), closeFile(), and getNewFile().
PrintStream alma::acs::logtools::monitor::file::FileHelper::outStream = null [private] |
The writer for output
Referenced by closeFile(), getNewFile(), and put().
1.6.2