diff options
Diffstat (limited to 'TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker')
4 files changed, 47 insertions, 14 deletions
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp index 6e1ffafb619..1ed8649ac7d 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp @@ -69,6 +69,14 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, timer_.stop (); + ++invocations_; + + ACE_DEBUG ((LM_EMERGENCY, "m(%s,%d,%d,%d) ", + logfile_.c_str (), + max_iterations_, + log_start_, + invocations_)); + if (logging_ && (invocations_ >= log_start_)) { ACE_Time_Value rt; @@ -79,9 +87,9 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, } catch (CORBA::SystemException & ex) { - ACE_DEBUG ((LM_WARNING, - ACE_TEXT ("Client_Timer_Handler::handle_timeout () -" - "caught: %s"), ex._info ().c_str ())); + ACE_DEBUG ((LM_EMERGENCY, + ACE_TEXT ("Client_Timer_Handler::handle_timeout () -" + "caught: %s"), ex._info ().c_str ())); orb_->shutdown (); @@ -90,7 +98,7 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, try { - if ((max_iterations_ > 0) && (++invocations_ >= max_iterations_)) + if ((max_iterations_ > 0) && (invocations_ >= max_iterations_)) { worker_->stop (); @@ -112,6 +120,8 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, int Client_Timer_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { + orb_->orb_core ()->reactor ()->cancel_timer (this); + orb_->shutdown (); return 0; diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker.mpc b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker.mpc index 0166a030785..d1dceb34436 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker.mpc +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker.mpc @@ -30,15 +30,19 @@ project(*Server): lwft_server, lwft_client, naming, rtcorba { } } -project(*Client): lwft_client, naming, rtcorba { +project(*Client): lwft_client, naming, rtcorba, portableserver { after += *idl Source_Files { client.cpp Client_Timer_Handler.cpp - WorkerC.cpp + WorkerC.cpp + TriggerS.cpp + TriggerC.cpp + Trigger_i.cpp } IDL_Files { + Trigger.idl } } diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp index e7806502566..3da7aba5ab2 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp @@ -16,7 +16,7 @@ Failure_Task::svc (void) { ACE_Guard <ACE_Thread_Mutex> guard (lock_); - while (((limit_ == 0) || (count_ < limit_)) && !stop_) + while (((limit_ == 0) || (count_ <= limit_)) && !stop_) { condition_.wait (); } @@ -59,6 +59,8 @@ Worker_i::Worker_i (CORBA::ORB_ptr orb, CORBA::ULong Worker_i::run_task (CORBA::Double execution_time) { + ACE_DEBUG ((LM_EMERGENCY, "x(%d) ", state_)); + timer_.start (); this->cpu_.run (static_cast <size_t> (execution_time)); diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp index dde0f65d562..660c6069819 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp @@ -1,6 +1,7 @@ // $Id$ #include <sstream> +#include <fstream> #include "WorkerC.h" #include "ace/Get_Opt.h" #include "orbsvcs/orbsvcs/LWFT/LWFT_Client_Init.h" @@ -8,6 +9,7 @@ #include "ace/Sig_Handler.h" #include "ace/Reactor.h" #include "tao/ORB_Core.h" +#include "Trigger_i.h" #include "tao/RTCORBA/RTCORBA.h" @@ -119,15 +121,30 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) timeout_handler.set_orb (orb.in ()); timeout_handler.set_worker (server1.in ()); - // add a the handler for the SIGINT signal here + // add a the handler for the SIGINT signal here ACE_Sig_Handler sig_handler; sig_handler.register_handler (SIGINT, &timeout_handler); - - // register the timer handler with the ORB reactor - orb->orb_core ()->reactor ()->schedule_timer (&timeout_handler, - 0, - ACE_Time_Value::zero, - period); + + Trigger_i * trigger = new Trigger_i (orb.in (), + timeout_handler, + period.msec ()); + + PortableServer::ServantBase_var ownership_transfer (trigger); + + CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); + + PortableServer::POAManager_var poa_mgr = poa->the_POAManager (); + + poa_mgr->activate (); + + Trigger_var trig = trigger->_this (); + + std::string fname = server_id + "Client.ior"; + std::ofstream file (fname.c_str ()); + file << orb->object_to_string (trig.in ()); + file.close (); orb->run (); |