Implementation of ReconnectionRegistry. More...
#include <Reconnection_Registry.h>


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 (void) |
| 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) |
Private Attributes | |
| Reconnection_Registry_Type | reconnection_registry_ |
| ::NotifyExt::ReconnectionRegistry::ReconnectionID | highest_id_ |
Implementation of ReconnectionRegistry.
Definition at line 42 of file Reconnection_Registry.h.
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> TAO_Notify::Reconnection_Registry::Reconnection_Registry_Type [private] |
The registry consists of a map from ReconnectionID to stringified IOR.
Definition at line 50 of file Reconnection_Registry.h.
| TAO_Notify::Reconnection_Registry::Reconnection_Registry | ( | Topology_Parent & | parent | ) |
Constructor.
Definition at line 31 of file Reconnection_Registry.cpp.
: highest_id_(0) { // not the best technique, here. Take advantage of "protected" Topology_Object::topology_parent_ = &parent; }
| TAO_Notify::Reconnection_Registry::~Reconnection_Registry | ( | ) | [virtual] |
| CORBA::Boolean TAO_Notify::Reconnection_Registry::is_alive | ( | void | ) |
Definition at line 91 of file Reconnection_Registry.cpp.
{
return CORBA::Boolean(1);
}
| Topology_Object * TAO_Notify::Reconnection_Registry::load_child | ( | const ACE_CString & | type, | |
| CORBA::Long | id, | |||
| const NVPList & | attrs | |||
| ) | [virtual] |
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 140 of file Reconnection_Registry.cpp.
{
if (type == REGISTRY_CALLBACK_TYPE)
{
NotifyExt::ReconnectionRegistry::ReconnectionID id;
ACE_CString ior;
if (attrs.load (RECONNECT_ID, id) && attrs.load (RECONNECT_IOR, ior))
{
if (id > highest_id_)
{
highest_id_ = id;
if (DEBUG_LEVEL > 0)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Reconnect registry: reloading %d\n"),
static_cast<int> (id)
));
}
}
if ( 0 != reconnection_registry_.bind (id, ior))
{
//@@todo - throw something;
}
}
else
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Reconnect registry: missing attribute\n")
));
}
}
return this;
}
| ::NotifyExt::ReconnectionRegistry::ReconnectionID TAO_Notify::Reconnection_Registry::register_callback | ( | ::NotifyExt::ReconnectionCallback_ptr | callback | ) |
Add a new callback to the registry.
| void TAO_Notify::Reconnection_Registry::release | ( | void | ) | [private] |
Definition at line 235 of file Reconnection_Registry.cpp.
{
delete this;
//@@ inform factory
}
| void TAO_Notify::Reconnection_Registry::save_persistent | ( | Topology_Saver & | saver | ) | [virtual] |
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); for all children { if (want_all_children || child.is_changed()) { child.save_persistent(saver); } } for all deleted children { saver.delete_child(child_type, child_id); } saver.end_object(this->id(), type); )
Implements TAO_Notify::Topology_Savable.
Definition at line 100 of file Reconnection_Registry.cpp.
{
bool change = this->self_changed_;
this->self_changed_ = false;
this->children_changed_ = false;
NVPList attrs;
//@@todo: bool want_all_children =
saver.begin_object (0, REGISTRY_TYPE, attrs, change);
Reconnection_Registry_Type::ENTRY *entry;
for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
iter.next (entry);
iter.advance ())
{
NVPList cattrs;
if (DEBUG_LEVEL > 0)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Reconnect registry: saving %d\n"),
static_cast<int> (entry->ext_id_)
));
}
cattrs.push_back(NVP(RECONNECT_ID, entry->ext_id_));
cattrs.push_back(NVP(RECONNECT_IOR, entry->int_id_));
saver.begin_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE, cattrs, true);
saver.end_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE);
}
// todo:
// for all deleted children
// {
// saver.delete_child(child_type, child_id);
// }
saver.end_object (0, REGISTRY_TYPE);
}
| void TAO_Notify::Reconnection_Registry::send_reconnect | ( | CosNotifyChannelAdmin::EventChannelFactory_ptr | dest_factory | ) |
Definition at line 178 of file Reconnection_Registry.cpp.
{
TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
CORBA::ORB_var orb = properties->orb ();
ACE_Vector <NotifyExt::ReconnectionRegistry::ReconnectionID> bad_ids;
Reconnection_Registry_Type::ENTRY *entry;
for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
iter.next (entry);
iter.advance ())
{
try
{
if (DEBUG_LEVEL > 0)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Reconnection Registry: Sending reconnection to client %d\n"),
static_cast<int> (entry->ext_id_)
));
}
ACE_CString & ior = entry->int_id_;
CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
NotifyExt::ReconnectionCallback_var callback =
NotifyExt::ReconnectionCallback::_narrow (obj.in ());
if (!CORBA::is_nil (callback.in ()))
{
callback->reconnect (dest_factory);
}
else
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Reconnection Registry: Can't resolve reconnection client's IOR %d\n"),
static_cast<int> (entry->ext_id_)
));
//throw this entry away but you've got an iterator so be careful
bad_ids.push_back (entry->ext_id_);
}
}
catch (const CORBA::Exception&)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Reconnection Registry: Exception sending reconnection to client -- discarding registry entry\n")
));
//throw this entry away but you've got an iterator so be careful
bad_ids.push_back (entry->ext_id_);
//@@todo : we might want to check for retryable exceptions, but for now...
}
}
size_t bad_count = bad_ids.size ();
for (size_t nbad = 0; nbad < bad_count; ++nbad)
{
this->reconnection_registry_.unbind (bad_ids[nbad]);
}
}
| void TAO_Notify::Reconnection_Registry::unregister_callback | ( | ::NotifyExt::ReconnectionRegistry::ReconnectionID | id | ) |
::NotifyExt::ReconnectionRegistry::ReconnectionID TAO_Notify::Reconnection_Registry::highest_id_ [private] |
Definition at line 89 of file Reconnection_Registry.h.
Definition at line 88 of file Reconnection_Registry.h.
1.7.0