#include <Reconnection_Registry.h>
Inheritance diagram for TAO_Notify::Reconnection_Registry:


Public Member Functions | |
| Reconnection_Registry (Topology_Parent &parent) | |
| Constructor. | |
| virtual | ~Reconnection_Registry () |
| Destructor. | |
| ::NotifyExt::ReconnectionRegistry::ReconnectionID | register_callback (::NotifyExt::ReconnectionCallback_ptr callback) |
| add a new callback to the registry | |
| void | unregister_callback (::NotifyExt::ReconnectionRegistry::ReconnectionID id) |
| CORBA::Boolean | is_alive () |
| virtual void | save_persistent (Topology_Saver &saver) |
| virtual Topology_Object * | load_child (const ACE_CString &type, CORBA::Long id, const NVPList &attrs) |
| Create a child of the appropriate type and return it. | |
| void | send_reconnect (CosNotifyChannelAdmin::EventChannelFactory_ptr dest_factory) |
Private Types | |
| typedef ACE_Hash_Map_Manager_Ex< NotifyExt::ReconnectionRegistry::ReconnectionID, ACE_CString, ACE_Hash< NotifyExt::ReconnectionRegistry::ReconnectionID >, ACE_Equal_To< NotifyExt::ReconnectionRegistry::ReconnectionID >, ACE_SYNCH_NULL_MUTEX > | Reconnection_Registry_Type |
| The registry consists of a map from ReconnectionID to stringified IOR. | |
Private Member Functions | |
| void | release (void) |
| The release method is called when the refcount reaches 0. | |
Private Attributes | |
| Reconnection_Registry_Type | reconnection_registry_ |
| ::NotifyExt::ReconnectionRegistry::ReconnectionID | highest_id_ |
Definition at line 42 of file Reconnection_Registry.h.
|
|
The registry consists of a map from ReconnectionID to stringified IOR.
Definition at line 50 of file Reconnection_Registry.h. |
|
|
Constructor.
Definition at line 31 of file Reconnection_Registry.cpp.
00032 : highest_id_(0) 00033 { 00034 // not the best technique, here. Take advantage of "protected" 00035 Topology_Object::topology_parent_ = &parent; 00036 } |
|
|
Destructor.
Definition at line 38 of file Reconnection_Registry.cpp.
00039 {
00040 }
|
|
|
Definition at line 96 of file Reconnection_Registry.cpp. References CORBA::Boolean.
00097 {
00098 return CORBA::Boolean(1);
00099 }
|
|
||||||||||||||||
|
Create a child of the appropriate type and return it. Use "type" as passed in to determine what kind of child (supporting the Topology_Object interface) to create and return. Inform it of its new ID. Reimplemented from TAO_Notify::Topology_Object. Definition at line 148 of file Reconnection_Registry.cpp. References ACE_CString, ACE_DEBUG, ACE_ERROR, ACE_TEXT(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), DEBUG_LEVEL, highest_id_, LM_DEBUG, LM_ERROR, TAO_Notify::RECONNECT_ID, TAO_Notify::RECONNECT_IOR, reconnection_registry_, and TAO_Notify::REGISTRY_CALLBACK_TYPE.
00152 {
00153 if (type == REGISTRY_CALLBACK_TYPE)
00154 {
00155 NotifyExt::ReconnectionRegistry::ReconnectionID id;
00156 ACE_CString ior;
00157 if (attrs.load (RECONNECT_ID, id) && attrs.load (RECONNECT_IOR, ior))
00158 {
00159 if (id > highest_id_)
00160 {
00161 highest_id_ = id;
00162
00163 if (DEBUG_LEVEL > 0)
00164 {
00165 ACE_DEBUG ((LM_DEBUG,
00166 ACE_TEXT ("(%P|%t) Reconnect registry: reloading %d\n"),
00167 static_cast<int> (id)
00168 ));
00169 }
00170 }
00171 if ( 0 != reconnection_registry_.bind (id, ior))
00172 {
00173 //@@todo - throw something;
00174 }
00175 }
00176 else
00177 {
00178 ACE_ERROR ((LM_ERROR,
00179 ACE_TEXT ("(%P|%t) Reconnect registry: missing attribute\n")
00180 ));
00181 }
00182 }
00183 return this;
00184 }
|
|
|
add a new callback to the registry
Definition at line 46 of file Reconnection_Registry.cpp. References ACE_CHECK_RETURN, ACE_CString, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TEXT(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), DEBUG_LEVEL, highest_id_, TAO_Singleton< TYPE, ACE_LOCK >::instance(), LM_DEBUG, TAO_Notify_Properties::orb(), reconnection_registry_, and TAO_Notify::Topology_Object::self_change().
00049 {
00050 //@@todo DO WE NEED THREAD SAFENESS?
00051 NotifyExt::ReconnectionRegistry::ReconnectionID next_id = ++highest_id_;
00052
00053 if (DEBUG_LEVEL > 0)
00054 {
00055 ACE_DEBUG ((LM_DEBUG,
00056 ACE_TEXT ("(%P|%t) Reconnect registry: registering %d\n"),
00057 static_cast<int> (next_id)
00058 ));
00059 }
00060 TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
00061 CORBA::ORB_var orb = properties->orb ();
00062
00063 CORBA::String_var cior = orb->object_to_string (callback ACE_ENV_ARG_PARAMETER);
00064 ACE_CHECK_RETURN (0);
00065 ACE_CString ior(cior.in ());
00066 if ( 0 != reconnection_registry_.bind (next_id, ior))
00067 {
00068 //todo throw something;
00069 }
00070 this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00071 ACE_CHECK_RETURN (0);
00072
00073 return next_id;
00074 }
|
|
|
The release method is called when the refcount reaches 0.
Implements TAO_Notify_Refcountable. Definition at line 249 of file Reconnection_Registry.cpp.
00250 {
00251 delete this;
00252 //@@ inform factory
00253 }
|
|
|
Save our state to a Topology_Saver. Use the methods of a Topology_Saver to store all information we want persisted. This function is called by our parent, which gives us a saver to use. In turn, we must call this function on all of our children. The implementation should look like: bool change = this->self_changed_; this->self_changed_ = false; this->children_changed_ = false; if (is_persistent ()) { bool want_all_children = saver.begin_object( this->id(), type, attrs, change ACE_ENV_ARG_PARAMETER); ACE_CHECK; for all children { if (want_all_children || child.is_changed()) { child.save_persistent(saver ACE_ENV_ARG_PARAMETER); ACE_CHECK; } } for all deleted children { saver.delete_child(child_type, child_id); } saver.end_object(this->id(), type ACE_ENV_ARG_PARAMETER); ) Implements TAO_Notify::Topology_Savable. Definition at line 105 of file Reconnection_Registry.cpp. References ACE_CHECK, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_TEXT(), DEBUG_LEVEL, LM_DEBUG, TAO_Notify::NVPList::push_back(), TAO_Notify::RECONNECT_ID, TAO_Notify::RECONNECT_IOR, TAO_Notify::REGISTRY_CALLBACK_TYPE, and TAO_Notify::REGISTRY_TYPE. Referenced by TAO_Notify_EventChannelFactory::save_persistent().
00106 {
00107 bool change = this->self_changed_;
00108 this->self_changed_ = false;
00109 this->children_changed_ = false;
00110
00111 NVPList attrs;
00112 //@@todo: bool want_all_children =
00113 saver.begin_object (0, REGISTRY_TYPE, attrs, change ACE_ENV_ARG_PARAMETER);
00114 ACE_CHECK;
00115
00116 Reconnection_Registry_Type::ENTRY *entry;
00117 for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
00118 iter.next (entry);
00119 iter.advance ())
00120 {
00121 NVPList cattrs;
00122 if (DEBUG_LEVEL > 0)
00123 {
00124 ACE_DEBUG ((LM_DEBUG,
00125 ACE_TEXT ("(%P|%t) Reconnect registry: saving %d\n"),
00126 static_cast<int> (entry->ext_id_)
00127 ));
00128 }
00129 cattrs.push_back(NVP(RECONNECT_ID, entry->ext_id_));
00130 cattrs.push_back(NVP(RECONNECT_IOR, entry->int_id_));
00131 saver.begin_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE, cattrs, true ACE_ENV_ARG_PARAMETER);
00132 ACE_CHECK;
00133 saver.end_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE ACE_ENV_ARG_PARAMETER);
00134 ACE_CHECK;
00135 }
00136 // todo:
00137 // for all deleted children
00138 // {
00139 // saver.delete_child(child_type, child_id);
00140 // }
00141 saver.end_object (0, REGISTRY_TYPE ACE_ENV_ARG_PARAMETER);
00142 }
|
|
|
Definition at line 187 of file Reconnection_Registry.cpp. References ACE_CATCHANY, ACE_CString, ACE_DEBUG, ACE_DECLARE_NEW_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_TEXT(), ACE_TRY, ACE_TRY_CHECK, DEBUG_LEVEL, CosNotifyChannelAdmin::EventChannelFactory_ptr, TAO_Singleton< TYPE, ACE_LOCK >::instance(), CORBA::is_nil(), LM_DEBUG, TAO_Notify_Properties::orb(), ACE_Vector< T, DEFAULT_SIZE >::push_back(), reconnection_registry_, ACE_Vector< T, DEFAULT_SIZE >::size(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(). Referenced by TAO_Notify_EventChannelFactory::reconnect().
00189 {
00190 TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
00191 CORBA::ORB_var orb = properties->orb ();
00192 ACE_Vector <NotifyExt::ReconnectionRegistry::ReconnectionID> bad_ids;
00193
00194 Reconnection_Registry_Type::ENTRY *entry;
00195 for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
00196 iter.next (entry);
00197 iter.advance ())
00198 {
00199 ACE_DECLARE_NEW_ENV;
00200 ACE_TRY
00201 {
00202 if (DEBUG_LEVEL > 0)
00203 {
00204 ACE_DEBUG ((LM_DEBUG,
00205 ACE_TEXT ("(%P|%t) Reconnection Registry: Sending reconnection to client %d\n"),
00206 static_cast<int> (entry->ext_id_)
00207 ));
00208 }
00209 ACE_CString & ior = entry->int_id_;
00210 CORBA::Object_var obj = orb->string_to_object (ior.c_str () ACE_ENV_ARG_PARAMETER);
00211 ACE_TRY_CHECK;
00212 NotifyExt::ReconnectionCallback_var callback =
00213 NotifyExt::ReconnectionCallback::_narrow (obj.in ());
00214 if (!CORBA::is_nil (callback.in ()))
00215 {
00216 callback->reconnect (dest_factory ACE_ENV_ARG_PARAMETER);
00217 ACE_TRY_CHECK;
00218 }
00219 else
00220 {
00221 ACE_DEBUG ((LM_DEBUG,
00222 ACE_TEXT ("(%P|%t) Reconnection Registry: Can't resolve reconnection client's IOR %d\n"),
00223 static_cast<int> (entry->ext_id_)
00224 ));
00225
00226 //throw this entry away but you've got an iterator so be careful
00227 bad_ids.push_back (entry->ext_id_);
00228 }
00229 }
00230 ACE_CATCHANY
00231 {
00232 ACE_DEBUG ((LM_DEBUG,
00233 ACE_TEXT ("(%P|%t) Reconnection Registry: Exception sending reconnection to client -- discarding registry entry\n")
00234 ));
00235 //throw this entry away but you've got an iterator so be careful
00236 bad_ids.push_back (entry->ext_id_);
00237 //@@todo : we might want to check for retryable exceptions, but for now...
00238 }
00239 ACE_ENDTRY;
00240 }
00241 size_t bad_count = bad_ids.size ();
00242 for (size_t nbad = 0; nbad < bad_count; ++nbad)
00243 {
00244 this->reconnection_registry_.unbind (bad_ids[nbad]);
00245 }
00246 }
|
|
|
Definition at line 77 of file Reconnection_Registry.cpp. References ACE_CHECK, ACE_DEBUG, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TEXT(), DEBUG_LEVEL, LM_DEBUG, reconnection_registry_, TAO_Notify::Topology_Object::self_change(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00079 {
00080 if (DEBUG_LEVEL > 0)
00081 {
00082 ACE_DEBUG ((LM_DEBUG,
00083 ACE_TEXT ("(%P|%t) Reconnect registry: unregistering %d\n"),
00084 static_cast<int> (id)
00085 ));
00086 }
00087 if ( 0 != reconnection_registry_.unbind (id))
00088 {
00089 //@@todo throw something
00090 }
00091 this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00092 ACE_CHECK;
00093 }
|
|
|
Definition at line 93 of file Reconnection_Registry.h. Referenced by load_child(), and register_callback(). |
|
|
Definition at line 92 of file Reconnection_Registry.h. Referenced by load_child(), register_callback(), send_reconnect(), and unregister_callback(). |
1.3.6