#include <file_manager_strategy.h>
Manages how files are split up, which files to write to and read when requested.
Definition at line 285 of file file_manager_strategy.h.
Aws::FileManagement::FileManagerStrategy::~FileManagerStrategy |
( |
| ) |
|
|
overridedefault |
void Aws::FileManagement::FileManagerStrategy::addFilePathToStorage |
( |
const std::experimental::filesystem::path & |
file_path | ) |
|
|
private |
Adds a file path to the stored_files_ list
- Parameters
-
file_path | the path to the file |
Definition at line 410 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::checkIfStorageLimitHasBeenReached |
( |
const uintmax_t & |
new_data_size | ) |
|
|
private |
Checks if all the space taken up by offline storage exceeds the setting storage_limit_in_kb. If it has reached that amount it deletes the oldest file from disk.
- Parameters
-
new_data_size | the size of all files on disk in bytes |
Definition at line 452 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::checkIfWriteFileShouldRotate |
( |
const uintmax_t & |
new_data_size | ) |
|
|
private |
Checks if the active_write_file_ size is equal to or greater than maximum_file_size_in_kb in size. If it is then it calls rotateWriteFile.
- Parameters
-
new_data_size | the size of the active_write_file in bytes |
Definition at line 442 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::deleteFile |
( |
const std::string & |
file_path | ) |
|
|
private |
Delete a file at this path. Used when all data from a file has been uploaded successfully or when the offline file storage has reached storage_limit_in_kb
- Parameters
-
file_path | path to the file to be deleted |
Definition at line 383 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::deleteOldestFile |
( |
| ) |
|
|
private |
void Aws::FileManagement::FileManagerStrategy::discoverStoredFiles |
( |
| ) |
|
|
private |
std::string Aws::FileManagement::FileManagerStrategy::getActiveWriteFile |
( |
| ) |
|
|
inlineprotected |
Returns the active write file. Getter used for testing.
- Returns
- the file the system is actively writing to
Definition at line 359 of file file_manager_strategy.h.
std::string Aws::FileManagement::FileManagerStrategy::getFileToRead |
( |
| ) |
|
|
protected |
Returns the next file from storage that should be read from. Prioritizes newest files first.
- Returns
- a path to the file to be read
- Exceptions
-
std::runtime_error | If there are no files available to read |
Definition at line 390 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::initializeStorage |
( |
| ) |
|
|
private |
Initializes the folder that offline data will be saved to, creating it if it doesn't already exist.
Definition at line 250 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::initializeTokenStore |
( |
| ) |
|
|
private |
bool Aws::FileManagement::FileManagerStrategy::isDataAvailable |
( |
| ) |
|
|
overridevirtual |
bool Aws::FileManagement::FileManagerStrategy::isDeleteStaleData |
( |
| ) |
|
|
overridevirtual |
DataToken Aws::FileManagement::FileManagerStrategy::read |
( |
std::string & |
data | ) |
|
|
overridevirtual |
void Aws::FileManagement::FileManagerStrategy::resolve |
( |
const DataToken & |
token, |
|
|
bool |
is_success |
|
) |
| |
|
overridevirtual |
void Aws::FileManagement::FileManagerStrategy::rotateWriteFile |
( |
| ) |
|
|
private |
Moves the active_write_file into stored_files list and creates a new file setting the active_write_file_ to that new file.
Definition at line 415 of file file_manager_strategy.cpp.
bool Aws::FileManagement::FileManagerStrategy::shutdown |
( |
| ) |
|
|
overridevirtual |
Saves all in flight tokens and information out to disk so that on startup the FileManagerStrategy can start reading from the same file location that it was up to previously.
- Returns
- bool whether it shutdown successfully
Reimplemented from Service.
Definition at line 363 of file file_manager_strategy.cpp.
bool Aws::FileManagement::FileManagerStrategy::start |
( |
| ) |
|
|
overridevirtual |
Starts the FileManagerStrategy, this does any initialization I/O tasks required. It is separate from the constructor to keep the construction of this class lightweight. It checks if there are any existing offline storage files on disk, initializes the token store, and ensures there is a new file ready to write to if uploads fail.
- Returns
- bool whether it started successfully or not
Reimplemented from Service.
Definition at line 238 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::validateOptions |
( |
| ) |
|
|
private |
Validates options that were passed to the constructor of this class. Also sanitizes any paths or slightly incorrect options.
Definition at line 246 of file file_manager_strategy.cpp.
void Aws::FileManagement::FileManagerStrategy::write |
( |
const std::string & |
data | ) |
|
|
overridevirtual |
std::string Aws::FileManagement::FileManagerStrategy::active_read_file_ |
|
private |
std::mutex Aws::FileManagement::FileManagerStrategy::active_read_file_mutex_ |
|
private |
A lock on the active read file, to ensure that it does not get deleted while it is being read from.
Definition at line 467 of file file_manager_strategy.h.
std::unique_ptr<std::ifstream> Aws::FileManagement::FileManagerStrategy::active_read_file_stream_ |
|
private |
An IOStream for the active_read_file. Kept open so that it's easy to move to the next point in the file with each read instead of continually opening a new stream each time.
Definition at line 461 of file file_manager_strategy.h.
std::string Aws::FileManagement::FileManagerStrategy::active_write_file_ |
|
private |
Path to the file we're currently writing to. This file cannot be read from or deleted.
Definition at line 438 of file file_manager_strategy.h.
std::mutex Aws::FileManagement::FileManagerStrategy::active_write_file_mutex_ |
|
private |
A lock on the active write file, to ensure that when it's rotated nothing is writing to it at the same time.
Definition at line 449 of file file_manager_strategy.h.
std::atomic<size_t> Aws::FileManagement::FileManagerStrategy::active_write_file_size_ {} |
|
private |
std::list<std::string> Aws::FileManagement::FileManagerStrategy::stored_files_ |
|
private |
std::atomic<size_t> Aws::FileManagement::FileManagerStrategy::stored_files_size_ {} |
|
private |
Disk space used by all stored files. Does not include active_write_file_size_.
Definition at line 433 of file file_manager_strategy.h.
std::unique_ptr<TokenStore> Aws::FileManagement::FileManagerStrategy::token_store_ |
|
private |
The documentation for this class was generated from the following files: