CEC_Reactive_SupplierControl.h

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

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