TAO_Notify::Reconnection_Registry Class Reference

Implementation of ReconnectionRegistry. More...

#include <Reconnection_Registry.h>

Inheritance diagram for TAO_Notify::Reconnection_Registry:

Inheritance graph
[legend]
Collaboration diagram for TAO_Notify::Reconnection_Registry:

Collaboration graph
[legend]
List of all members.

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_Objectload_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_

Detailed Description

Implementation of ReconnectionRegistry.

Definition at line 42 of file Reconnection_Registry.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

TAO_Notify::Reconnection_Registry::Reconnection_Registry ( Topology_Parent parent  ) 

Constructor.

Definition at line 31 of file Reconnection_Registry.cpp.

References TAO_Notify::Topology_Object::topology_parent_.

00032     : highest_id_(0)
00033   {
00034     // not the best technique, here.  Take advantage of "protected"
00035     Topology_Object::topology_parent_ = &parent;
00036   }

TAO_Notify::Reconnection_Registry::~Reconnection_Registry (  )  [virtual]

Destructor.

Definition at line 38 of file Reconnection_Registry.cpp.

00039   {
00040   }


Member Function Documentation

CORBA::Boolean TAO_Notify::Reconnection_Registry::is_alive ( void   ) 

Definition at line 91 of file Reconnection_Registry.cpp.

00092   {
00093     return CORBA::Boolean(1);
00094   }

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.

References 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::NVPList::load(), TAO_Notify::RECONNECT_ID, TAO_Notify::RECONNECT_IOR, reconnection_registry_, and TAO_Notify::REGISTRY_CALLBACK_TYPE.

00143   {
00144     if (type == REGISTRY_CALLBACK_TYPE)
00145     {
00146       NotifyExt::ReconnectionRegistry::ReconnectionID id;
00147       ACE_CString ior;
00148       if (attrs.load (RECONNECT_ID, id) && attrs.load (RECONNECT_IOR, ior))
00149       {
00150         if (id > highest_id_)
00151         {
00152           highest_id_ = id;
00153 
00154           if (DEBUG_LEVEL > 0)
00155           {
00156             ACE_DEBUG ((LM_DEBUG,
00157               ACE_TEXT ("(%P|%t) Reconnect registry: reloading %d\n"),
00158               static_cast<int> (id)
00159               ));
00160           }
00161         }
00162         if ( 0 != reconnection_registry_.bind (id, ior))
00163         {
00164           //@@todo - throw something;
00165         }
00166       }
00167       else
00168       {
00169         ACE_ERROR ((LM_ERROR,
00170           ACE_TEXT ("(%P|%t) Reconnect registry: missing attribute\n")
00171           ));
00172       }
00173     }
00174     return this;
00175   }

::NotifyExt::ReconnectionRegistry::ReconnectionID TAO_Notify::Reconnection_Registry::register_callback ( ::NotifyExt::ReconnectionCallback_ptr  callback  ) 

Add a new callback to the registry.

Referenced by TAO_Notify_EventChannelFactory::register_callback().

void TAO_Notify::Reconnection_Registry::release ( void   )  [private, virtual]

The release method is called when the refcount reaches 0.

Implements TAO_Notify_Refcountable.

Definition at line 235 of file Reconnection_Registry.cpp.

00236   {
00237     delete this;
00238     //@@ inform factory
00239   }

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.

References ACE_DEBUG, ACE_TEXT(), TAO_Notify::Topology_Saver::begin_object(), TAO_Notify::Topology_Object::children_changed_, DEBUG_LEVEL, TAO_Notify::Topology_Saver::end_object(), LM_DEBUG, TAO_Notify::RECONNECT_ID, TAO_Notify::RECONNECT_IOR, TAO_Notify::REGISTRY_CALLBACK_TYPE, TAO_Notify::REGISTRY_TYPE, and TAO_Notify::Topology_Object::self_changed_.

