diff options
author | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-05-28 19:06:41 +0000 |
---|---|---|
committer | thrall <thrall@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-05-28 19:06:41 +0000 |
commit | 35ce532920ea2d9a0e5b644b2c8507a79b064084 (patch) | |
tree | 03638cb5bba0d31531ab4ff883a5dd9d3977879d | |
parent | f35da05bce56147c3be426fc4c0b106889a586c6 (diff) | |
download | ATCD-35ce532920ea2d9a0e5b644b2c8507a79b064084.tar.gz |
Added support for randomized mode switches, fixed DEBUG periodicity
-rw-r--r-- | TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Dynamic_Supplier.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Supplier_EC.cpp | 34 |
2 files changed, 28 insertions, 8 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Dynamic_Supplier.cpp b/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Dynamic_Supplier.cpp index 6c95658e952..2bb5001ba34 100644 --- a/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Dynamic_Supplier.cpp +++ b/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Dynamic_Supplier.cpp @@ -52,6 +52,7 @@ Dynamic_Supplier::timeout_occured (ACE_ENV_SINGLE_ARG_DECL) switch (this->mode_) { case FAULT_TOLERANT: { + ACE_DEBUG((LM_DEBUG,"Dynamic_Supplier (%P|%t) mode: FAULT_TOLERANT\n")); eventA[0].header.type = this->ft_type_; eventB[0].header.type = this->ft_type2_; //ACE_DEBUG((LM_DEBUG,"Dynamic_Supplier (%P|%t) setting header FT types: A = %d, B = %d\n",eventA[0].header.type,eventB[0].header.type)); @@ -60,6 +61,7 @@ Dynamic_Supplier::timeout_occured (ACE_ENV_SINGLE_ARG_DECL) } default: //NORMAL { + ACE_DEBUG((LM_DEBUG,"Dynamic_Supplier (%P|%t) mode: NORMAL\n")); eventA[0].header.type = this->norm_type_; eventB[0].header.type = this->norm_type2_; //ACE_DEBUG((LM_DEBUG,"Dynamic_Supplier (%P|%t) setting header types: A = %d, B = %d\n",eventA[0].header.type,eventB[0].header.type)); diff --git a/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Supplier_EC.cpp b/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Supplier_EC.cpp index 1030e9c836a..7bdef675b58 100644 --- a/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Supplier_EC.cpp +++ b/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Supplier_EC.cpp @@ -5,6 +5,7 @@ #include "ace/Sched_Params.h" #include "ace/Thread.h" #include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_stdlib.h" //for rand() #include "ace/Select_Reactor_Base.h" //for ACE_Select_Reactor_Impl::DEFAULT_SIZE #include "ace/Map.h" #include "ace/Vector_T.h" @@ -43,7 +44,8 @@ namespace class Mode_Handler: public Service_Handler { public: - ///Switches Supplier from NORMAL mode to FAULT_TOLERANT after switch_at_event handle_service_start()s + //Switches Supplier from NORMAL mode to FAULT_TOLERANT after + //switch_at_event handle_service_start()s. If switch_at_event = -1, then switching happens randomly. Mode_Handler(long switch_at_event) : switch_(switch_at_event) { @@ -67,17 +69,33 @@ public: , RtecScheduler::SYNCHRONIZATION_FAILURE )) { - if (this->switch_ <= 0) + if (this->switch_ >= 0) { - ACE_DEBUG((LM_DEBUG,"Mode_Handler (%P|%t) handle_service_start() START\n")); + //switch to FAULT_TOLERANT after a certain number of Task servicings + if (this->switch_ == 0) + { + ACE_DEBUG((LM_DEBUG,"Mode_Handler (%P|%t) handle_service_start() START\n")); - this->supplier_->mode(Supplier::FAULT_TOLERANT); + this->supplier_->mode(Supplier::FAULT_TOLERANT); - ACE_DEBUG((LM_DEBUG,"Mode_Handler (%P|%t) handle_service_start() END\n")); + ACE_DEBUG((LM_DEBUG,"Mode_Handler (%P|%t) handle_service_start() END\n")); + } + else + { + this->switch_--; + } } else { - this->switch_--; + //randomly choose mode + if (rand() > RAND_MAX/2.0) + { + this->supplier_->mode(Supplier::FAULT_TOLERANT); + } + else + { + this->supplier_->mode(Supplier::NORMAL); + } } } @@ -225,7 +243,7 @@ public: Mode_Handler *mode_handler; ACE_NEW(mode_handler, - Mode_Handler(1)); //mode switch after first event + Mode_Handler(0)); //mode switch immediately Supplier *supplier_impl1_1; Timeout_Consumer *timeout_consumer_impl1_1; ACE_NEW(supplier_impl1_1, @@ -234,7 +252,7 @@ public: this->handler_ = mode_handler; ACE_NEW(timeout_consumer_impl1_1, Timeout_Consumer(supplier_impl1_1)); - ACE_Time_Value tv(1,200000); //period DEBUG: set to much longer period + ACE_Time_Value tv(0,200000); //period add_supplier_with_timeout(supplier_impl1_1, "supplier1_1", supp1_1_types, |