int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { TAO_EC_Default_Factory::init_svcs (); /// Move the test to the real-time class if it is possible. RT_Class rt_class; try { ORB_Holder orb (argc, argv, ""); if (parse_args (argc, argv) != 0) return 1; RTServer_Setup rtserver_setup (use_rt_corba, orb, rt_class, nthreads); PortableServer::POA_var root_poa = RIR_Narrow<PortableServer::POA>::resolve (orb, "RootPOA"); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); PortableServer::POA_var ec_poa (rtserver_setup.poa ()); ORB_Task orb_task (orb); ORB_Task_Activator orb_task_activator (rt_class.priority_high (), rt_class.thr_sched_class (), nthreads, &orb_task); ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n")); Servant_var<TAO_EC_Event_Channel> ec_impl ( RTEC_Initializer::create (ec_poa.in (), ec_poa.in (), rtserver_setup.rtcorba_setup ()) ); ec_impl->activate (); PortableServer::ObjectId_var ec_id = ec_poa->activate_object (ec_impl.in ()); CORBA::Object_var ec_object = ec_poa->id_to_reference (ec_id.in ()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); CORBA::String_var ior = orb->object_to_string (ec.in ()); // Output the ior to the <ior_output_file> FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); do { ACE_Time_Value tv (1, 0); orb->run (tv); } while (ec_impl->destroyed () == 0); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
void OrbRunner::run(void) { ACE_ASSERT(this->num_orb_threads_ > 0); // If the num_orb_threads_ is exactly one, then just use the current // (mainline) thread to run the ORB event loop. if (this->num_orb_threads_ == 1) { // Since the num_orb_threads_ is exactly one, we just use the current // (mainline) thread to run the ORB event loop. this->orb_->run(); } else { // The num_orb_threads_ is greater than 1, so we will use an OrbTask // (active object) to run the ORB event loop in (num_orb_threads_ - 1) // threads. We use the current (mainline) thread as the other thread // running the ORB event loop. OrbTask orb_task(this->orb_.in(), this->num_orb_threads_ - 1); // Activate the OrbTask worker threads if (orb_task.open(0) != 0) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to open the OrbTask.\n")); throw TestAppException(); } // This will use the current (mainline) thread to run the ORB event loop. this->orb_->run(); // Now that the current thread has unblocked from running the orb, // make sure to wait for all of the worker threads to complete. orb_task.wait(); } }
// // run_main // int TestExecutionManager_App::run_main (int argc, char * argv []) { try { // Parse the command-line arguments. if (0 != this->parse_args (argc, argv)) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to parse ") ACE_TEXT ("command-line arguments\n")), -1); // Get the root POA for this ORB. ::CORBA::Object_var obj = this->orb_->resolve_initial_references ("RootPOA"); if (::CORBA::is_nil (obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - failed to resolve RootPOA")), -1); this->root_poa_ = ::PortableServer::POA::_narrow (obj.in ()); if (::CORBA::is_nil (this->root_poa_.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - object is not a POA")), -1); // Activate the POA manager. ::PortableServer::POAManager_var poa_mgr = this->root_poa_->the_POAManager (); poa_mgr->activate (); // Finish initializing the servant, then activate it. const ACE_CString iortbl_name = "OASIS/TEM"; this->servant_.set_trait_value (IOR_Table_Trait (), iortbl_name); TestExecutionManager_i * test_mgr = 0; ACE_NEW_THROW_EX (test_mgr, TestExecutionManager_i (*this), CORBA::NO_MEMORY ()); this->servant_.reset (test_mgr); this->servant_.activate (this->root_poa_.in ()); // Update the ORB task. ORB_Server_Task orb_task (this->orb_.in ()); // Run the ORB's event loop, and wait for it to exit. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%T (%t) - %M - running ORB's event loop\n"))); orb_task.activate (); orb_task.wait (); return 0; } catch (const CORBA::Exception & ex) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - %s\n"), ex._info ().c_str ())); } catch (const std::exception & ex) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%T (%t) - %M - %s\n"), ex.what ())); } return -1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { const CORBA::Long experiment_id = 1; TAO_EC_Default_Factory::init_svcs (); /// Move the test to the real-time class if it is possible. RT_Class rt_class; try { ORB_Holder orb (argc, argv, ""); Client_Options options (argc, argv); if (argc != 1) { ACE_ERROR_RETURN ((LM_ERROR, "Usage: %s " "-i iterations (iterations) " "-h high_priority_period (usecs) " "-l low_priority_period (usecs) " "-w high_priority_workload (usecs) " "-v low_priority_workload (usecs) " "-r (enable RT-CORBA) " "-n nthreads (low priority thread) " "-d (dump history) " "-z (disable low priority) " "\n", argv [0]), 1); } RTServer_Setup rtserver_setup (options.use_rt_corba, orb, rt_class, 1 // options.nthreads ); PortableServer::POA_var root_poa = RIR_Narrow<PortableServer::POA>::resolve (orb, "RootPOA"); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); PortableServer::POA_var ec_poa (rtserver_setup.poa ()); ACE_Thread_Manager my_thread_manager; ORB_Task orb_task (orb); orb_task.thr_mgr (&my_thread_manager); ORB_Task_Activator orb_task_activator (rt_class.priority_high (), rt_class.thr_sched_class (), 1, &orb_task); ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n")); Servant_var<TAO_EC_Event_Channel> ec_impl ( RTEC_Initializer::create (ec_poa.in (), ec_poa.in (), rtserver_setup.rtcorba_setup ()) ); ec_impl->activate (); PortableServer::ObjectId_var ec_id = ec_poa->activate_object (ec_impl.in ()); CORBA::Object_var ec_object = ec_poa->id_to_reference (ec_id.in ()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); EC_Destroyer ec_destroyer (ec.in ()); ACE_DEBUG ((LM_DEBUG, "Finished EC configuration and activation\n")); int thread_count = 1 + options.nthreads; ACE_Barrier the_barrier (thread_count); ACE_DEBUG ((LM_DEBUG, "Calibrating high res timer ....")); ACE_High_Res_Timer::calibrate (); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "Done (%d)\n", gsf)); CORBA::Long event_range = 1; if (options.funky_supplier_publication) { if (options.unique_low_priority_event) event_range = 1 + options.low_priority_consumers; else event_range = 2; } Client_Group high_priority_group; high_priority_group.init (experiment_id, ACE_ES_EVENT_UNDEFINED, event_range, options.iterations, options.high_priority_workload, gsf, ec_poa.in (), ec_poa.in ()); Auto_Disconnect<Client_Group> high_priority_disconnect; if (!options.high_priority_is_last) { high_priority_group.connect (ec.in ()); high_priority_disconnect = &high_priority_group; } int per_thread_period = options.low_priority_period; if (options.global_low_priority_rate) per_thread_period = options.low_priority_period * options.nthreads; Low_Priority_Setup<Client_Group> low_priority_setup ( options.low_priority_consumers, 0, // no limit on the number of iterations options.unique_low_priority_event, experiment_id, ACE_ES_EVENT_UNDEFINED + 2, options.low_priority_workload, gsf, options.nthreads, rt_class.priority_low (), rt_class.thr_sched_class (), per_thread_period, ec_poa.in (), ec_poa.in (), ec.in (), &the_barrier); if (options.high_priority_is_last) { high_priority_group.connect (ec.in ()); high_priority_disconnect = &high_priority_group; } Send_Task high_priority_task; high_priority_task.init (options.iterations, options.high_priority_period, 0, ACE_ES_EVENT_UNDEFINED, experiment_id, high_priority_group.supplier (), &the_barrier); high_priority_task.thr_mgr (&my_thread_manager); { // Artificial scope to wait for the high priority task... Task_Activator<Send_Task> high_priority_act (rt_class.priority_high (), rt_class.thr_sched_class (), 1, &high_priority_task); } ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - high priority task completed\n")); low_priority_setup.stop_all_threads (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - low priority task(s) stopped\n")); ACE_Sample_History &history = high_priority_group.consumer ()->sample_history (); if (options.dump_history) { history.dump_samples (ACE_TEXT("HISTORY"), gsf); } ACE_Basic_Stats high_priority_stats; history.collect_basic_stats (high_priority_stats); high_priority_stats.dump_results (ACE_TEXT("High Priority"), gsf); ACE_Basic_Stats low_priority_stats; low_priority_setup.collect_basic_stats (low_priority_stats); low_priority_stats.dump_results (ACE_TEXT("Low Priority"), gsf); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - starting cleanup\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { /// Move the test to the real-time class if it is possible. RT_Class rt_class; try { ORB_Holder orb (argc, argv, ""); if (parse_args (argc, argv) != 0) return 1; RTServer_Setup rtserver_setup (use_rt_corba, orb, rt_class, nthreads); PortableServer::POA_var root_poa = RIR_Narrow<PortableServer::POA>::resolve (orb, "RootPOA"); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); PortableServer::POA_var the_poa (rtserver_setup.poa ()); ORB_Task orb_task (orb); ORB_Task_Activator orb_task_activator (rt_class.priority_high (), rt_class.thr_sched_class (), nthreads, &orb_task); ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n")); Servant_var<Session_Factory> session_factory ( new Session_Factory (orb, the_poa.in ()) ); CORBA::Object_var object = session_factory->_this (); CORBA::String_var ior = orb->object_to_string (object.in ()); // Output the ior to the <ior_output_file> FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }