EC_Reactive_ConsumerControl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /**
00003  *  @file   EC_Reactive_ConsumerControl.h
00004  *
00005  *  EC_Reactive_ConsumerControl.h,v 1.23 2006/03/14 06:14:25 jtc Exp
00006  *
00007  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00008  *
00009  * Based on previous work by Tim Harrison (harrison@cs.wustl.edu) and
00010  * other members of the DOC group. More details can be found in:
00011  *
00012  * http://doc.ece.uci.edu/~coryan/EC/index.html
00013  */
00014 
00015 #ifndef TAO_EC_REACTIVE_CONSUMERCONTROL_H
00016 #define TAO_EC_REACTIVE_CONSUMERCONTROL_H
00017 
00018 #include /**/ "ace/pre.h"
00019 
00020 #include "orbsvcs/Event/EC_ConsumerControl.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "orbsvcs/ESF/ESF_Worker.h"
00027 
00028 #include "tao/ORB.h"
00029 #include "tao/PolicyC.h"
00030 
00031 #include "ace/Event_Handler.h"
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 class TAO_EC_Event_Channel_Base;
00036 
00037 class TAO_EC_Reactive_ConsumerControl;
00038 
00039 /**
00040  * @class TAO_EC_ConsumerControl_Adapter
00041  *
00042  * @brief Forwards timeout events to the Reactive ConsumerControl
00043  *
00044  * The Reactive ConsumerControl strategy uses the reactor to
00045  * periodically wakeup and verify the state of the consumers
00046  * registered with the Event Channel.
00047  */
00048 class TAO_RTEvent_Serv_Export TAO_EC_ConsumerControl_Adapter : public ACE_Event_Handler
00049 {
00050 public:
00051   /// Constructor
00052   TAO_EC_ConsumerControl_Adapter (TAO_EC_Reactive_ConsumerControl *adaptee);
00053 
00054   // = Documented in ACE_Event_Handler.
00055   virtual int handle_timeout (const ACE_Time_Value &tv,
00056                               const void *arg = 0);
00057 
00058 private:
00059   /// The adapted object
00060   TAO_EC_Reactive_ConsumerControl *adaptee_;
00061 };
00062 
00063 /**
00064  * @class TAO_EC_Reactive_ConsumerControl
00065  *
00066  * @brief ConsumerControl
00067  *
00068  * Defines the interface for the consumer control strategy.
00069  * This strategy handles misbehaving or failing consumers.
00070  */
00071 class TAO_RTEvent_Serv_Export TAO_EC_Reactive_ConsumerControl : public TAO_EC_ConsumerControl
00072 {
00073 public:
00074   /// Constructor.  It does not assume ownership of the @a event_channel
00075   /// parameter.
00076   TAO_EC_Reactive_ConsumerControl (const ACE_Time_Value &rate,
00077                                    const ACE_Time_Value &timeout,
00078                                    TAO_EC_Event_Channel_Base *event_channel,
00079                                    CORBA::ORB_ptr orb);
00080 
00081   /// Destructor.
00082   virtual ~TAO_EC_Reactive_ConsumerControl (void);
00083 
00084   /// Receive the timeout from the adapter
00085   void handle_timeout (const ACE_Time_Value &tv,
00086                        const void* arg);
00087 
00088   // = Documented in TAO_EC_ConsumerControl
00089   virtual int activate (void);
00090   virtual int shutdown (void);
00091   virtual void consumer_not_exist (TAO_EC_ProxyPushSupplier *proxy
00092                                    ACE_ENV_ARG_DECL_NOT_USED);
00093   virtual void system_exception (TAO_EC_ProxyPushSupplier *proxy,
00094                                  CORBA::SystemException &
00095                                  ACE_ENV_ARG_DECL_NOT_USED);
00096 
00097 private:
00098   /// Check if the consumers still exists.  It is a helper method for
00099   /// handle_timeout() to isolate the exceptions.
00100   void query_consumers (ACE_ENV_SINGLE_ARG_DECL);
00101 
00102 private:
00103   /// The polling rate
00104   ACE_Time_Value rate_;
00105 
00106   /// The polling timeout
00107   ACE_Time_Value timeout_;
00108 
00109   /// The Adapter for the reactor events
00110   TAO_EC_ConsumerControl_Adapter adapter_;
00111 
00112   /// The event channel
00113   TAO_EC_Event_Channel_Base *event_channel_;
00114 
00115   /// The ORB
00116   CORBA::ORB_var orb_;
00117 
00118   /// To control the timeout policy in the thread
00119   CORBA::PolicyCurrent_var policy_current_;
00120 
00121   /// Precomputed policy list to the set timeout.
00122   CORBA::PolicyList policy_list_;
00123 
00124   /// The ORB reactor
00125   ACE_Reactor *reactor_;
00126 
00127 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00128   /// The timer id
00129   long timer_id_;
00130 #endif /* TAO_HAS_CORBA_MESSAGING */
00131 };
00132 
00133 // ****************************************************************
00134 
00135 class TAO_EC_Ping_Consumer : public TAO_ESF_Worker<TAO_EC_ProxyPushSupplier>
00136 {
00137 public:
00138   TAO_EC_Ping_Consumer (TAO_EC_ConsumerControl *control);
00139 
00140   virtual void work (TAO_EC_ProxyPushSupplier *supplier
00141                      ACE_ENV_ARG_DECL);
00142 
00143 private:
00144   TAO_EC_ConsumerControl *control_;
00145 };
00146 
00147 TAO_END_VERSIONED_NAMESPACE_DECL
00148 
00149 #if defined (__ACE_INLINE__)
00150 #include "orbsvcs/Event/EC_Reactive_ConsumerControl.i"
00151 #endif /* __ACE_INLINE__ */
00152 
00153 #include /**/ "ace/post.h"
00154 
00155 #endif /* TAO_EC_CONSUMERCONTROL_H */

Generated on Thu Nov 9 13:11:09 2006 for TAO_RTEvent by doxygen 1.3.6