#include <octopus.h>
Inheritance diagram for octopus:


Public Member Functions | |
| octopus (const istring &name, int max_size_per_entity) | |
| constructs an octopus named "name". | |
| virtual | ~octopus () |
| IMPLEMENT_CLASS_NAME ("octopus") | |
| const istring & | name () const |
| returns the name that the octopus was constructed with. | |
| outcome | add_tentacle (tentacle *to_add, bool filter=false) |
| hooks a tentacle in to provide processing of one type of infoton. | |
| outcome | remove_tentacle (const string_array &group_name, tentacle *&free_me) |
| removes the tentacle listed for the "group_name", if any. | |
| outcome | zap_tentacle (const string_array &group_name) |
| similar to remove_tentacle(), but destroys the tentacle. | |
| octopus_entity | issue_identity () |
| creates an entity identifier that is unique for this octopus. | |
| void | expunge (const octopus_entity &to_remove) |
| invokes every tentacle's expunge() method on the id "to_remove". | |
| entity_data_bin & | responses () |
| allows external access to our set of results. | |
| outcome | restore (const string_array &classifier, byte_array &packed_form, infoton *&reformed) |
| regenerates a packed infoton given its classifier. | |
| outcome | evaluate (infoton *request, const octopus_request_id &item_id, bool now=false) |
| tries to process the "request" using the current set of tentacles. | |
| infoton * | acquire_result (const octopus_entity &requester, octopus_request_id &original_id) |
| acquires responses to previous requests if there are any waiting. | |
| infoton * | acquire_specific_result (const octopus_request_id &original_id) |
| supports seeking the result for a specific request. | |
| tentacle * | lock_tentacle (const string_array &tentacle_name) |
| locates the tentacle with the "tentacle_name" and returns it. | |
| void | unlock_tentacle (tentacle *to_unlock) |
| unlocks the octopus when given a previously locked tentacle. | |
| void | lock_tentacles () |
| locks the tentacle list for use with locked_get_tentacle. | |
| int | locked_tentacle_count () |
| number of tentacles. | |
| tentacle * | locked_get_tentacle (int indy) |
| access indy'th tentacle. | |
| void | unlock_tentacles () |
| unlocks the list. | |
| void | periodic_cleaning () |
| flushes any abandoned data from the response bin. | |
Octopus is a plug-in module manager that can serve as the base for highly extensible program architectures. Each module is called a tentacle, following the conceit of the naming conventions, and it services one type of request. The requests come in the form of infoton objects, where the tentacle that handles each class of infotons is uniquely identifiable. Note that the outcomes returned here are from the tentacle's set of outcomes.
Definition at line 46 of file octopus.h.
| octopus::octopus | ( | const istring & | name, | |
| int | max_size_per_entity | |||
| ) |
constructs an octopus named "name".
the "name" string identifies the arena where this octopus is running. this could be a network host or other identification string. the "max_size_per_entity" is the largest that we allow one entity's bin of pending data to be. this should be quite large if massive transactions need to be processed.
Definition at line 134 of file octopus.cpp.
References add_tentacle().
| octopus::~octopus | ( | ) | [virtual] |
| octopus::IMPLEMENT_CLASS_NAME | ( | "octopus" | ) |
| const istring & octopus::name | ( | ) | const |
hooks a tentacle in to provide processing of one type of infoton.
lists the tentacle "to_add" as being responsible for handling requests for the tentacle's group(). note that the octopus takes over control of the "to_add" pointer; do not destroy that pointer independently, and do not use the tentacle after adding it to the octopus unless the tentacle is thread-safe. the add will replace an existing tentacle if it was already registered under the same group name. if the "filter" flag is enabled, then this tentacle is considered a filter; it will be consulted on all infotons before they are processed. filters will be invoked in the order that they are added.
Definition at line 245 of file octopus.cpp.
References tentacle::ALREADY_EXISTS, tentacle::attach_storage(), tentacle::BAD_INPUT, FUNCDEF, GRAB_LOCK, tentacle::group(), array< contents >::length(), LOG, tentacle::OKAY, string_array::text_form(), and zap_tentacle().
Referenced by list_synchronizer::add_list(), cromp_common::add_tentacle(), recursive_file_copy::copy_hierarchy(), and octopus().
| outcome octopus::remove_tentacle | ( | const string_array & | group_name, | |
| tentacle *& | free_me | |||
| ) |
removes the tentacle listed for the "group_name", if any.
"free_me" provides the means for getting back what was originally registered. NOTE: remember to destroy "free_me" if that's appropriate (i.e. it was dynamically allocated, has no other users and no other entity has responsibility for it).
Definition at line 271 of file octopus.cpp.
References tentacle::BAD_INPUT, object_base::class_name(), continuable_error, FUNCDEF, array< contents >::length(), mutex_base::lock(), negative(), NIL, tentacle::NOT_FOUND, tentacle::OKAY, portable::sleep_ms(), mutex_base::unlock(), and WHACK().
Referenced by zap_tentacle().
| outcome octopus::zap_tentacle | ( | const string_array & | group_name | ) |
similar to remove_tentacle(), but destroys the tentacle.
Definition at line 237 of file octopus.cpp.
References NIL, remove_tentacle(), and WHACK().
Referenced by add_tentacle(), and list_synchronizer::zap_list().
| octopus_entity octopus::issue_identity | ( | ) |
creates an entity identifier that is unique for this octopus.
this provides a unique identity using the "name" specified in the constructor and the current process id. the sequence number and random add_in are generated by this class also.
Definition at line 517 of file octopus.cpp.
References chaos::inclusive(), MAXINT, safe_roller::next_id(), and portable::process_id().
Referenced by identity_tentacle::consume(), and recursive_file_copy::copy_hierarchy().
| void octopus::expunge | ( | const octopus_entity & | to_remove | ) |
invokes every tentacle's expunge() method on the id "to_remove".
this indicates that the entity is no longer extant and resources held for it can be destroyed.
Definition at line 192 of file octopus.cpp.
References entity_data_bin::acquire_for_entity(), FUNCDEF, GRAB_LOCK, LOG, octopus_entity::mangled_form(), MAXIMUM_TRASH_SIZE, and responses().
| entity_data_bin & octopus::responses | ( | ) |
allows external access to our set of results.
this should not be used unless you know what you're doing.
Definition at line 170 of file octopus.cpp.
Referenced by expunge(), cromp_server::get_sizes(), cromp_common::max_bytes_per_entity(), and cromp_server::responses_text_form().
| outcome octopus::restore | ( | const string_array & | classifier, | |
| byte_array & | packed_form, | |||
| infoton *& | reformed | |||
| ) |
regenerates a packed infoton given its classifier.
locates the appropriate type of infoton with the "classifier" and consumes the bytes in "packed_form" to return a new version of the original data in "reformed", if possible.
Definition at line 310 of file octopus.cpp.
References tentacle::BAD_INPUT, FUNCDEF, GRAB_LOCK, array< contents >::length(), LOG, NIL, tentacle::NOT_FOUND, periodic_cleaning(), tentacle::reconstitute(), and string_array::text_form().
Referenced by cromp_client::decrypt_package_as_needed(), and evaluate().
| outcome octopus::evaluate | ( | infoton * | request, | |
| const octopus_request_id & | item_id, | |||
| bool | now = false | |||
| ) |
tries to process the "request" using the current set of tentacles.
if there is no group handler for the "request", then NO_HANDLER will be returned. the classifier for "request" specifies the group name for processing. NOTE: the octopus assumes all responsibility for the "request", even if the outcome denotes failure; do not touch the "request" after this call. if the "request" will be processed further by lower level octopi, then the classifier can be patched as appropriate. the "item_id" must be maintained with the request in order to identify the entity making the request and the sequence number of this particular request. the "now" parameter specifies whether the processing must occur immediately; if false, the processing will occur later when the tentacle get around to it. if "now" is true, there is more load on the octopus itself. note that "now" is ignored if the tentacle does not support backgrounding; true is always assumed for that case.
Definition at line 341 of file octopus.cpp.
References tentacle::backgrounding(), tentacle::BAD_INPUT, infoton::classifier(), tentacle::consume(), tentacle::enqueue(), infoton::fast_unpack(), FUNCDEF, GRAB_LOCK, array< contents >::length(), mutex_base::lock(), LOG, NIL, tentacle::NOT_FOUND, tentacle::OKAY, tentacle::outcome_name(), tentacle::PARTIAL, periodic_cleaning(), restore(), string_array::text_form(), object_base::text_form(), mutex_base::unlock(), WHACK(), and WHACK_RETURN.
Referenced by recursive_file_copy::copy_hierarchy().
| infoton * octopus::acquire_result | ( | const octopus_entity & | requester, | |
| octopus_request_id & | original_id | |||
| ) |
acquires responses to previous requests if there are any waiting.
it returns an infoton for the "requester", if any are available. call this function repeatedly to ensure that all responses have been provided. the "original_id" is a copy of the "item_id" that was originally passed to evaluate_request(). the returned object must eventually be destroyed if non-NIL.
Definition at line 182 of file octopus.cpp.
References entity_data_bin::acquire_for_entity().
| infoton * octopus::acquire_specific_result | ( | const octopus_request_id & | original_id | ) |
supports seeking the result for a specific request.
either the infoton that is a response to "original_id" will be returned or NIL.
Definition at line 179 of file octopus.cpp.
References entity_data_bin::acquire_for_identifier().
Referenced by recursive_file_copy::copy_hierarchy().
| tentacle * octopus::lock_tentacle | ( | const string_array & | tentacle_name | ) |
locates the tentacle with the "tentacle_name" and returns it.
the octopus will stay locked until the unlock_tentacle() method is invoked.
Definition at line 505 of file octopus.cpp.
References array< contents >::length(), mutex_base::lock(), NIL, and mutex_base::unlock().
| void octopus::unlock_tentacle | ( | tentacle * | to_unlock | ) |
unlocks the octopus when given a previously locked tentacle.
this must be the same object that was obtained via the lock_tentacle() method.
Definition at line 186 of file octopus.cpp.
References NIL, and mutex_base::unlock().
| void octopus::lock_tentacles | ( | ) |
locks the tentacle list for use with locked_get_tentacle.
Definition at line 166 of file octopus.cpp.
References mutex_base::lock().
Referenced by list_synchronizer::clean(), and list_synchronizer::update().
| int octopus::locked_tentacle_count | ( | ) |
number of tentacles.
Definition at line 172 of file octopus.cpp.
Referenced by list_synchronizer::clean(), and list_synchronizer::update().
| tentacle * octopus::locked_get_tentacle | ( | int | indy | ) |
access indy'th tentacle.
Definition at line 176 of file octopus.cpp.
Referenced by list_synchronizer::clean(), and list_synchronizer::update().
| void octopus::unlock_tentacles | ( | ) |
unlocks the list.
Definition at line 168 of file octopus.cpp.
References mutex_base::unlock().
Referenced by list_synchronizer::clean(), and list_synchronizer::update().
| void octopus::periodic_cleaning | ( | ) |
flushes any abandoned data from the response bin.
Definition at line 488 of file octopus.cpp.
References entity_data_bin::clean_out_deadwood(), FUNCDEF, OCTOPUS_CHECKING_INTERVAL, and time_stamp::reset().
Referenced by evaluate(), and restore().
1.5.1