public class QueueFileEventStorage extends Object implements EventsStorage
EventsStorage backed by a QueueFile.
Note that this class is not thread safe and relies on upstream collaborators
to ensure thread safe access.| Constructor and Description |
|---|
QueueFileEventStorage(Context context,
File workingDirectory,
String workingFileName,
String targetDirectoryName) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[] data)
Add an event represented as a byte array to the working file
|
boolean |
canWorkingFileStore(int newEventSizeInBytes,
int maxByteSizePerFile) |
void |
deleteFilesInRollOverDirectory(List<File> files)
Clear out given set of files in roll-over directory
|
void |
deleteWorkingFile()
Clear out active working file
|
List<File> |
getAllFilesInRollOverDirectory() |
List<File> |
getBatchOfFilesToSend(int maxBatchSize) |
OutputStream |
getMoveOutputStream(File targetFile)
Returns the output stream to be used for moving file contents to the specified
targetFile. |
File |
getRollOverDirectory() |
File |
getWorkingDirectory() |
int |
getWorkingFileUsedSizeInBytes() |
boolean |
isWorkingFileEmpty() |
void |
rollOver(String targetName)
roll the current working file over to a file in the roll-over directory
with the given name.
|
public QueueFileEventStorage(Context context,
File workingDirectory,
String workingFileName,
String targetDirectoryName)
throws IOException
IOExceptionpublic void add(byte[] data)
throws IOException
EventsStorageadd in interface EventsStorageIOExceptionpublic int getWorkingFileUsedSizeInBytes()
getWorkingFileUsedSizeInBytes in interface EventsStoragepublic void rollOver(String targetName)
throws IOException
EventsStoragerollOver in interface EventsStorageIOExceptionpublic OutputStream getMoveOutputStream(File targetFile)
throws IOException
targetFile.
Override this method if you need a different output stream, such as one that supports
compression.IOExceptionpublic File getWorkingDirectory()
getWorkingDirectory in interface EventsStoragepublic File getRollOverDirectory()
getRollOverDirectory in interface EventsStoragepublic List<File> getBatchOfFilesToSend(int maxBatchSize)
getBatchOfFilesToSend in interface EventsStoragemaxBatchSize - maximum number of files to include in batchpublic void deleteFilesInRollOverDirectory(List<File> files)
EventsStoragedeleteFilesInRollOverDirectory in interface EventsStoragepublic List<File> getAllFilesInRollOverDirectory()
getAllFilesInRollOverDirectory in interface EventsStoragepublic void deleteWorkingFile()
EventsStoragedeleteWorkingFile in interface EventsStoragepublic boolean isWorkingFileEmpty()
isWorkingFileEmpty in interface EventsStoragepublic boolean canWorkingFileStore(int newEventSizeInBytes,
int maxByteSizePerFile)
canWorkingFileStore in interface EventsStoragenewEventSizeInBytes - the size in bytes of the event we would like to write to the working filemaxByteSizePerFile - The size in bytes which we will enforce as the maximum for the working filetrue if the new event size will fit in the working file, false if not