public class MemoryLogStorage extends Object implements LogStorage, LogStorageStatus
LogStorage
and LogStorageStatus
Constructor and Description |
---|
MemoryLogStorage(long bucketSize) |
Modifier and Type | Method and Description |
---|---|
void |
addLogRecord(LogRecord record)
Persists new log record.
|
long |
getConsumedVolume()
Retrieves current log storage size used by added records.
|
LogBlock |
getRecordBlock(long blockSize)
Retrieves new log block of specified size or null if there is no logs.
|
long |
getRecordCount()
Retrieves current number of added records.
|
void |
notifyUploadFailed(int id)
Notifies if sending of a log block with a specified id was failed.
|
void |
removeOldestRecord(long maximumAllowedVolume)
Removes elder records until occupied size becomes equal or less than
specified in a passed parameter.
|
void |
removeRecordBlock(int id)
Removes already sent log records by its block id.
|
public void addLogRecord(LogRecord record)
LogStorage
addLogRecord
in interface LogStorage
record
- New record (LogRecord
)public long getConsumedVolume()
LogStorageStatus
getConsumedVolume
in interface LogStorageStatus
public long getRecordCount()
LogStorageStatus
getRecordCount
in interface LogStorageStatus
public LogBlock getRecordBlock(long blockSize)
LogStorage
Retrieves new log block of specified size or null if there is no logs.
The size of retrieved log records should NOT be greater than specified block size.
getRecordBlock
in interface LogStorage
blockSize
- Maximum size of sending log blockLogBlock
)public void removeRecordBlock(int id)
LogStorage
Removes already sent log records by its block id.
Use in case of a successful upload.
removeRecordBlock
in interface LogStorage
id
- Unique id of sent log blockpublic void removeOldestRecord(long maximumAllowedVolume)
LogStorage
removeOldestRecord
in interface LogStorage
maximumAllowedVolume
- Maximum size of inner storagepublic void notifyUploadFailed(int id)
LogStorage
notifyUploadFailed
in interface LogStorage
id
- Unique id of log block.Copyright © 2015. All rights reserved.