Public Member Functions | Private Member Functions | Private Attributes | List of all members
Aws::FileManagement::TokenStore Class Reference

#include <file_manager_strategy.h>

Public Member Functions

std::vector< FileTokenInfobackup ()
 
void backupToDisk ()
 
DataToken createToken (const std::string &file_name, const long streampos, bool is_eof)
 
FileTokenInfo fail (const DataToken &token)
 
bool isTokenAvailable (const std::string &file_name) const
 
FileTokenInfo popAvailableToken (const std::string &file_name)
 
FileTokenInfo resolve (const DataToken &token)
 
void restore (const std::vector< FileTokenInfo > &file_tokens)
 
void restoreFromDisk ()
 
 TokenStore ()=default
 
 TokenStore (const TokenStoreOptions &options)
 

Private Member Functions

void initializeBackupDirectory ()
 
void validateOptions ()
 

Private Attributes

std::unordered_map< std::string, std::list< DataToken > > file_tokens_
 
TokenStoreOptions options_
 
std::random_device rand_device
 
std::unordered_map< std::string, FileTokenInfostaged_tokens_
 
std::unordered_map< DataToken, FileTokenInfotoken_store_
 

Detailed Description

Stores all tokens and manages failed or loaded tokens.

Definition at line 162 of file file_manager_strategy.h.

Constructor & Destructor Documentation

Aws::FileManagement::TokenStore::TokenStore ( )
default
Aws::FileManagement::TokenStore::TokenStore ( const TokenStoreOptions options)
explicit

Definition at line 52 of file file_manager_strategy.cpp.

Member Function Documentation

std::vector< FileTokenInfo > Aws::FileManagement::TokenStore::backup ( )

Backup the first unacked token and all failed tokens into a vector.

Returns
vector to tokens

Definition at line 163 of file file_manager_strategy.cpp.

void Aws::FileManagement::TokenStore::backupToDisk ( )

Backup the token store to a file on disk

Definition at line 176 of file file_manager_strategy.cpp.

DataToken Aws::FileManagement::TokenStore::createToken ( const std::string &  file_name,
const long  streampos,
bool  is_eof 
)

Create a token with the file name, stream position, and whether or not this is the last token in the file.

Parameters
file_name
streampos
is_eof
Returns

Definition at line 111 of file file_manager_strategy.cpp.

FileTokenInfo Aws::FileManagement::TokenStore::fail ( const DataToken token)

Mark a token as failed so the FileManagerStrategy knows to keep the data around.

Parameters
tokento fail
Returns
token info that was failed
Exceptions
std::runtime_errorif token not found

Definition at line 123 of file file_manager_strategy.cpp.

void Aws::FileManagement::TokenStore::initializeBackupDirectory ( )
private

Creates the directory where the token store is backed up to upon shutdown.

Definition at line 61 of file file_manager_strategy.cpp.

bool Aws::FileManagement::TokenStore::isTokenAvailable ( const std::string &  file_name) const

Checks if a token is availa for a specific file

Parameters
file_nameto lookup
Returns
true if a staged token is available to read for that file

Definition at line 69 of file file_manager_strategy.cpp.

FileTokenInfo Aws::FileManagement::TokenStore::popAvailableToken ( const std::string &  file_name)
Parameters
file_nameto lookup
Returns
the file token for that file

Definition at line 73 of file file_manager_strategy.cpp.

FileTokenInfo Aws::FileManagement::TokenStore::resolve ( const DataToken token)

Resolve a token, marking it as complete so the TokenStore can forget about it and its related data.

Parameters
token
Returns
token info which was resolved
Exceptions
std::runtime_errorif token not found

Definition at line 138 of file file_manager_strategy.cpp.

void Aws::FileManagement::TokenStore::restore ( const std::vector< FileTokenInfo > &  file_tokens)

Restore tokens from a vector

Parameters
std::vector<FileTokenInfo>

Definition at line 194 of file file_manager_strategy.cpp.

void Aws::FileManagement::TokenStore::restoreFromDisk ( )

Restore the token store from a file saved to disk

Definition at line 200 of file file_manager_strategy.cpp.

void Aws::FileManagement::TokenStore::validateOptions ( )
private

Ensure that all options are valid. Also sanitizes options that are slightly incorrect.

Definition at line 57 of file file_manager_strategy.cpp.

Member Data Documentation

std::unordered_map<std::string, std::list<DataToken> > Aws::FileManagement::TokenStore::file_tokens_
private

A map of file paths to the tokens that corrospond to that file. So that when all tokens for a file have been resolved the system knows that the file can be deleted

Definition at line 259 of file file_manager_strategy.h.

TokenStoreOptions Aws::FileManagement::TokenStore::options_
private

A struct of options to initialize the token store with

Definition at line 274 of file file_manager_strategy.h.

std::random_device Aws::FileManagement::TokenStore::rand_device
private

A random number generator, used to generate tokens (which are just uint64's)

Definition at line 279 of file file_manager_strategy.h.

std::unordered_map<std::string, FileTokenInfo> Aws::FileManagement::TokenStore::staged_tokens_
private

A map of file paths to the File path and position where the reader is up to. When a token fails to resolve (thus the data failed to upload), it is added to this map. Then in the read function if there is anything in this map it will go to that location in the file and attempt to send it again. It does this first before reading any other data.

Definition at line 269 of file file_manager_strategy.h.

std::unordered_map<DataToken, FileTokenInfo> Aws::FileManagement::TokenStore::token_store_
private

A map of tokens to File Path and Position that the token corrosponds to

Definition at line 252 of file file_manager_strategy.h.


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


file_management
Author(s): AWS RoboMaker
autogenerated on Fri May 7 2021 02:18:23