CEC_Reactive_SupplierControl.h

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

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