octopi::file_transfer_tentacle Class Reference

Manages the transferrence of directory trees from one place to another. More...

#include <file_transfer_tentacle.h>

Inheritance diagram for octopi::file_transfer_tentacle:
Inheritance graph
[legend]
Collaboration diagram for octopi::file_transfer_tentacle:
Collaboration graph
[legend]

List of all members.

Public Types

enum  transfer_modes { ONLY_REPORT_DIFFS = 0x1, COMPARE_SIZE_AND_TIME = 0x2, COMPARE_CONTENT_SAMPLE = 0x4, COMPARE_ALL = 0x6 }

Public Member Functions

 file_transfer_tentacle (int maximum_transfer, transfer_modes mode_of_transfer)
 constructs a tentacle for either transfers or comparisons.
virtual ~file_transfer_tentacle ()
 DEFINE_CLASS_NAME ("file_transfer_tentacle")
basis::astring text_form () const
 returns a string representing the current state of transfers.
filesystem::directory_treelock_directory (const basis::astring &source_mapping)
 provides a view of the tentacle's current state.
void unlock_directory ()
 unlock MUST be called when one is done looking at the tree.
basis::outcome add_correspondence (const basis::astring &source_mapping, const basis::astring &source_root, int refresh_interval)
 adds a file transfer correspondence.
basis::outcome remove_correspondence (const basis::astring &source_mapping)
 takes out the "source_mapping" which was previously added.
basis::outcome refresh_now (const basis::astring &source_mapping)
 refreshes the "source_mapping" right now, regardless of the interval.
bool add_path (const basis::astring &source_mapping, const basis::astring &new_path)
 inserts the "new_path" into a registered correspondence.
bool remove_path (const basis::astring &source_mapping, const basis::astring &old_path)
 deletes the "old_path" out of an existing correspondence.
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.
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.
bool 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.
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.
virtual basis::outcome reconstitute (const structures::string_array &classifier, basis::byte_array &packed_form, infoton *&reformed)
 recreates a "reformed" infoton from its packed form.
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.
virtual void expunge (const octopus_entity &to_remove)
 throws out any transfers occurring for the entity "to_remove".
void periodic_actions ()
 drops timed out transfers.

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
ONLY_REPORT_DIFFS 

no actual file transfer, just reports.

COMPARE_SIZE_AND_TIME 

uses size and time to see differences.

COMPARE_CONTENT_SAMPLE 

samples parts of file for comparison.

COMPARE_ALL 

compares all of the file size, file time, and contents.

Definition at line 43 of file file_transfer_tentacle.h.


Constructor & Destructor Documentation

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 217 of file file_transfer_tentacle.cpp.

References NIL.

octopi::file_transfer_tentacle::~file_transfer_tentacle (  )  [virtual]

Definition at line 231 of file file_transfer_tentacle.cpp.

References basis::WHACK().


Member Function Documentation

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 253 of file file_transfer_tentacle.cpp.

References AUTO_LOCK, FUNCDEF, LOG, 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.

outcome octopi::file_transfer_tentacle::consume ( infoton to_chow,
const octopus_request_id item_id,
basis::byte_array transformed 
) [virtual]
octopi::file_transfer_tentacle::DEFINE_CLASS_NAME ( "file_transfer_tentacle"   ) 
void octopi::file_transfer_tentacle::expunge ( const octopus_entity to_remove  )  [virtual]

throws out any transfers occurring for the entity "to_remove".

Implements octopi::tentacle.

Definition at line 246 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, 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(), NIL, 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, octopi::TRANSFER_TIMEOUT, and basis::WHACK().

outcome octopi::file_transfer_tentacle::reconstitute ( const structures::string_array classifier,
basis::byte_array packed_form,
infoton *&  reformed 
) [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 452 of file file_transfer_tentacle.cpp.

References octopi::file_transfer_infoton::file_transfer_classifier(), NIL, octopi::tentacle::NO_HANDLER, 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 739 of file file_transfer_tentacle.cpp.

References AUTO_LOCK, FUNCDEF, LOG, octopi::tentacle::NOT_FOUND, octopi::tentacle::OKAY, 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 343 of file file_transfer_tentacle.cpp.

References AUTO_LOCK.

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 294 of file file_transfer_tentacle.cpp.

References AUTO_LOCK.

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.

References AUTO_LOCK.

astring octopi::file_transfer_tentacle::text_form (  )  const

returns a string representing the current state of transfers.

Definition at line 240 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().


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:48 2012 for hoople2 project by  doxygen 1.6.3