CEC_Reactive_ConsumerControl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_Reactive_ConsumerControl.h
00006  *
00007  *  CEC_Reactive_ConsumerControl.h,v 1.24 2006/03/14 06:14:25 jtc Exp
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                                    ACE_ENV_ARG_DECL_NOT_USED);
00116   virtual void consumer_not_exist (TAO_CEC_ProxyPullSupplier *proxy
00117                                    ACE_ENV_ARG_DECL_NOT_USED);
00118   virtual void system_exception (TAO_CEC_ProxyPushSupplier *proxy,
00119                                  CORBA::SystemException &
00120                                  ACE_ENV_ARG_DECL_NOT_USED);
00121 
00122   /// Do we need to disconnect this supplier?  The parameter type for
00123   /// proxy is PortableServer::ServantBase* due to the fact that this
00124   /// method will be used for TAO_CEC_ProxyPushSupplier's and
00125   /// TAO_CEC_ProxyPullSupplier's.
00126   virtual bool need_to_disconnect (PortableServer::ServantBase* proxy);
00127 
00128   /// Allow others to inform us when a send or receive was successful.
00129   virtual void successful_transmission (PortableServer::ServantBase* proxy);
00130 
00131 private:
00132   /// Check if the consumers still exists.  It is a helper method for
00133   /// handle_timeout() to isolate the exceptions.
00134   void query_consumers (ACE_ENV_SINGLE_ARG_DECL);
00135 
00136 private:
00137   /// The polling rate
00138   ACE_Time_Value rate_;
00139 
00140   /// The polling timeout
00141   ACE_Time_Value timeout_;
00142 
00143   /// The number of retries per proxy until it is disconnected
00144   unsigned int retries_;
00145 
00146   /// The Adapter for the reactor events
00147   TAO_CEC_ConsumerControl_Adapter adapter_;
00148 
00149   /// The event channel
00150   TAO_CEC_EventChannel *event_channel_;
00151 
00152   /// The typed event channel
00153 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00154   TAO_CEC_TypedEventChannel *typed_event_channel_;
00155 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00156 
00157   /// The ORB
00158   CORBA::ORB_var orb_;
00159 
00160   /// To control the timeout policy in the thread
00161   CORBA::PolicyCurrent_var policy_current_;
00162 
00163   /// Precomputed policy list to the set timeout.
00164   CORBA::PolicyList policy_list_;
00165 
00166   /// The ORB reactor
00167   ACE_Reactor *reactor_;
00168 
00169 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00170   /// The timer id
00171   long timer_id_;
00172 #endif /* TAO_HAS_CORBA_MESSAGING */
00173 };
00174 
00175 // ****************************************************************
00176 
00177 class TAO_CEC_Ping_Push_Consumer
00178   : public TAO_ESF_Worker<TAO_CEC_ProxyPushSupplier>
00179 {
00180 public:
00181   TAO_CEC_Ping_Push_Consumer (TAO_CEC_ConsumerControl *control);
00182 
00183   virtual void work (TAO_CEC_ProxyPushSupplier *supplier
00184                      ACE_ENV_ARG_DECL);
00185 
00186 private:
00187   TAO_CEC_ConsumerControl *control_;
00188 };
00189 
00190 // ****************************************************************
00191 
00192 class TAO_CEC_Ping_Pull_Consumer
00193   : public TAO_ESF_Worker<TAO_CEC_ProxyPullSupplier>
00194 {
00195 public:
00196   TAO_CEC_Ping_Pull_Consumer (TAO_CEC_ConsumerControl *control);
00197 
00198   virtual void work (TAO_CEC_ProxyPullSupplier *supplier
00199                      ACE_ENV_ARG_DECL);
00200 
00201 private:
00202   TAO_CEC_ConsumerControl *control_;
00203 };
00204 
00205 TAO_END_VERSIONED_NAMESPACE_DECL
00206 
00207 #if defined (__ACE_INLINE__)
00208 #include "orbsvcs/CosEvent/CEC_Reactive_ConsumerControl.i"
00209 #endif /* __ACE_INLINE__ */
00210 
00211 #include /**/ "ace/post.h"
00212 
00213 #endif /* TAO_CEC_CONSUMERCONTROL_H */

Generated on Thu Nov 9 13:18:17 2006 for TAO_CosEvent by doxygen 1.3.6