EC_Reactive_SupplierControl.h

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

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