00101   {
00102     bool change = this->self_changed_;
00103     this->self_changed_ = false;
00104     this->children_changed_ = false;
00105 
00106     NVPList attrs;
00107     //@@todo: bool want_all_children =
00108       saver.begin_object (0, REGISTRY_TYPE, attrs, change);
00109 
00110     Reconnection_Registry_Type::ENTRY *entry;
00111     for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
00112       iter.next (entry);
00113       iter.advance ())
00114     {
00115       NVPList cattrs;
00116       if (DEBUG_LEVEL > 0)
00117       {
00118         ACE_DEBUG ((LM_DEBUG,
00119           ACE_TEXT ("(%P|%t) Reconnect registry: saving %d\n"),
00120           static_cast<int> (entry->ext_id_)
00121           ));
00122       }
00123       cattrs.push_back(NVP(RECONNECT_ID, entry->ext_id_));
00124       cattrs.push_back(NVP(RECONNECT_IOR, entry->int_id_));
00125       saver.begin_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE, cattrs, true);
00126       saver.end_object (entry->ext_id_, REGISTRY_CALLBACK_TYPE);
00127     }
00128 // todo:
00129 //    for all deleted children
00130 //    {
00131 //      saver.delete_child(child_type, child_id);
00132 //    }
00133     saver.end_object (0, REGISTRY_TYPE);
00134   }

void TAO_Notify::Reconnection_Registry::send_reconnect ( CosNotifyChannelAdmin::EventChannelFactory_ptr  dest_factory  ) 

Definition at line 178 of file Reconnection_Registry.cpp.

References ACE_DEBUG, ACE_TEXT(), ACE_String_Base< CHAR >::c_str(), DEBUG_LEVEL, TAO_Pseudo_Var_T< T >::in(), TAO_Notify_Properties::instance(), CORBA::is_nil(), LM_DEBUG, TAO_Notify_Properties::orb(), ACE_Vector< T, DEFAULT_SIZE >::push_back(), and ACE_Vector< T, DEFAULT_SIZE >::size().

Referenced by TAO_Notify_EventChannelFactory::reconnect().

00179   {
00180     TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
00181     CORBA::ORB_var orb = properties->orb ();
00182     ACE_Vector <NotifyExt::ReconnectionRegistry::ReconnectionID> bad_ids;
00183 
00184     Reconnection_Registry_Type::ENTRY *entry;
00185     for (Reconnection_Registry_Type::ITERATOR iter (this->reconnection_registry_);
00186       iter.next (entry);
00187       iter.advance ())
00188     {
00189       try
00190       {
00191         if (DEBUG_LEVEL > 0)
00192         {
00193           ACE_DEBUG ((LM_DEBUG,
00194             ACE_TEXT ("(%P|%t) Reconnection Registry: Sending reconnection to client %d\n"),
00195               static_cast<int> (entry->ext_id_)
00196             ));
00197         }
00198         ACE_CString & ior = entry->int_id_;
00199         CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
00200         NotifyExt::ReconnectionCallback_var callback =
00201           NotifyExt::ReconnectionCallback::_narrow (obj.in ());
00202         if (!CORBA::is_nil (callback.in ()))
00203         {
00204           callback->reconnect (dest_factory);
00205         }
00206         else
00207         {
00208           ACE_DEBUG ((LM_DEBUG,
00209             ACE_TEXT ("(%P|%t) Reconnection Registry: Can't resolve reconnection client's IOR %d\n"),
00210               static_cast<int> (entry->ext_id_)
00211             ));
00212 
00213           //throw this entry away but you've got an iterator so be careful
00214           bad_ids.push_back (entry->ext_id_);
00215         }
00216       }
00217       catch (const CORBA::Exception&)
00218       {
00219         ACE_DEBUG ((LM_DEBUG,
00220           ACE_TEXT ("(%P|%t) Reconnection Registry: Exception sending reconnection to client -- discarding registry entry\n")
00221           ));
00222         //throw this entry away but you've got an iterator so be careful
00223         bad_ids.push_back (entry->ext_id_);
00224         //@@todo : we might want to check for retryable exceptions, but for now...
00225       }
00226     }
00227     size_t bad_count = bad_ids.size ();
00228     for (size_t nbad = 0; nbad < bad_count; ++nbad)
00229     {
00230       this->reconnection_registry_.unbind (bad_ids[nbad]);
00231     }
00232   }

void TAO_Notify::Reconnection_Registry::unregister_callback ( ::NotifyExt::ReconnectionRegistry::ReconnectionID  id  ) 

Referenced by TAO_Notify_EventChannelFactory::unregister_callback().


Member Data Documentation

::NotifyExt::ReconnectionRegistry::ReconnectionID TAO_Notify::Reconnection_Registry::highest_id_ [private]

Definition at line 89 of file Reconnection_Registry.h.

Referenced by load_child().

Reconnection_Registry_Type TAO_Notify::Reconnection_Registry::reconnection_registry_ [private]

Definition at line 88 of file Reconnection_Registry.h.

Referenced by load_child().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:46:42 2010 for TAO_CosNotification by  doxygen 1.4.7