CEC_Reactive_ConsumerControl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_Reactive_ConsumerControl.h
00006  *
00007  *  $Id: CEC_Reactive_ConsumerControl.h 76589 2007-01-25 18:04:11Z elliott_c $
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  *
00011  * More details can be found in:
00012  *
00013  * http://doc.ece.uci.edu/~coryan/EC/
00014  */
00015 //=============================================================================
00016 
00017 
00018 #ifndef TAO_CEC_REACTIVE_CONSUMERCONTROL_H
00019 #define TAO_CEC_REACTIVE_CONSUMERCONTROL_H
00020 
00021 #include /**/ "ace/pre.h"
00022 
00023 #include "orbsvcs/CosEvent/CEC_ConsumerControl.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 #include "orbsvcs/ESF/ESF_Worker.h"
00030 
00031 #include "tao/ORB.h"
00032 
00033 #include "ace/Event_Handler.h"
00034 
00035 
00036 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00037 
00038 class TAO_CEC_EventChannel;
00039 
00040 class TAO_CEC_Reactive_ConsumerControl;
00041 
00042 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00043 class TAO_CEC_TypedEventChannel;
00044 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00045 
00046 /**
00047  * @class TAO_CEC_ConsumerControl_Adapter
00048  *
00049  * @brief Forwards timeout events to the Reactive ConsumerControl
00050  *
00051  * The Reactive ConsumerControl strategy uses the reactor to
00052  * periodically wakeup and verify the state of the consumers
00053  * registered with the Event Channel.
00054  */
00055 class TAO_Event_Serv_Export TAO_CEC_ConsumerControl_Adapter : public ACE_Event_Handler
00056 {
00057 public:
00058   /// Constructor
00059   TAO_CEC_ConsumerControl_Adapter (TAO_CEC_Reactive_ConsumerControl *adaptee);
00060 
00061   // = Documented in ACE_Event_Handler.
00062   virtual int handle_timeout (const ACE_Time_Value &tv,
00063                               const void *arg = 0);
00064 
00065 private:
00066   /// The adapted object
00067   TAO_CEC_Reactive_ConsumerControl *adaptee_;
00068 };
00069 
00070 /**
00071  * @class TAO_CEC_Reactive_ConsumerControl
00072  *
00073  * @brief ConsumerControl
00074  *
00075  * Defines the interface for the consumer control strategy.
00076  * This strategy handles misbehaving or failing consumers.
00077  * = MEMORY MANAGMENT
00078  * = LOCKING
00079  * = TODO
00080  */
00081 class TAO_Event_Serv_Export TAO_CEC_Reactive_ConsumerControl
00082   : public TAO_CEC_ConsumerControl
00083 {
00084 public:
00085   /// Constructor.  It does not assume ownership of the <event_channel>
00086   /// parameter.
00087   TAO_CEC_Reactive_ConsumerControl (const ACE_Time_Value &rate,
00088                                     const ACE_Time_Value &timeout,
00089                                     unsigned int retries,
00090                                     TAO_CEC_EventChannel *event_channel,
00091                                     CORBA::ORB_ptr orb);
00092 
00093   /// Constructor for the typed ec.
00094 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00095   TAO_CEC_Reactive_ConsumerControl (
00096       const ACE_Time_Value &rate,
00097       const ACE_Time_Value &timeout,
00098       unsigned int retries,
00099       TAO_CEC_TypedEventChannel *typed_event_channel,
00100       CORBA::ORB_ptr orb
00101     );
00102 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00103 
00104   /// destructor...
00105   virtual ~TAO_CEC_Reactive_ConsumerControl (void);
00106 
00107   /// Receive the timeout from the adapter
00108   void handle_timeout (const ACE_Time_Value &tv,
00109                        const void* arg);
00110 
00111   // = Documented in TAO_CEC_ConsumerControl
00112   virtual int activate (void);
00113   virtual int shutdown (void);
00114   virtual void consumer_not_exist (TAO_CEC_ProxyPushSupplier *proxy);
00115   virtual void consumer_not_exist (TAO_CEC_ProxyPullSupplier *proxy);
00116   virtual void system_exception (TAO_CEC_ProxyPushSupplier *proxy,
00117                                  CORBA::SystemException &);
00118 
00119   /// Do we need to disconnect this supplier?  The parameter type for
00120   /// proxy is PortableServer::ServantBase* due to the fact that this
00121   /// method will be used for TAO_CEC_ProxyPushSupplier's and
00122   /// TAO_CEC_ProxyPullSupplier's.
00123   virtual bool need_to_disconnect (PortableServer::ServantBase* proxy);
00124 
00125   /// Allow others to inform us when a send or receive was successful.
00126   virtual void successful_transmission (PortableServer::ServantBase* proxy);
00127 
00128 private:
00129   /// Check if the consumers still exists.  It is a helper method for
00130   /// handle_timeout() to isolate the exceptions.
00131   void query_consumers (void);
00132 
00133 private:
00134   /// The polling rate
00135   ACE_Time_Value rate_;
00136 
00137   /// The polling timeout
00138   ACE_Time_Value timeout_;
00139 
00140   /// The number of retries per proxy until it is disconnected
00141   unsigned int retries_;
00142 
00143   /// The Adapter for the reactor events
00144   TAO_CEC_ConsumerControl_Adapter adapter_;
00145 
00146   /// The event channel
00147   TAO_CEC_EventChannel *event_channel_;
00148 
00149   /// The typed event channel
00150 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00151   TAO_CEC_TypedEventChannel *typed_event_channel_;
00152 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00153 
00154   /// The ORB
00155   CORBA::ORB_var orb_;
00156 
00157   /// To control the timeout policy in the thread
00158   CORBA::PolicyCurrent_var policy_current_;
00159 
00160   /// Precomputed policy list to the set timeout.
00161   CORBA::PolicyList policy_list_;
00162 
00163   /// The ORB reactor
00164   ACE_Reactor *reactor_;
00165 
00166 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00167   /// The timer id
00168   long timer_id_;
00169 #endif /* TAO_HAS_CORBA_MESSAGING */
00170 };
00171 
00172 // ****************************************************************
00173 
00174 class TAO_CEC_Ping_Push_Consumer
00175   : public TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier>
00176 {
00177 public:
00178   TAO_CEC_Ping_Push_Consumer (TAO_CEC_ConsumerControl *control);
00179 
00180   virtual void work (TAO_CEC_ProxyPushSupplier *supplier);
00181 
00182 private:
00183   TAO_CEC_ConsumerControl *control_;
00184 };
00185 
00186 // ****************************************************************
00187 
00188 class TAO_CEC_Ping_Pull_Consumer
00189   : public TAO_ESF_Worker<TAO_CEC_ProxyPullSupplier>
00190 {
00191 public:
00192   TAO_CEC_Ping_Pull_Consumer (TAO_CEC_ConsumerControl *control);
00193 
00194   virtual void work (TAO_CEC_ProxyPullSupplier *supplier);
00195 
00196 private:
00197   TAO_CEC_ConsumerControl *control_;
00198 };
00199 
00200 TAO_END_VERSIONED_NAMESPACE_DECL
00201 
00202 #if defined (__ACE_INLINE__)
00203 #include "orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.inl"
00204 #endif /* __ACE_INLINE__ */
00205 
00206 #include /**/ "ace/post.h"
00207 
00208 #endif /* TAO_CEC_CONSUMERCONTROL_H */

Generated on Tue Feb 2 17:44:51 2010 for TAO_CosEvent by  doxygen 1.4.7