#include <EC_Reactive_SupplierControl.h>
Inheritance diagram for TAO_EC_Reactive_SupplierControl:
Public Member Functions | |
TAO_EC_Reactive_SupplierControl (const ACE_Time_Value &rate, const ACE_Time_Value &timeout, TAO_EC_Event_Channel_Base *event_channel, CORBA::ORB_ptr orb) | |
virtual | ~TAO_EC_Reactive_SupplierControl (void) |
Destructor. | |
void | handle_timeout (const ACE_Time_Value &tv, const void *arg) |
Receive the timeout from the adapter. | |
virtual int | activate (void) |
virtual int | shutdown (void) |
virtual void | supplier_not_exist (TAO_EC_ProxyPushConsumer *proxy) |
virtual void | system_exception (TAO_EC_ProxyPushConsumer *proxy, CORBA::SystemException &) |
Private Member Functions | |
void | query_suppliers (void) |
Private Attributes | |
ACE_Time_Value | rate_ |
The polling rate. | |
ACE_Time_Value | timeout_ |
The polling timeout. | |
TAO_EC_SupplierControl_Adapter | adapter_ |
The Adapter for the reactor events. | |
TAO_EC_Event_Channel_Base * | event_channel_ |
The event channel. | |
CORBA::ORB_var | orb_ |
The ORB. | |
CORBA::PolicyCurrent_var | policy_current_ |
To control the timeout policy in the thread. | |
CORBA::PolicyList | policy_list_ |
Precomputed policy list to the set timeout. | |
ACE_Reactor * | reactor_ |
The ORB reactor. | |
long | timer_id_ |
The timer id. |
Defines the interface for the supplier control strategy. This strategy handles misbehaving or failing suppliers.
Definition at line 82 of file EC_Reactive_SupplierControl.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_Reactive_SupplierControl::TAO_EC_Reactive_SupplierControl | ( | const ACE_Time_Value & | rate, | |
const ACE_Time_Value & | timeout, | |||
TAO_EC_Event_Channel_Base * | event_channel, | |||
CORBA::ORB_ptr | orb | |||
) |
Constructor. It does not assume ownership of the event_channel parameter.
Definition at line 23 of file EC_Reactive_SupplierControl.cpp.
00027 : rate_ (rate), 00028 timeout_ (timeout), 00029 adapter_ (this), 00030 event_channel_ (ec), 00031 orb_ (CORBA::ORB::_duplicate (orb)) 00032 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00033 , timer_id_ (-1) 00034 #endif /* TAO_HAS_CORBA_MESSAGING != 0*/ 00035 { 00036 this->reactor_ = 00037 this->orb_->orb_core ()->reactor (); 00038 }
TAO_EC_Reactive_SupplierControl::~TAO_EC_Reactive_SupplierControl | ( | void | ) | [virtual] |
int TAO_EC_Reactive_SupplierControl::activate | ( | void | ) | [virtual] |
Activate any internal threads or timers used to poll the state of the suppliers
Reimplemented from TAO_EC_SupplierControl.
Definition at line 85 of file EC_Reactive_SupplierControl.cpp.
References TAO_Pseudo_Var_T< T >::in(), orb_, policy_current_, policy_list_, reactor_, ACE_Reactor::schedule_timer(), timeout_, timer_id_, ACE_Time_Value::usec(), and ACE_Time_Value::zero.
00086 { 00087 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00088 try 00089 { 00090 // Get the PolicyCurrent object 00091 CORBA::Object_var tmp = 00092 this->orb_->resolve_initial_references ("PolicyCurrent"); 00093 00094 this->policy_current_ = 00095 CORBA::PolicyCurrent::_narrow (tmp.in ()); 00096 00097 // Timeout for polling state (default = 10 msec) 00098 TimeBase::TimeT timeout = timeout_.usec() * 10; 00099 CORBA::Any any; 00100 any <<= timeout; 00101 00102 this->policy_list_.length (1); 00103 this->policy_list_[0] = 00104 this->orb_->create_policy ( 00105 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, 00106 any); 00107 00108 // Only schedule the timer, when the rate is not zero 00109 if (this->rate_ != ACE_Time_Value::zero) 00110 { 00111 // Schedule the timer after these policies has been set, because the 00112 // handle_timeout uses these policies, if done in front, the channel 00113 // can crash when the timeout expires before initiazation is ready. 00114 timer_id_ = this->reactor_->schedule_timer (&this->adapter_, 00115 0, 00116 this->rate_, 00117 this->rate_); 00118 if (timer_id_ == -1) 00119 return -1; 00120 } 00121 } 00122 catch (const CORBA::Exception&) 00123 { 00124 return -1; 00125 } 00126 #endif /* TAO_HAS_CORBA_MESSAGING */ 00127 00128 return 0; 00129 }
void TAO_EC_Reactive_SupplierControl::handle_timeout | ( | const ACE_Time_Value & | tv, | |
const void * | arg | |||
) |
Receive the timeout from the adapter.
Definition at line 52 of file EC_Reactive_SupplierControl.cpp.
References policy_current_, and query_suppliers().
Referenced by TAO_EC_SupplierControl_Adapter::handle_timeout().
00055 { 00056 try 00057 { 00058 // Query the state of the Current object *before* we initiate 00059 // the iteration... 00060 CORBA::PolicyTypeSeq types; 00061 CORBA::PolicyList_var policies = 00062 this->policy_current_->get_policy_overrides (types); 00063 00064 // Change the timeout 00065 this->policy_current_->set_policy_overrides (this->policy_list_, 00066 CORBA::ADD_OVERRIDE); 00067 00068 // Query the state of the suppliers... 00069 this->query_suppliers (); 00070 00071 this->policy_current_->set_policy_overrides (policies.in (), 00072 CORBA::SET_OVERRIDE); 00073 for (CORBA::ULong i = 0; i != policies->length (); ++i) 00074 { 00075 policies[i]->destroy (); 00076 } 00077 } 00078 catch (const CORBA::Exception&) 00079 { 00080 // Ignore all exceptions 00081 } 00082 }
void TAO_EC_Reactive_SupplierControl::query_suppliers | ( | void | ) | [private] |
Check if the suppliers still exists. It is a helper method for handle_timeout() to isolate the exceptions.
Definition at line 45 of file EC_Reactive_SupplierControl.cpp.
References event_channel_, and TAO_EC_Event_Channel_Base::for_each_supplier().
Referenced by handle_timeout().
00046 { 00047 TAO_EC_Ping_Supplier worker (this); 00048 this->event_channel_->for_each_supplier (&worker); 00049 }
int TAO_EC_Reactive_SupplierControl::shutdown | ( | void | ) | [virtual] |
Reimplemented from TAO_EC_SupplierControl.
Definition at line 132 of file EC_Reactive_SupplierControl.cpp.
References adapter_, ACE_Reactor::cancel_timer(), ACE_Event_Handler::reactor(), reactor_, and timer_id_.
00133 { 00134 int r = 0; 00135 00136 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00137 r = this->reactor_->cancel_timer (timer_id_); 00138 #endif /* TAO_HAS_CORBA_MESSAGING */ 00139 this->adapter_.reactor (0); 00140 return r; 00141 }
void TAO_EC_Reactive_SupplierControl::supplier_not_exist | ( | TAO_EC_ProxyPushConsumer * | proxy | ) | [virtual] |
Invoked by helper classes when they detect that a supplier does not exists (i.e. _non_existent() returns true and/or the CORBA::OBJECT_NOT_EXIST exception has been raised).
Reimplemented from TAO_EC_SupplierControl.
Definition at line 144 of file EC_Reactive_SupplierControl.cpp.
References TAO_EC_ProxyPushConsumer::disconnect_push_consumer().
00146 { 00147 try 00148 { 00149 //ACE_DEBUG ((LM_DEBUG, 00150 // "EC_Reactive_SupplierControl(%P|%t) - " 00151 // "Consumer %x does not exists\n", long(proxy))); 00152 proxy->disconnect_push_consumer (); 00153 } 00154 catch (const CORBA::Exception&) 00155 { 00156 // Ignore all exceptions.. 00157 } 00158 }
void TAO_EC_Reactive_SupplierControl::system_exception | ( | TAO_EC_ProxyPushConsumer * | proxy, | |
CORBA::SystemException & | ||||
) | [virtual] |
Some system exception was raised while trying to contact the supplier
Reimplemented from TAO_EC_SupplierControl.
Definition at line 161 of file EC_Reactive_SupplierControl.cpp.
References TAO_EC_ProxyPushConsumer::disconnect_push_consumer().
00164 { 00165 try 00166 { 00167 // The current implementation is very strict, and kicks out a 00168 // client on the first system exception. We may 00169 // want to be more lenient in the future, for example, 00170 // this is TAO's minor code for a failed connection. 00171 // 00172 // if (CORBA::TRANSIENT::_narrow (&exception) != 0 00173 // && exception->minor () == 0x54410085) 00174 // return; 00175 00176 // Anything else is serious, including timeouts... 00177 proxy->disconnect_push_consumer (); 00178 } 00179 catch (const CORBA::Exception&) 00180 { 00181 // Ignore all exceptions.. 00182 } 00183 }
The Adapter for the reactor events.
Definition at line 119 of file EC_Reactive_SupplierControl.h.
Referenced by shutdown().
The event channel.
Definition at line 122 of file EC_Reactive_SupplierControl.h.
Referenced by query_suppliers().
CORBA::PolicyCurrent_var TAO_EC_Reactive_SupplierControl::policy_current_ [private] |
To control the timeout policy in the thread.
Definition at line 128 of file EC_Reactive_SupplierControl.h.
Referenced by activate(), and handle_timeout().
CORBA::PolicyList TAO_EC_Reactive_SupplierControl::policy_list_ [private] |
Precomputed policy list to the set timeout.
Definition at line 131 of file EC_Reactive_SupplierControl.h.
Referenced by activate().
The ORB reactor.
Definition at line 134 of file EC_Reactive_SupplierControl.h.
Referenced by activate(), and shutdown().
The polling timeout.
Definition at line 116 of file EC_Reactive_SupplierControl.h.
Referenced by activate().
long TAO_EC_Reactive_SupplierControl::timer_id_ [private] |
The timer id.
Definition at line 138 of file EC_Reactive_SupplierControl.h.
Referenced by activate(), and shutdown().