feisty meow concerns codebase
2.140
|
Manages the transferrence of directory trees from one place to another. More...
#include <file_transfer_tentacle.h>
Public Types | |
enum | transfer_modes { ONLY_REPORT_DIFFS = 0x1 , COMPARE_SIZE_AND_TIME = 0x2 , COMPARE_CONTENT_SAMPLE = 0x4 , COMPARE_ALL = 0x6 } |
Public Types inherited from octopi::tentacle | |
enum | constants { DEFAULT_RATE = 40 } |
enum | outcomes { OKAY = basis::common::OKAY , NOT_FOUND = basis::common::NOT_FOUND , ALREADY_EXISTS = basis::common::EXISTING , BAD_INPUT = basis::common::BAD_INPUT , NO_SPACE = basis::common::NO_SPACE , GARBAGE = basis::common::GARBAGE , DISALLOWED = basis::common::DISALLOWED , NO_HANDLER = basis::common::NO_HANDLER , PARTIAL = basis::common::PARTIAL , ENCRYPTION_MISMATCH = basis::common::ENCRYPTION_MISMATCH } |
Public Member Functions | |
file_transfer_tentacle (int maximum_transfer, transfer_modes mode_of_transfer) | |
constructs a tentacle for either transfers or comparisons. More... | |
virtual | ~file_transfer_tentacle () |
DEFINE_CLASS_NAME ("file_transfer_tentacle") | |
basis::astring | text_form () const |
returns a string representing the current state of transfers. More... | |
filesystem::directory_tree * | lock_directory (const basis::astring &source_mapping) |
provides a view of the tentacle's current state. More... | |
void | unlock_directory () |
unlock MUST be called when one is done looking at the tree. More... | |
basis::outcome | add_correspondence (const basis::astring &source_mapping, const basis::astring &source_root, int refresh_interval) |
adds a file transfer correspondence. More... | |
basis::outcome | remove_correspondence (const basis::astring &source_mapping) |
takes out the "source_mapping" which was previously added. More... | |
basis::outcome | refresh_now (const basis::astring &source_mapping) |
refreshes the "source_mapping" right now, regardless of the interval. More... | |
bool | add_path (const basis::astring &source_mapping, const basis::astring &new_path) |
inserts the "new_path" into a registered correspondence. More... | |
bool | remove_path (const basis::astring &source_mapping, const basis::astring &old_path) |
deletes the "old_path" out of an existing correspondence. More... | |
basis::outcome | register_file_transfer (const octopus_entity &ent, const basis::astring &src_root, const basis::astring &dest_root, const structures::string_array &include) |
records a transfer that is going to commence. More... | |
basis::outcome | cancel_file_transfer (const octopus_entity &ent, const basis::astring &src_root, const basis::astring &dest_root) |
tosses a previously registered file transfer. More... | |
bool | status (const octopus_entity &ent, const basis::astring &src, const basis::astring &dest, double &total_size, int &total_files, double ¤t_size, int ¤t_files, bool &done, timely::time_stamp &last_active) |
locates the transfer specified and returns information about it. More... | |
bool | get_differences (const octopus_entity &ent, const basis::astring &src, const basis::astring &dest, filesystem::filename_list &diffs) |
accesses the list of difference for an ongoing transfer. More... | |
virtual basis::outcome | reconstitute (const structures::string_array &classifier, basis::byte_array &packed_form, infoton *&reformed) |
recreates a "reformed" infoton from its packed form. More... | |
virtual basis::outcome | consume (infoton &to_chow, const octopus_request_id &item_id, basis::byte_array &transformed) |
processes the "to_chow" infoton as a file transfer request. More... | |
virtual void | expunge (const octopus_entity &to_remove) |
throws out any transfers occurring for the entity "to_remove". More... | |
void | periodic_actions () |
drops timed out transfers. More... | |
Public Member Functions inherited from octopi::tentacle_helper< file_transfer_infoton > | |
tentacle_helper (const structures::string_array &classifier, bool backgrounded, int motivational_rate=tentacle::DEFAULT_RATE) | |
virtual | ~tentacle_helper () |
force a virtual destructor. More... | |
virtual basis::outcome | consume (infoton &formal(to_chow), const octopus_request_id &formal(item_id), basis::byte_array &transformed) |
consume is not really provided here. remember to implement for servers! More... | |
virtual void | expunge (const octopus_entity &formal(to_remove)) |
no general actions for expunge; they are all class-specific. More... | |
Public Member Functions inherited from octopi::tentacle | |
tentacle (const structures::string_array &group_name, bool backgrounded, int motivational_rate=tentacle::DEFAULT_RATE) | |
constructs a tentacle that handles infotons with the "group_name". More... | |
virtual | ~tentacle () |
DEFINE_CLASS_NAME ("tentacle") | |
const structures::string_array & | group () const |
returns the name of the group that this tentacle services. More... | |
bool | backgrounding () const |
reports on whether this tentacle supports background operation or not. More... | |
int | motivational_rate () const |
returns the background processing rate this was constructed with. More... | |
basis::outcome | enqueue (infoton *to_chow, const octopus_request_id &item_id) |
holds onto infotons coming from the octopus for backgrounding. More... | |
infoton * | next_request (octopus_request_id &item_id) |
pops out the next queued request for processing. More... | |
bool | store_product (infoton *product, const octopus_request_id &original_id) |
used by tentacles to store the objects they produce from infotons. More... | |
void | attach_storage (entity_data_bin &storage) |
used when a tentacle is being integrated with an octopus. More... | |
void | detach_storage () |
unhooks the storage bin from this tentacle. More... | |
entity_data_bin * | get_storage () |
returns the current pointer, which might be nil. More... | |
void | propel_arm () |
invoked by our thread to cause requests to be processed. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from octopi::tentacle | |
static const char * | outcome_name (const basis::outcome &to_name) |
returns the textual form of the outcome "to_name". More... | |
Manages the transferrence of directory trees from one place to another.
Note: this is a fairly heavy-weight header due to the inclusion of the file transfer infoton header. It is better to forward declare the objects in both file transfer headers when using the types in other headers.
Definition at line 39 of file file_transfer_tentacle.h.
Definition at line 43 of file file_transfer_tentacle.h.
octopi::file_transfer_tentacle::file_transfer_tentacle | ( | int | maximum_transfer, |
file_transfer_tentacle::transfer_modes | mode_of_transfer | ||
) |
constructs a tentacle for either transfers or comparisons.
the "maximum_transfer" is the largest chunk of data we will try to sling across the network at a time. the "mode_of_transfer" selects how to perform the operation. if "ONLY_REPORT_DIFFS" is set, then there will only be a report of differences and no files will be copied. if COMPARE_SIZE_AND_TIME is set, then the comparison will use the file's size and its access time for determining if it has changed. if the COMPARE_CONTENT_SAMPLE flag is set, then the file will be sampled at some key locations and that will decide differences. the comparison modes can be mixed together. if there are no comparison modes, then the files will always be copied.
Definition at line 219 of file file_transfer_tentacle.cpp.
References NULL_POINTER.
|
virtual |
Definition at line 233 of file file_transfer_tentacle.cpp.
References basis::WHACK().
outcome octopi::file_transfer_tentacle::add_correspondence | ( | const basis::astring & | source_mapping, |
const basis::astring & | source_root, | ||
int | refresh_interval | ||
) |
adds a file transfer correspondence.
this is a "source_mapping" which is a short string that is made available to the other side for transfer requests. when they specify the "source_mapping", it will be translated on this side to the "source_root", which must be a valid filesystem path. the "refresh_interval" dictates how frequently, in milliseconds, the source will be scanned to update the internal directory tree. this is done the first time the "source_mapping" is set up also. if a previous identical "source_mapping" existed, then it is removed and replaced with the information from the new invocation.
Definition at line 254 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, COMPARE_CONTENT_SAMPLE, FUNCDEF, LOG, octopi::tentacle::OKAY, remove_correspondence(), basis::astring::text_form(), and basis::WHACK().
Referenced by octopi::recursive_file_copy::copy_hierarchy().
bool octopi::file_transfer_tentacle::add_path | ( | const basis::astring & | source_mapping, |
const basis::astring & | new_path | ||
) |
inserts the "new_path" into a registered correspondence.
the "source_mapping" must already be registered.
Definition at line 389 of file file_transfer_tentacle.cpp.
References AUTO_LOCK.
outcome octopi::file_transfer_tentacle::cancel_file_transfer | ( | const octopus_entity & | ent, |
const basis::astring & | src_root, | ||
const basis::astring & | dest_root | ||
) |
tosses a previously registered file transfer.
this will be done automatically after a time-out period, but it is better to clean it up as soon as one is finished with the transfer.
Definition at line 366 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, octopi::tentacle::NOT_FOUND, and octopi::tentacle::OKAY.
|
virtual |
processes the "to_chow" infoton as a file transfer request.
Implements octopi::tentacle.
Definition at line 879 of file file_transfer_tentacle.cpp.
References octopi::file_transfer_infoton::_command, octopi::file_transfer_infoton::_request, AUTO_LOCK, octopi::tentacle::BAD_INPUT, octopi::file_transfer_infoton::BUILD_TARGET_TREE, octopi::file_transfer_infoton::CONCLUDE_TRANSFER_MARKER, octopi::tentacle::DISALLOWED, FUNCDEF, octopi::file_transfer_infoton::PLACE_FILE_CHUNKS, basis::array< contents >::reset(), and octopi::file_transfer_infoton::TREE_COMPARISON.
octopi::file_transfer_tentacle::DEFINE_CLASS_NAME | ( | "file_transfer_tentacle" | ) |
|
virtual |
throws out any transfers occurring for the entity "to_remove".
Implements octopi::tentacle.
Definition at line 248 of file file_transfer_tentacle.cpp.
References AUTO_LOCK.
bool octopi::file_transfer_tentacle::get_differences | ( | const octopus_entity & | ent, |
const basis::astring & | src, | ||
const basis::astring & | dest, | ||
filesystem::filename_list & | diffs | ||
) |
accesses the list of difference for an ongoing transfer.
the progress is stored in "diffs".
Definition at line 302 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, FUNCDEF, and structures::amorph< contents >::reset().
directory_tree * octopi::file_transfer_tentacle::lock_directory | ( | const basis::astring & | source_mapping | ) |
provides a view of the tentacle's current state.
Definition at line 373 of file file_transfer_tentacle.cpp.
References basis::mutex::lock(), NULL_POINTER, and basis::mutex::unlock().
void octopi::file_transfer_tentacle::periodic_actions | ( | ) |
drops timed out transfers.
Definition at line 409 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, COMPARE_CONTENT_SAMPLE, FUNCDEF, LOG, basis::astring::text_form(), octopi::TRANSFER_TIMEOUT, and basis::WHACK().
|
virtual |
recreates a "reformed" infoton from its packed form.
this requires the "classifier" and packed infoton data in "packed_form". this will only succeed if the classifier's first name is understood here.
Reimplemented from octopi::tentacle_helper< file_transfer_infoton >.
Definition at line 450 of file file_transfer_tentacle.cpp.
References octopi::file_transfer_infoton::file_transfer_classifier(), octopi::tentacle::NO_HANDLER, NULL_POINTER, and octopi::reconstituter().
outcome octopi::file_transfer_tentacle::refresh_now | ( | const basis::astring & | source_mapping | ) |
refreshes the "source_mapping" right now, regardless of the interval.
the mapping must already have been created with add_correspondence().
Definition at line 910 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, COMPARE_CONTENT_SAMPLE, FUNCDEF, LOG, octopi::tentacle::NOT_FOUND, octopi::tentacle::OKAY, basis::astring::text_form(), and basis::WHACK().
outcome octopi::file_transfer_tentacle::register_file_transfer | ( | const octopus_entity & | ent, |
const basis::astring & | src_root, | ||
const basis::astring & | dest_root, | ||
const structures::string_array & | include | ||
) |
records a transfer that is going to commence.
the side that wishes to download files must invoke this before starting the transfer. if the "include" list is not empty, then only those files will be transferred. they have to match the suffix of the files that would have been transferred and wildcards are not currently supported.
Definition at line 342 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, FUNCDEF, octopi::tentacle::OKAY, and basis::array< contents >::reset().
Referenced by octopi::recursive_file_copy::copy_hierarchy().
outcome octopi::file_transfer_tentacle::remove_correspondence | ( | const basis::astring & | source_mapping | ) |
takes out the "source_mapping" which was previously added.
this keeps any transfers from occurring on that name, and will cause aborted transfers if any were still ongoing.
Definition at line 293 of file file_transfer_tentacle.cpp.
References AUTO_LOCK, octopi::tentacle::NOT_FOUND, and octopi::tentacle::OKAY.
Referenced by add_correspondence().
bool octopi::file_transfer_tentacle::remove_path | ( | const basis::astring & | source_mapping, |
const basis::astring & | old_path | ||
) |
deletes the "old_path" out of an existing correspondence.
Definition at line 399 of file file_transfer_tentacle.cpp.
References AUTO_LOCK.
bool octopi::file_transfer_tentacle::status | ( | const octopus_entity & | ent, |
const basis::astring & | src, | ||
const basis::astring & | dest, | ||
double & | total_size, | ||
int & | total_files, | ||
double & | current_size, | ||
int & | current_files, | ||
bool & | done, | ||
timely::time_stamp & | last_active | ||
) |
locates the transfer specified and returns information about it.
the transfer is designated by the "ent", "src" and "dest" parameters and returns the current progress. files refers to how many files are being transferred and size refers to their combined weight in bytes. the "done" flag is set if the transfer seems finished. note that this will not set any values until the first reply comes back from the server.
Definition at line 315 of file file_transfer_tentacle.cpp.
astring octopi::file_transfer_tentacle::text_form | ( | ) | const |
returns a string representing the current state of transfers.
Definition at line 242 of file file_transfer_tentacle.cpp.
References AUTO_LOCK.
void octopi::file_transfer_tentacle::unlock_directory | ( | ) |
unlock MUST be called when one is done looking at the tree.
Definition at line 384 of file file_transfer_tentacle.cpp.
References basis::mutex::unlock().