MADARA  3.4.1
madara::knowledge::FileRequester Class Reference

A helper class that can reconstruct files or request files be transferred in fragments from a Madara File Service (MFS) More...

#include <FileRequester.h>

Public Member Functions

 FileRequester ()
 Constructor. More...
 
 FileRequester (const std::string &prefix, const std::string &sync_key, const std::string &filename, KnowledgeBase kb, int max_request_fragments=-1)
 Constructor. More...
 
std::vector< int64_t > build_fragment_request (void)
 Builds fragment request to send. More...
 
void clear_fragments (void)
 Clears any lingering file fragments. More...
 
uint32_t get_crc (void)
 Returns the crc of the file. More...
 
std::string get_filename (void)
 Returns the name of the file. More...
 
double get_percent_complete (void)
 Returns the percentage of transfer that is completed. More...
 
size_t get_size (void)
 Returns the size of the file. More...
 
void init (const std::string &prefix, const std::string &sync_key, const std::string &filename, KnowledgeBase kb, int max_request_fragments=-1)
 Initializes the requester. More...
 
void modify (void)
 Remodifies the file size and crc. More...
 
bool needs_request (void)
 Builds fragment request to send. More...
 

Public Attributes

int max_fragments
 the maximum fragments allowed in a resend request More...
 

Private Attributes

containers::Integer file_crc_
 the crc of the file More...
 
containers::Integer file_size_
 the size of the file contents More...
 
std::string filename_
 the name of the file on the hard drive being reconstructed More...
 
knowledge::KnowledgeBase kb_
 saves the kb for general usage More...
 
containers::NativeIntegerVector sync_
 The key that is being synced to. More...
 

Detailed Description

A helper class that can reconstruct files or request files be transferred in fragments from a Madara File Service (MFS)

Definition at line 24 of file FileRequester.h.

Constructor & Destructor Documentation

◆ FileRequester() [1/2]

madara::knowledge::FileRequester::FileRequester ( )
inline

Constructor.

Definition at line 30 of file FileRequester.h.

◆ FileRequester() [2/2]

madara::knowledge::FileRequester::FileRequester ( const std::string &  prefix,
const std::string &  sync_key,
const std::string &  filename,
KnowledgeBase  kb,
int  max_request_fragments = -1 
)
inline

Constructor.

Parameters
prefixthe prefix in the knowledge base that precedes .crc and .size keys (e.g. from MFS)
sync_keythe key in the knowledge base that is used to send sync requests (e.g. to MFS)
filenamethe file that should be recreated from fragments
kbthe knowledge base where the sync key is located at
max_request_fragmentsthe most fragments that can be requested in a single send_modifieds

Definition at line 43 of file FileRequester.h.

Member Function Documentation

◆ build_fragment_request()

std::vector<int64_t> madara::knowledge::FileRequester::build_fragment_request ( void  )
inline

Builds fragment request to send.

Returns
the list of missing fragments for the file

Definition at line 144 of file FileRequester.h.

◆ clear_fragments()

void madara::knowledge::FileRequester::clear_fragments ( void  )
inline

Clears any lingering file fragments.

Definition at line 187 of file FileRequester.h.

◆ get_crc()

uint32_t madara::knowledge::FileRequester::get_crc ( void  )
inline

Returns the crc of the file.

Returns
the crc of the file

Definition at line 89 of file FileRequester.h.

◆ get_filename()

std::string madara::knowledge::FileRequester::get_filename ( void  )
inline

Returns the name of the file.

Returns
the name of the file being streamed

Definition at line 107 of file FileRequester.h.

◆ get_percent_complete()

double madara::knowledge::FileRequester::get_percent_complete ( void  )
inline

Returns the percentage of transfer that is completed.

Returns
the transfer completion percentage

Definition at line 116 of file FileRequester.h.

◆ get_size()

size_t madara::knowledge::FileRequester::get_size ( void  )
inline

Returns the size of the file.

Returns
the size of the file

Definition at line 98 of file FileRequester.h.

◆ init()

void madara::knowledge::FileRequester::init ( const std::string &  prefix,
const std::string &  sync_key,
const std::string &  filename,
KnowledgeBase  kb,
int  max_request_fragments = -1 
)
inline

Initializes the requester.

Parameters
prefixthe prefix in the knowledge base that precedes .crc and .size keys (e.g. from MFS)
sync_keythe key in the knowledge base that is used to send sync requests (e.g. to MFS)
filenamethe file to open and read from
kbthe knowledge base to stream to
max_request_fragmentsthe most fragments that can be requested in a single send_modifieds

Definition at line 61 of file FileRequester.h.

◆ modify()

void madara::knowledge::FileRequester::modify ( void  )
inline

Remodifies the file size and crc.

Definition at line 217 of file FileRequester.h.

◆ needs_request()

bool madara::knowledge::FileRequester::needs_request ( void  )
inline

Builds fragment request to send.

If the return is true, call send_modifieds on the KB to send the request.

Returns
true if a request is necessary, false if file is complete

Definition at line 155 of file FileRequester.h.

Member Data Documentation

◆ file_crc_

containers::Integer madara::knowledge::FileRequester::file_crc_
private

the crc of the file

Definition at line 235 of file FileRequester.h.

◆ file_size_

containers::Integer madara::knowledge::FileRequester::file_size_
private

the size of the file contents

Definition at line 232 of file FileRequester.h.

◆ filename_

std::string madara::knowledge::FileRequester::filename_
private

the name of the file on the hard drive being reconstructed

Definition at line 238 of file FileRequester.h.

◆ kb_

knowledge::KnowledgeBase madara::knowledge::FileRequester::kb_
private

saves the kb for general usage

Definition at line 241 of file FileRequester.h.

◆ max_fragments

int madara::knowledge::FileRequester::max_fragments

the maximum fragments allowed in a resend request

Definition at line 223 of file FileRequester.h.

◆ sync_

containers::NativeIntegerVector madara::knowledge::FileRequester::sync_
private

The key that is being synced to.

Definition at line 229 of file FileRequester.h.


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