ECG_Reconnect_ConsumerEC_Control.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   ECG_Reconnect_ConsumerEC_Control.h
00005  *
00006  *  $Id: ECG_Reconnect_ConsumerEC_Control.h 76589 2007-01-25 18:04:11Z elliott_c $
00007  *
00008  *  @author Johnny Willemsen (jwillemsen@remedy.nl)
00009  *
00010  */
00011 
00012 #ifndef TAO_ECG_RECONNECT_CONSUMEREC_CONTROL_H
00013 #define TAO_ECG_RECONNECT_CONSUMEREC_CONTROL_H
00014 
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "orbsvcs/Event/ECG_ConsumerEC_Control.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "tao/ORB.h"
00024 #include "tao/PolicyC.h"
00025 
00026 #include "ace/Event_Handler.h"
00027 
00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 class TAO_ECG_Reconnect_ConsumerEC_Control;
00031 class TAO_EC_Gateway_IIOP;
00032 
00033 /**
00034  * @class TAO_ECG_Reconnect_ConsumerEC_Control_Adapter
00035  *
00036  * @brief Forwards timeout events to the Reconnect ConsumerControl
00037  *
00038  * The Reconnect ConsumerControl strategy uses the reactor to
00039  * periodically wakeup and verify the state of the consumers
00040  * registered with the Event Channel.
00041  */
00042 class TAO_RTEvent_Serv_Export TAO_ECG_Reconnect_ConsumerEC_Control_Adapter
00043   : public ACE_Event_Handler
00044 {
00045 public:
00046   /// Constructor
00047   TAO_ECG_Reconnect_ConsumerEC_Control_Adapter (TAO_ECG_Reconnect_ConsumerEC_Control *adaptee);
00048 
00049   // = Documented in ACE_Event_Handler.
00050   virtual int handle_timeout (const ACE_Time_Value &tv,
00051                               const void *arg = 0);
00052 
00053 private:
00054   /// The adapted object
00055   TAO_ECG_Reconnect_ConsumerEC_Control *adaptee_;
00056 };
00057 
00058 /**
00059  * @class TAO_ECG_Reconnect_ConsumerEC_Control
00060  *
00061  * @brief Consumer event channel control
00062  *
00063  * Defines the interface for the consumer event channel control strategy.
00064  * This strategy handles misbehaving or failing consumer event channels.
00065  *
00066  * This control tries to reconnect to the consumer ec incase of a connection
00067  * loss and then does a reconnect when the connection is back again. When also
00068  * a restart of the consumer ec must be handled correctly, then the consumer
00069  * ec must use a persistent IOR.
00070  */
00071 class TAO_RTEvent_Serv_Export TAO_ECG_Reconnect_ConsumerEC_Control
00072   : public TAO_ECG_ConsumerEC_Control
00073 {
00074 public:
00075   /// Constructor.  It does not assume ownership of the @a event_channel
00076   /// parameter.
00077   TAO_ECG_Reconnect_ConsumerEC_Control (const ACE_Time_Value &rate,
00078                                         const ACE_Time_Value &timeout,
00079                                         TAO_EC_Gateway_IIOP* gateway,
00080                                         CORBA::ORB_ptr orb);
00081 
00082   /// Destructor.
00083   virtual ~TAO_ECG_Reconnect_ConsumerEC_Control (void);
00084 
00085   /// Receive the timeout from the adapter
00086   void handle_timeout (const ACE_Time_Value &tv,
00087                        const void* arg);
00088 
00089   // = Documented in TAO_EC_ConsumerControl
00090   virtual int activate (void);
00091   virtual int shutdown (void);
00092   virtual void event_channel_not_exist (TAO_EC_Gateway_IIOP *gateway);
00093   virtual void system_exception (TAO_EC_Gateway_IIOP *gateway,
00094                                  CORBA::SystemException &);
00095 
00096 private:
00097   /// Check if the consumers still exists.  It is a helper method for
00098   /// handle_timeout() to isolate the exceptions.
00099   void query_eventchannel (void);
00100 
00101   /// Look if we can reconnect again.
00102   void try_reconnect (void);
00103 
00104   /// Reconnect to the consumer ec.
00105   void reconnect (void);
00106 
00107 private:
00108   /// The polling rate
00109   ACE_Time_Value rate_;
00110 
00111   /// The polling timeout
00112   ACE_Time_Value timeout_;
00113 
00114   /// The Adapter for the reactor events
00115   TAO_ECG_Reconnect_ConsumerEC_Control_Adapter adapter_;
00116 
00117   /// The gateway
00118   TAO_EC_Gateway_IIOP* gateway_;
00119 
00120   /// The ORB
00121   CORBA::ORB_var orb_;
00122 
00123   /// To control the timeout policy in the thread
00124   CORBA::PolicyCurrent_var policy_current_;
00125 
00126   /// Precomputed policy list to the set timeout.
00127   CORBA::PolicyList policy_list_;
00128 
00129   /// The ORB reactor
00130   ACE_Reactor *reactor_;
00131 
00132   /// Do we have a connection to the consumer ec
00133   int is_consumer_ec_connected_;
00134 
00135 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00136   /// The timer id
00137   long timer_id_;
00138 #endif /* TAO_HAS_CORBA_MESSAGING */
00139 };
00140 
00141 TAO_END_VERSIONED_NAMESPACE_DECL
00142 
00143 #include /**/ "ace/post.h"
00144 
00145 #endif /* TAO_ECG_RECONNECT_CONSUMEREC_CONTROL_H */

Generated on Tue Feb 2 17:44:06 2010 for TAO_RTEvent by  doxygen 1.4.7