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; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { // We may want this to be alive beyond the next block. PortableServer::Servant_var<Heartbeat_Application> app; try { // Initialize ORB and POA, POA Manager, parse args. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) == -1) return 1; CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); if (check_for_nil (poa.in (), "POA") == -1) return 1; PortableServer::POAManager_var manager = poa->the_POAManager (); // Obtain reference to EC. obj = orb->resolve_initial_references ("Event_Service"); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (obj.in ()); if (check_for_nil (ec.in (), "EC") == -1) return 1; // Init our application. app = new Heartbeat_Application; if (!app.in ()) return 1; app->init (orb, ec); // Allow processing of CORBA requests. manager->activate (); // Receive events from EC. orb->run (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception in Heartbeat Application:"); // Since there was an exception, application might not have had // a chance to shutdown. app->shutdown (); return 1; } return 0; }
int Heartbeat_Application::check_args (CORBA::ORB_var orb, RtecEventChannelAdmin::EventChannel_var ec) { if (CORBA::is_nil (ec.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "%N (%l): Nil ec argument to " "Heartbeat_Application::init\n"), -1); } if (CORBA::is_nil (orb.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "%N (%l): Nil orb argument to " "Heartbeat_Application::init\n"), -1); } this->ec_ = ec; this->orb_ = orb; return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try{ orb = CORBA::ORB_init (argc, argv); RtecEventChannelAdmin::EventChannel_var channel = get_event_channel (argc, argv); if (CORBA::is_nil (channel.in ())) return -1; PortableServer::POA_var poa = resolve_init<PortableServer::POA> (orb.in (), "RootPOA"); PortableServer::POAManager_var mgr = poa->the_POAManager (); mgr->activate (); PushSupplier_impl push_supplier(orb.in ()); if (push_supplier.init(channel.in ()) == -1) return -1; RtecEventComm::PushSupplier_var supplier = push_supplier._this(); orb->run(); } catch (const CORBA::Exception& ex){ ex._tao_print_exception ("A CORBA Exception occurred."); } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); const ACE_TCHAR *ecname = ACE_TEXT ("EventService"); for (int i = 0; argv[i] != 0; i++) { if (ACE_OS::strcmp(argv[i], ACE_TEXT("-ecname")) == 0) { if (argv[i+1] != 0) { ecname = argv[i+1]; } else { std::cerr << "Missing Event channel name" << std::endl; } } } // Find the Naming Service. CORBA::Object_var obj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(obj.in()); // Find the EchoEventChannel. obj = root_context->resolve_str (ACE_TEXT_ALWAYS_CHAR (ecname)); // Downcast the object reference to an EventChannel reference. RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(obj.in()); if (CORBA::is_nil(ec.in())) { std::cerr << "Could not narrow EchoEventChannel." << std::endl; return 1; } std::cout << "EchoEventConsumerMain.cpp: Found the EchoEventChannel." << std::endl; // Obtain a reference to the consumer administration object. RtecEventChannelAdmin::ConsumerAdmin_var admin = ec->for_consumers(); // Obtain a reference to the push supplier proxy. RtecEventChannelAdmin::ProxyPushSupplier_var supplier = admin->obtain_push_supplier(); // Get the RootPOA. obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); // Instantiate an EchoEventConsumer_i servant and register it // with the RootPOA PortableServer::Servant_var<EchoEventConsumer_i> servant = new EchoEventConsumer_i(orb.in(), supplier.in(), EVENT_LIMIT); PortableServer::ObjectId_var oid = poa->activate_object(servant.in()); CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in()); RtecEventComm::PushConsumer_var consumer = RtecEventComm::PushConsumer::_narrow(consumer_obj.in()); // Connect as a consumer. ACE_ConsumerQOS_Factory qos; qos.start_disjunction_group (); qos.insert (MY_SOURCE_ID, // Source ID MY_EVENT_TYPE, // Event Type 0); // handle to the rt_info supplier->connect_push_consumer (consumer.in (), qos.get_ConsumerQOS ()); // Activate the POA via its POAManager. PortableServer::POAManager_var poa_manager = poa->the_POAManager(); poa_manager->activate(); std::cout << "EchoEventConsumerMain.cpp: Ready to receive events..." << std::endl; // Enter the ORB event loop. orb->run(); // If we have reached this, we must be shutting down... // Disconnect the ProxyPushSupplier. orb->destroy(); std::cout << "Test completed." << std::endl; return 0; } catch(const CORBA::Exception& exc) { std::cerr << "Caught CORBA::Exception" << std::endl << exc << std::endl; } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the EC Factory so we can customize the EC TAO_EC_Default_Factory::init_svcs (); // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); const ACE_TCHAR *ecname = ACE_TEXT ("EventService"); const ACE_TCHAR *address = ACE_TEXT ("localhost"); const ACE_TCHAR *iorfile = 0; u_short port = 12345; u_short listenport = 12345; int mcast = 1; for (int i = 0; argv[i] != 0; i++) { if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-ecname")) == 0) { if (argv[i+1] != 0) ecname = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing Event channel name\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-address")) == 0) { if (argv[i+1] != 0) address = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing address\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-port")) == 0) { if (argv[i+1] != 0) port = ACE_OS::atoi(argv[++i]); else ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-listenport")) == 0) { if (argv[i+1] != 0) listenport = ACE_OS::atoi(argv[++i]); else ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"), 0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-iorfile")) == 0) { if (argv[i+1] != 0) iorfile = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing ior file\n"), 0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-udp")) == 0) mcast = 0; } // Get the POA CORBA::Object_var tmpobj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (tmpobj.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Create a local event channel and register it TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ()); TAO_EC_Event_Channel ec_impl (attributes); ec_impl.activate (); PortableServer::ObjectId_var oid = poa->activate_object(&ec_impl); tmpobj = poa->id_to_reference(oid.in()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(tmpobj.in()); // Find the Naming Service. tmpobj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(tmpobj.in()); // Bind the Event Channel using Naming Services CosNaming::Name_var name = root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname)); root_context->rebind(name.in(), ec.in()); // Get a proxy push consumer from the EventChannel. RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers(); RtecEventChannelAdmin::ProxyPushConsumer_var consumer = admin->obtain_push_consumer(); // Instantiate an EchoEventSupplier_i servant. EchoEventSupplier_i servant(orb.in()); // Register it with the RootPOA. oid = poa->activate_object(&servant); tmpobj = poa->id_to_reference(oid.in()); RtecEventComm::PushSupplier_var supplier = RtecEventComm::PushSupplier::_narrow(tmpobj.in()); // Connect to the EC. ACE_SupplierQOS_Factory qos; qos.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); consumer->connect_push_supplier (supplier.in (), qos.get_SupplierQOS ()); // Initialize the address server with the desired address. This will // be used by the sender object and the multicast receiver only if // one is not otherwise available via the naming service. ACE_INET_Addr send_addr (port, address); SimpleAddressServer addr_srv_impl (send_addr); // Create an instance of the addr server for local use PortableServer::ObjectId_var addr_srv_oid = poa->activate_object(&addr_srv_impl); tmpobj = poa->id_to_reference(addr_srv_oid.in()); RtecUDPAdmin::AddrServer_var addr_srv = RtecUDPAdmin::AddrServer::_narrow(tmpobj.in()); // Create and initialize the sender object PortableServer::Servant_var<TAO_ECG_UDP_Sender> sender = TAO_ECG_UDP_Sender::create(); TAO_ECG_UDP_Out_Endpoint endpoint; // need to be explicit about the address type when built with // IPv6 support, otherwise SOCK_DGram::open defaults to ipv6 when // given a sap_any address. This causes trouble on at least solaris // and windows, or at most on not-linux. if (endpoint.dgram ().open (ACE_Addr::sap_any, send_addr.get_type()) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot open send endpoint\n"), 1); } // TAO_ECG_UDP_Sender::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the sender will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone (new TAO_ECG_UDP_Out_Endpoint (endpoint)); sender->init (ec.in (), addr_srv.in (), clone); // Setup the subscription and connect to the EC ACE_ConsumerQOS_Factory cons_qos_fact; cons_qos_fact.start_disjunction_group (); cons_qos_fact.insert (ACE_ES_EVENT_SOURCE_ANY, ACE_ES_EVENT_ANY, 0); RtecEventChannelAdmin::ConsumerQOS sub = cons_qos_fact.get_ConsumerQOS (); sender->connect (sub); // Create and initialize the receiver PortableServer::Servant_var<TAO_ECG_UDP_Receiver> receiver = TAO_ECG_UDP_Receiver::create(); // TAO_ECG_UDP_Receiver::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the receiver will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone2 (new TAO_ECG_UDP_Out_Endpoint (endpoint)); receiver->init (ec.in (), clone2, addr_srv.in ()); // Setup the registration and connect to the event channel ACE_SupplierQOS_Factory supp_qos_fact; supp_qos_fact.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); RtecEventChannelAdmin::SupplierQOS pub = supp_qos_fact.get_SupplierQOS (); receiver->connect (pub); // Create the appropriate event handler and register it with the reactor auto_ptr<ACE_Event_Handler> eh; if (mcast) { auto_ptr<TAO_ECG_Mcast_EH> mcast_eh(new TAO_ECG_Mcast_EH (receiver.in())); mcast_eh->reactor (orb->orb_core ()->reactor ()); mcast_eh->open (ec.in()); ACE_auto_ptr_reset(eh,mcast_eh.release()); //eh.reset(mcast_eh.release()); } else { auto_ptr<TAO_ECG_UDP_EH> udp_eh (new TAO_ECG_UDP_EH (receiver.in())); udp_eh->reactor (orb->orb_core ()->reactor ()); ACE_INET_Addr local_addr (listenport); if (udp_eh->open (local_addr) == -1) ACE_ERROR ((LM_ERROR,"Cannot open EH\n")); ACE_auto_ptr_reset(eh,udp_eh.release()); //eh.reset(udp_eh.release()); } // Create an event (just a string in this case). // Create an event set for one event RtecEventComm::EventSet event (1); event.length (1); // Initialize event header. event[0].header.source = MY_SOURCE_ID; event[0].header.ttl = 1; event[0].header.type = MY_EVENT_TYPE; #if !defined (TAO_LACKS_EVENT_CHANNEL_ANY) // Initialize data fields in event. const CORBA::String_var eventData = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (ecname)); event[0].data.any_value <<= eventData; #else // Use the octet sequence payload instead char *tmpstr = const_cast<char *>(ACE_TEXT_ALWAYS_CHAR (ecname)); size_t len = ACE_OS::strlen(tmpstr) +1; event[0].data.payload.replace ( len, len, reinterpret_cast<CORBA::Octet *> (tmpstr)); #endif /* !TAO_LACKS_EVENT_CHANNEL_ANY */ if (iorfile != 0) { CORBA::String_var str = orb->object_to_string( ec.in() ); std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(iorfile) ); iorFile << str.in() << std::endl; iorFile.close(); } ACE_DEBUG ((LM_DEBUG, "Starting main loop\n")); const int EVENT_DELAY_MS = 1000; while (1) { consumer->push (event); ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS); orb->run(tv); } orb->destroy(); return 0; } catch (const CORBA::Exception& exc) { ACE_ERROR ((LM_ERROR, "Caught CORBA::Exception\n%C (%C)\n", exc._name (), exc._rep_id () )); } return 1; }
int Event_Service::run (int argc, ACE_TCHAR* argv[]) { try { // Check if -ORBDaemon is specified and if so, daemonize at this moment, // -ORBDaemon in the ORB core is faulty, see bugzilla 3335 TAO_Daemon_Utility::check_for_daemon (argc, argv); // Initialize ORB. this->orb_ = CORBA::ORB_init (argc, argv); if (this->parse_args (argc, argv) == -1) return 1; CORBA::Object_var root_poa_object = this->orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (root_poa_object.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the root POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (root_poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); // When we have a service name or a non local scheduler we must use the // naming service. bool use_name_service = bind_to_naming_service_ || this->scheduler_type_ != ES_SCHED_NONE; CORBA::Object_var naming_obj; RtecScheduler::Scheduler_var scheduler; CosNaming::NamingContext_var naming_context; if (use_name_service) { naming_obj= this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the Naming Service.\n"), 1); naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); } // This is the name we (potentially) register the Scheduling // Service in the Naming Service. CosNaming::Name schedule_name (1); schedule_name.length (1); schedule_name[0].id = CORBA::string_dup ("ScheduleService"); // The old EC always needs a scheduler. If none is // specified, we default to a local scheduler if (this->scheduler_type_ == ES_SCHED_LOCAL) { // Create a local scheduler instance ACE_NEW_RETURN (this->sched_impl_, ACE_Config_Scheduler, 1); scheduler = this->sched_impl_->_this (); // Register the servant with the Naming Context.... if (!CORBA::is_nil (naming_context.in ())) { naming_context->rebind (schedule_name, scheduler.in ()); } } else if (this->scheduler_type_ == ES_SCHED_GLOBAL) { // Get reference to a scheduler from naming service CORBA::Object_var tmp = naming_context->resolve (schedule_name); scheduler = RtecScheduler::Scheduler::_narrow (tmp.in ()); if (CORBA::is_nil (scheduler.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to resolve the Scheduling Service.\n"), 1); } TAO_EC_Event_Channel_Attributes attr (root_poa.in (), root_poa.in ()); if (this->scheduler_type_ != ES_SCHED_NONE) { attr.scheduler = scheduler.in (); } TAO_EC_Event_Channel* ec_impl = 0; ACE_NEW_RETURN (ec_impl, TAO_EC_Event_Channel (attr), 1); this->ec_impl_ = ec_impl; ec_impl->activate (); RtecEventChannelAdmin::EventChannel_var ec; // If the object_id_ is empty and we don't use BiDIR GIOP, activate the // servant under the default POA, else create a new child POA with // the needed policies int persistent = ACE_OS::strcmp(this->object_id_.c_str(), ""); if ((persistent == 0) && (this->use_bidir_giop_ == false)) { // Notice that we activate *this* object with the POA, but we // forward all the requests to the underlying EC // implementation. ec = this->_this (); } else { CORBA::ULong index = 0; // Create child POA CORBA::PolicyList policies (3); if (persistent != 0) { policies.length (index++); policies[index] = root_poa->create_id_assignment_policy (PortableServer::USER_ID); policies.length (index++); policies[index] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT); } if (this->use_bidir_giop_ == true) { CORBA::Any pol; pol <<= BiDirPolicy::BOTH; policies.length (index++); policies[index] = this->orb_->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol); } ACE_CString child_poa_name = "childPOA"; PortableServer::POA_var child_poa = root_poa->create_POA (child_poa_name.c_str (), poa_manager.in (), policies); // Creation of persistentPOA is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < policies.length (); ++i) { policies[i]->destroy (); } if (CORBA::is_nil (child_poa.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the child POA.\n"), 1); PortableServer::ObjectId_var ec_object_id = PortableServer::string_to_ObjectId(object_id_.c_str()); child_poa->activate_object_with_id(ec_object_id.in(), this); CORBA::Object_var ec_obj = child_poa->id_to_reference(ec_object_id.in()); ec = RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in()); } CORBA::String_var str = this->orb_->object_to_string (ec.in ()); if (ACE_OS::strcmp(this->ior_file_name_.c_str(), ACE_TEXT("")) != 0) { FILE *output_file= ACE_OS::fopen (this->ior_file_name_.c_str(), ACE_TEXT("w")); if (output_file == 0) ORBSVCS_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", this->ior_file_name_.c_str()), 1); ACE_OS::fprintf (output_file, "%s", str.in ()); ACE_OS::fclose (output_file); } if (ACE_OS::strcmp(this->pid_file_name_.c_str(), ACE_TEXT("")) != 0) { FILE *pidf = ACE_OS::fopen (this->pid_file_name_.c_str(), ACE_TEXT("w")); if (pidf != 0) { ACE_OS::fprintf (pidf, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pidf); } } ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("The EC IOR is <%C>\n"), str.in ())); if (bind_to_naming_service_ && !CORBA::is_nil (naming_context.in ())) { CosNaming::Name channel_name (1); channel_name.length (1); channel_name[0].id = CORBA::string_dup (this->service_name_.c_str()); naming_context->rebind (channel_name, ec.in ()); } ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("%C; running event service\n"), __FILE__)); this->orb_->run (); if (bind_to_naming_service_ && !CORBA::is_nil (naming_context.in ())) { CosNaming::Name channel_name (1); channel_name.length (1); channel_name[0].id = CORBA::string_dup (this->service_name_.c_str()); naming_context->unbind (channel_name); } if (!CORBA::is_nil (scheduler.in ()) && !CORBA::is_nil (naming_context.in ())) { naming_context->unbind (schedule_name); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("EC"); } return 0; }
int ECT_Consumer_Driver::run (int argc, ACE_TCHAR* argv[]) { try { this->orb_ = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = this->orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (this->parse_args (argc, argv)) return 1; if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "Execution parameters:\n" " consumers = <%d>\n" " suppliers = <%d>\n" " type start = <%d>\n" " type count = <%d>\n" " pid file name = <%s>\n", this->n_consumers_, this->n_suppliers_, this->type_start_, this->type_count_, this->pid_file_name_?this->pid_file_name_:ACE_TEXT("nil")) ); } if (this->pid_file_name_ != 0) { FILE* pid = ACE_OS::fopen (this->pid_file_name_, "w"); if (pid != 0) { ACE_OS::fprintf (pid, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pid); } } int min_priority = ACE_Sched_Params::priority_min (ACE_SCHED_FIFO); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, min_priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) ACE_DEBUG ((LM_DEBUG, "%s: user is not superuser, " "so remain in time-sharing class\n", argv[0])); else ACE_ERROR ((LM_ERROR, "%s: ACE_OS::sched_params failed\n", argv[0])); } if (ACE_OS::thr_setprio (min_priority) == -1) { ACE_ERROR ((LM_ERROR, "(%P|%t) main thr_setprio failed," "no real-time features\n")); } CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to get the Naming Service.\n"), 1); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); CosNaming::Name schedule_name (1); schedule_name.length (1); schedule_name[0].id = CORBA::string_dup ("ScheduleService"); CORBA::Object_var sched_obj = naming_context->resolve (schedule_name); if (CORBA::is_nil (sched_obj.in ())) return 1; RtecScheduler::Scheduler_var scheduler = RtecScheduler::Scheduler::_narrow (sched_obj.in ()); CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup ("EventService"); CORBA::Object_var ec_obj = naming_context->resolve (name); RtecEventChannelAdmin::EventChannel_var channel; if (CORBA::is_nil (ec_obj.in ())) channel = RtecEventChannelAdmin::EventChannel::_nil (); else channel = RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in ()); poa_manager->activate (); this->connect_consumers (scheduler.in (), channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n")); ACE_DEBUG ((LM_DEBUG, "running the test\n")); for (;;) { ACE_Time_Value tv (1, 0); this->orb_->perform_work (tv); ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 1); if (this->active_count_ <= 0) break; } ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); this->dump_results (); this->disconnect_consumers (); if (this->shutdown_event_channel_ != 0) { channel->destroy (); } root_poa->destroy (1, 1); this->orb_->destroy (); } catch (const CORBA::SystemException& sys_ex) { sys_ex._tao_print_exception ("SYS_EX"); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("NON SYS EX"); } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { try { // First initialize the ORB, that will remove some arguments... CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Create the servant Quoter_Stock_Factory_i stock_factory_i; // Activate it to obtain the object reference Quoter::Stock_Factory_var stock_factory = stock_factory_i._this (); // Get the Naming Context reference CORBA::Object_var naming_context_object = orb->resolve_initial_references ("NameService"); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_context_object.in ()); // Create and initialize the name. CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup ("Stock_Factory"); // Bind the object naming_context->rebind (name, stock_factory.in ()); // Resolve the Event Service name[0].id = CORBA::string_dup ("EventService"); CORBA::Object_var ec_object = naming_context->resolve (name); // Now downcast the object reference to the appropriate type RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = ec->for_suppliers (); stock_factory_i.load_stock_objects (poa.in (), poa_manager.in (), supplier_admin.in ()); // **************************************************************** for (int j = 0; j != 1000; ++j) { for (int i = 1; i != argc; ++i) { try { // Get the stock object Quoter::Stock_var stock = stock_factory->get_stock (ACE_TEXT_ALWAYS_CHAR (argv[i])); CORBA::String_var full_name = stock->full_name (); // Get the price CORBA::Double price = stock->price (); Quoter::Modify_Stock_var modify_stock = Quoter::Modify_Stock::_narrow (stock.in ()); modify_stock->set_price (price + 1); cout << "Set the price of " << full_name.in () << " to " << price + 1 << endl; } catch (Quoter::Invalid_Stock_Symbol &) { cerr << "Invalid stock symbol <" << argv[i] << ">" << endl; } ACE_Time_Value tv (0, 500000); ACE_OS::sleep (tv); } } stock_factory_i.destroy_stock_objects (); // Destroy the POA, waiting until the destruction terminates poa->destroy (1, 1); orb->destroy (); } catch (CORBA::Exception &) { cerr << "CORBA exception raised!" << endl; } return 0; }
int main (int argc, char* argv[]) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Find the Naming Service. CORBA::Object_var obj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var naming_client = CosNaming::NamingContextExt::_narrow(obj.in()); // Get the Event Channel using Naming Services obj = naming_client->resolve_str("EventService"); // Downcast the object reference to an EventChannel reference. RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(obj.in()); if (CORBA::is_nil(ec.in())) { cerr << "Could not resolve EchoEventChannel." << endl; return 1; } // Get a SupplierAdmin object from the EventChannel. RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers(); // Get a ProxyPushConsumer from the SupplierAdmin. RtecEventChannelAdmin::ProxyPushConsumer_var consumer = admin->obtain_push_consumer(); // Get the RootPOA. obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); // Instantiate an EchoEventConsumer_i servant. EchoEventSupplier_i servant(orb.in()); // Register it with the RootPOA. PortableServer::ObjectId_var oid = poa->activate_object(&servant); CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in()); RtecEventComm::PushSupplier_var supplier = RtecEventComm::PushSupplier::_narrow(supplier_obj.in()); // Publish the events the supplier provides. ACE_SupplierQOS_Factory qos; qos.insert (MY_SOURCE_ID, // Supplier's unique id MY_EVENT_TYPE, // Event type 0, // handle to the rt_info structure 1); // number of calls // Connect as a supplier of the published events. consumer->connect_push_supplier (supplier.in (), qos.get_SupplierQOS ()); // Activate the POA via its POAManager. PortableServer::POAManager_var poa_manager = poa->the_POAManager(); poa_manager->activate(); // Create an event (just a string in this case). const CORBA::String_var eventData = CORBA::string_dup("Hello, world."); // Create an event set for one event RtecEventComm::EventSet events (1); events.length (1); // Initialize event header. events[0].header.source = MY_SOURCE_ID; events[0].header.type = MY_EVENT_TYPE; // Initialize data fields in event. events[0].data.any_value <<= eventData; cout << "Supplier starting sending of events" << endl; while (1) { consumer->push (events); ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS); orb->run(tv); } orb->destroy(); return 0; } catch (CORBA::Exception& ex) { cerr << "Supplier::main() Caught CORBA::Exception" << endl << ex << endl; } return 1; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { TAO_EC_Default_Factory::init_svcs (); int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_DEBUG, "server (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "server (%P|%t): sched_params failed\n")); } try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); #if (TAO_HAS_CORBA_MESSAGING == 1) CORBA::Object_var manager_object = orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (manager_object.in ()); CORBA::Any sync_scope; sync_scope <<= Messaging::SYNC_WITH_TARGET; CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_scope); policy_manager->set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); #else ACE_DEBUG ((LM_DEBUG, "CORBA Messaging disabled in this configuration," " test may not be optimally configured\n")); #endif /* TAO_HAS_MESSAGING */ CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); if (parse_args (argc, argv) != 0) return 1; TAO_EC_Event_Channel_Attributes attr (root_poa.in (), root_poa.in ()); TAO_EC_Event_Channel ec_impl (attr); ec_impl.activate (); RtecEventChannelAdmin::EventChannel_var ec = ec_impl._this (); CORBA::String_var str = orb->object_to_string (ec.in ()); if (ior_file_name != 0) { FILE *output_file= ACE_OS::fopen (ior_file_name, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_file_name), 1); ACE_OS::fprintf (output_file, "%s", str.in ()); ACE_OS::fclose (output_file); } orb->run (); PortableServer::ObjectId_var id = root_poa->servant_to_id (&ec_impl); root_poa->deactivate_object (id.in ()); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception (argv[0]); } return 0; }
int EC::run (int argc, ACE_TCHAR* argv[]) { TAO_EC_Default_Factory::init_svcs (); try { // First parse our command line options if (this->parse_args(argc, argv) != 0) { return -1; } // ORB initialization boiler plate... CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var rootpoa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var root_poa_manager = rootpoa->the_POAManager (); // Create persistent POA CORBA::PolicyList policies (2); policies.length (2); policies[0] = rootpoa->create_id_assignment_policy (PortableServer::USER_ID); policies[1] = rootpoa->create_lifespan_policy (PortableServer::PERSISTENT); ACE_CString poaname = "POA"; PortableServer::POA_var child_poa_ = rootpoa->create_POA (poaname.c_str (), root_poa_manager.in (), policies); // Create a local event channel and register it with the RootPOA. TAO_EC_Event_Channel_Attributes attributes (rootpoa.in (), rootpoa.in ()); attributes.consumer_reconnect = 1; attributes.supplier_reconnect = 1; TAO_EC_Event_Channel ec_impl (attributes); ec_impl.activate (); PortableServer::ObjectId_var ecId = PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(ecname)); child_poa_->activate_object_with_id(ecId.in(), &ec_impl); CORBA::Object_var ec_obj = child_poa_->id_to_reference(ecId.in()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in()); // Find the Naming Service. object = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var naming_context = CosNaming::NamingContextExt::_narrow(object.in()); // Create a name. CosNaming::Name name; name.length (1); name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(ecname)); name[0].kind = CORBA::string_dup (""); // Register with the name server naming_context->rebind (name, ec.in ()); root_poa_manager->activate (); // Wait for events, using work_pending()/perform_work() may help // or using another thread, this example is too simple for that. orb->run (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("EC::run"); return 1; } return 0; }
int ECT_Throughput::run (int argc, ACE_TCHAR* argv[]) { try { // Calibrate the high resolution timer *before* starting the // test. ACE_High_Res_Timer::calibrate (); this->orb_ = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = this->orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); if (this->parse_args (argc, argv)) return 1; if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "Execution parameters:\n" " consumers = <%d>\n" " suppliers = <%d>\n" " burst count = <%d>\n" " burst size = <%d>\n" " event size = <%d>\n" " burst pause = <%d>\n" " consumer type start = <%d>\n" " consumer type count = <%d>\n" " consumer type shift = <%d>\n" " supplier type start = <%d>\n" " supplier type count = <%d>\n" " supplier type shift = <%d>\n" " pid file name = <%s>\n" " concurrency HWM = <%d>\n", this->n_consumers_, this->n_suppliers_, this->burst_count_, this->burst_size_, this->event_size_, this->burst_pause_, this->consumer_type_start_, this->consumer_type_count_, this->consumer_type_shift_, this->supplier_type_start_, this->supplier_type_count_, this->supplier_type_shift_, this->pid_file_name_?this->pid_file_name_:ACE_TEXT("nil"), this->ec_concurrency_hwm_ ) ); } if (this->pid_file_name_ != 0) { FILE* pid = ACE_OS::fopen (this->pid_file_name_, "w"); if (pid != 0) { ACE_OS::fprintf (pid, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pid); } } int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_DEBUG, "%s: user is not superuser, " "so remain in time-sharing class\n", argv[0])); this->thr_create_flags_ = THR_NEW_LWP; } else ACE_ERROR ((LM_ERROR, "%s: ACE_OS::sched_params failed\n", argv[0])); } if (ACE_OS::thr_setprio (priority) == -1) { ACE_ERROR ((LM_ERROR, "(%P|%t) main thr_setprio failed," "no real-time features\n")); } #if 1 ACE_Config_Scheduler scheduler_impl; #else #include "ECT_Scheduler_Info.h" ACE_Runtime_Scheduler scheduler_impl ( runtime_configs_size, runtime_configs, runtime_infos_size, runtime_infos); #endif RtecScheduler::Scheduler_var scheduler = scheduler_impl._this (); #if 0 CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to get the Naming Service.\n"), 1); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); // This is the name we (potentially) register the Scheduling // Service in the Naming Service. CosNaming::Name schedule_name (1); schedule_name.length (1); schedule_name[0].id = CORBA::string_dup ("ScheduleService"); CORBA::String_var str = this->orb_->object_to_string (scheduler.in ()); ACE_DEBUG ((LM_DEBUG, "The (local) scheduler IOR is <%s>\n", str.in ())); // Register the servant with the Naming Context.... naming_context->rebind (schedule_name, scheduler.in ()); ACE_Scheduler_Factory::use_config (naming_context.in ()); #endif /* 0 */ auto_ptr<POA_RtecEventChannelAdmin::EventChannel> ec_impl; TAO_EC_Event_Channel_Attributes attr (root_poa.in (), root_poa.in ()); TAO_EC_Event_Channel *ec = new TAO_EC_Event_Channel (attr); ec->activate (); auto_ptr<POA_RtecEventChannelAdmin::EventChannel> auto_ec_impl (ec); ec_impl = auto_ec_impl; RtecEventChannelAdmin::EventChannel_var channel = ec_impl->_this (); this->connect_consumers (scheduler.in (), channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n")); this->connect_suppliers (scheduler.in (), channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected supplier(s)\n")); this->activate_suppliers (); ACE_DEBUG ((LM_DEBUG, "suppliers are active\n")); // Wait for the supplier threads... if (ACE_Thread_Manager::instance ()->wait () == -1) { ACE_ERROR ((LM_ERROR, "Thread_Manager wait failed\n")); return 1; } ACE_DEBUG ((LM_DEBUG, "suppliers finished\n")); this->dump_results (); this->disconnect_consumers (); ACE_DEBUG ((LM_DEBUG, "consumers disconnected\n")); this->disconnect_suppliers (); ACE_DEBUG ((LM_DEBUG, "suppliers disconnected\n")); channel->destroy (); ACE_DEBUG ((LM_DEBUG, "channel destroyed\n")); { // Deactivate the EC PortableServer::POA_var poa = ec_impl->_default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (ec_impl.get ()); poa->deactivate_object (id.in ()); ACE_DEBUG ((LM_DEBUG, "EC deactivated\n")); } { // Deactivate the Scheduler PortableServer::POA_var poa = scheduler_impl._default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (&scheduler_impl); poa->deactivate_object (id.in ()); ACE_DEBUG ((LM_DEBUG, "scheduler deactivated\n")); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("ECT_Throughput::run"); } catch (...) { ACE_ERROR ((LM_ERROR, "non-corba exception raised\n")); } return 0; }
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[]) { try { // Initialize ORB and POA, POA Manager, parse args. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) == -1) return 1; CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); if (check_for_nil (poa.in (), "POA") == -1) return 1; PortableServer::POAManager_var manager = poa->the_POAManager (); // Obtain reference to EC. obj = orb->resolve_initial_references ("Event_Service"); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (obj.in ()); if (check_for_nil (ec.in (), "EC") == -1) return 1; // Create the consumer and register it with POA. PortableServer::Servant_var<EC_Consumer> consumer_impl = new EC_Consumer (orb, ec); if (!consumer_impl.in ()) return -1; RtecEventComm::PushConsumer_var consumer; TAO_EC_Object_Deactivator consumer_deactivator; activate (consumer, poa.in (), consumer_impl.in (), consumer_deactivator); consumer_deactivator.disallow_deactivation (); // Obtain reference to ConsumerAdmin. RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = ec->for_consumers (); // Obtain ProxyPushSupplier and connect this consumer. RtecEventChannelAdmin::ProxyPushSupplier_var supplier = consumer_admin->obtain_push_supplier (); ACE_ConsumerQOS_Factory qos; qos.start_disjunction_group (3); qos.insert_type (A_EVENT_TYPE, 0); qos.insert_type (B_EVENT_TYPE, 0); qos.insert_type (C_EVENT_TYPE, 0); supplier->connect_push_consumer (consumer.in (), qos.get_ConsumerQOS ()); // Allow processing of CORBA requests. manager->activate (); // Receive events from EC. orb->run (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception in Consumer:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { try { // First initialize the ORB, that will remove some arguments... CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); CORBA::Object_var naming_context_object = orb->resolve_initial_references ("NameService"); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_context_object.in ()); CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup ("EventService"); CORBA::Object_var ec_object = naming_context->resolve (name); // Now downcast the object reference to the appropriate type RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); ACE_ConsumerQOS_Factory qos; qos.start_disjunction_group (); for (int i = 1; i != argc; ++i) { if (ACE_OS::strlen (argv[i]) < 4) continue; CORBA::ULong type = ((int(argv[i][0]) << 24) | (int(argv[i][1]) << 16) | (int(argv[i][2]) << 8) | int(argv[i][3])); qos.insert_type (type, 0); } Stock_Consumer stock_consumer_i; stock_consumer_i.connect (ec.in (), qos.get_ConsumerQOS ()); orb->run (); stock_consumer_i.disconnect (); poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception &ex) { cerr << "CORBA exception raised!" << ex << endl; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the EC Factory so we can customize the EC TAO_EC_Default_Factory::init_svcs (); // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); const ACE_TCHAR* ecname = ACE_TEXT ("EventService"); const ACE_TCHAR* remote_ecname = 0; const ACE_TCHAR* iorfile = 0; for (int i = 0; argv[i] != 0; i++) { if (ACE_OS::strcmp(argv[i], ACE_TEXT("-ecname")) == 0) { if (argv[i+1] != 0) { i++; ecname = argv[i]; } else { std::cerr << "Missing Event channel name" << std::endl; } } if (ACE_OS::strcmp(argv[i], ACE_TEXT("-gateway")) == 0) { if (argv[i+1] != 0) { i++; remote_ecname = argv[i]; } else { std::cerr << "Missing Event channel name" << std::endl; } } if (ACE_OS::strcmp(argv[i], ACE_TEXT("-iorfile")) == 0) { if (argv[i+1] != 0) { i++; iorfile = argv[i]; } } } // Get the POA CORBA::Object_var object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Spawn a thread for the orb ACE_Thread_Manager *thread_mgr = ACE_Thread_Manager::instance(); thread_mgr->spawn(orb_thread, orb.in()); // Create a local event channel and register it with the RootPOA. TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ()); PortableServer::Servant_var<TAO_EC_Event_Channel> ec_impl = new TAO_EC_Event_Channel(attributes); ec_impl->activate (); PortableServer::ObjectId_var oid = poa->activate_object(ec_impl.in()); CORBA::Object_var ec_obj = poa->id_to_reference(oid.in()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in()); // Find the Naming Service. object = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(object.in()); CosNaming::Name_var name = root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname)); root_context->rebind(name.in(), ec.in()); // Get a SupplierAdmin object from the EventChannel. RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers(); // Get a ProxyPushConsumer from the SupplierAdmin. RtecEventChannelAdmin::ProxyPushConsumer_var consumer = admin->obtain_push_consumer(); // Instantiate an EchoEventSupplier_i servant. PortableServer::Servant_var<EchoEventSupplier_i> servant = new EchoEventSupplier_i(orb.in()); // Register it with the RootPOA. oid = poa->activate_object(servant.in()); CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in()); RtecEventComm::PushSupplier_var supplier = RtecEventComm::PushSupplier::_narrow(supplier_obj.in()); // Publish the events the supplier provides. ACE_SupplierQOS_Factory qos; qos.insert (MY_SOURCE_ID, // Supplier's unique id MY_EVENT_TYPE, // Event type 0, // handle to the rt_info structure 1); // number of calls // Connect as a supplier of the published events. consumer->connect_push_supplier (supplier.in (), qos.get_SupplierQOS ()); // Create an event (just a string in this case). const CORBA::String_var eventData = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (ecname)); // Create an event set for one event RtecEventComm::EventSet event (1); event.length (1); // Initialize event header. event[0].header.source = MY_SOURCE_ID; event[0].header.ttl = 1; event[0].header.type = MY_EVENT_TYPE; // Initialize data fields in event. event[0].data.any_value <<= eventData; PortableServer::Servant_var<TAO_EC_Gateway_IIOP> gateway = new TAO_EC_Gateway_IIOP; int gateway_initialized = 0; std::cout << "Supplier starting sending of events.\n"; while (1) { consumer->push (event); ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS); orb->run(tv); if ((remote_ecname != 0) && (!gateway_initialized)) { try { // Get the remote event channel object CORBA::Object_var obj = root_context->resolve_str (ACE_TEXT_ALWAYS_CHAR (remote_ecname)); RtecEventChannelAdmin::EventChannel_var remote_ec = RtecEventChannelAdmin::EventChannel::_narrow(obj.in()); int ok = 0; if (!CORBA::is_nil(remote_ec.in())) { // Now check if we can talk to it... try { RtecEventChannelAdmin::SupplierAdmin_var adm = remote_ec->for_suppliers(); ok = 1; } catch(const CORBA::UserException&) { // What is the correct exception(s) to catch here? } } // There is a good remote event channel so initialize the // gateway. if (ok) { gateway->init(remote_ec.in(), ec.in()); PortableServer::ObjectId_var gateway_oid = poa->activate_object(gateway.in()); CORBA::Object_var gateway_obj = poa->id_to_reference(gateway_oid.in()); RtecEventChannelAdmin::Observer_var obs = RtecEventChannelAdmin::Observer::_narrow(gateway_obj.in()); RtecEventChannelAdmin::Observer_Handle local_ec_obs_handle = ec->append_observer (obs.in ()); ACE_UNUSED_ARG (local_ec_obs_handle); gateway_initialized = 1; std::cout << "Gateway initialized\n"; if (iorfile != 0) { CORBA::String_var str = orb->object_to_string( ec.in() ); std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(iorfile) ); iorFile << str.in() << std::endl; iorFile.close(); } } } catch(const CosNaming::NamingContext::NotFound&) { // Try again later... } } } orb->destroy(); return 0; } catch(const CORBA::Exception& exc) { std::cerr << "Caught CORBA::Exception" << std::endl << exc << std::endl; } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the EC Factory so we can customize the EC TAO_EC_Default_Factory::init_svcs (); // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); const ACE_TCHAR* ecname = ACE_TEXT ("EventService"); const ACE_TCHAR* address = ACE_TEXT ("localhost"); const ACE_TCHAR* iorfile = 0; u_short port = 12345; u_short listenport = 12345; int mcast = 1; for (int i = 0; argv[i] != 0; i++) { if (ACE_OS::strcmp(argv[i], ACE_TEXT("-ecname")) == 0) { if (argv[i+1] != 0) { i++; ecname = argv[i]; } else { std::cerr << "Missing Event channel name" << std::endl; } } else if (ACE_OS::strcmp(argv[i], ACE_TEXT("-address")) == 0) { if (argv[i+1] != 0) { i++; address = argv[i]; } else { std::cerr << "Missing address" << std::endl; } } else if (ACE_OS::strcmp(argv[i], ACE_TEXT("-port")) == 0) { if (argv[i+1] != 0) { i++; port = ACE_OS::atoi(argv[i]); } else { std::cerr << "Missing port" << std::endl; } } else if (ACE_OS::strcmp(argv[i], ACE_TEXT("-listenport")) == 0) { if (argv[i+1] != 0) { i++; listenport = ACE_OS::atoi(argv[i]); } else { std::cerr << "Missing port" << std::endl; } } else if (ACE_OS::strcmp(argv[i], ACE_TEXT("-iorfile")) == 0) { if (argv[i+1] != 0) { i++; iorfile = argv[i]; } } else if (ACE_OS::strcmp(argv[i], ACE_TEXT("-udp")) == 0) { mcast = 0; } } // Get the POA CORBA::Object_var object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Create a local event channel and register it TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ()); PortableServer::Servant_var<TAO_EC_Event_Channel> ec_impl = new TAO_EC_Event_Channel(attributes); ec_impl->activate (); PortableServer::ObjectId_var oid = poa->activate_object(ec_impl.in()); CORBA::Object_var ec_obj = poa->id_to_reference(oid.in()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in()); // Find the Naming Service. CORBA::Object_var obj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(obj.in()); // Bind the Event Channel using Naming Services CosNaming::Name_var name = root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname)); root_context->rebind(name.in(), ec.in()); // Get a proxy push consumer from the EventChannel. RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers(); RtecEventChannelAdmin::ProxyPushConsumer_var consumer = admin->obtain_push_consumer(); // Instantiate an EchoEventSupplier_i servant. PortableServer::Servant_var<EchoEventSupplier_i> servant = new EchoEventSupplier_i(orb.in()); // Register it with the RootPOA. oid = poa->activate_object(servant.in()); CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in()); RtecEventComm::PushSupplier_var supplier = RtecEventComm::PushSupplier::_narrow(supplier_obj.in()); // Connect to the EC. ACE_SupplierQOS_Factory qos; qos.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); consumer->connect_push_supplier (supplier.in (), qos.get_SupplierQOS ()); // Initialize the address server with the desired address. // This will be used by the sender object and the multicast // receiver. ACE_INET_Addr send_addr (port, address); PortableServer::Servant_var<SimpleAddressServer> addr_srv_impl = new SimpleAddressServer(send_addr); PortableServer::ObjectId_var addr_srv_oid = poa->activate_object(addr_srv_impl.in()); CORBA::Object_var addr_srv_obj = poa->id_to_reference(addr_srv_oid.in()); RtecUDPAdmin::AddrServer_var addr_srv = RtecUDPAdmin::AddrServer::_narrow(addr_srv_obj.in()); // Create and initialize the sender object PortableServer::Servant_var<TAO_ECG_UDP_Sender> sender = TAO_ECG_UDP_Sender::create(); TAO_ECG_UDP_Out_Endpoint endpoint; if (endpoint.dgram ().open (ACE_Addr::sap_any) == -1) { std::cerr << "Cannot open send endpoint" << std::endl; return 1; } // TAO_ECG_UDP_Sender::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the sender will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone (new TAO_ECG_UDP_Out_Endpoint (endpoint)); sender->init (ec.in (), addr_srv.in (), clone); // Setup the subscription and connect to the EC ACE_ConsumerQOS_Factory cons_qos_fact; cons_qos_fact.start_disjunction_group (); cons_qos_fact.insert (ACE_ES_EVENT_SOURCE_ANY, ACE_ES_EVENT_ANY, 0); RtecEventChannelAdmin::ConsumerQOS sub = cons_qos_fact.get_ConsumerQOS (); sender->connect (sub); // Create and initialize the receiver PortableServer::Servant_var<TAO_ECG_UDP_Receiver> receiver = TAO_ECG_UDP_Receiver::create(); // TAO_ECG_UDP_Receiver::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the receiver will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone2 (new TAO_ECG_UDP_Out_Endpoint (endpoint)); receiver->init (ec.in (), clone2, addr_srv.in ()); // Setup the registration and connect to the event channel ACE_SupplierQOS_Factory supp_qos_fact; supp_qos_fact.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); RtecEventChannelAdmin::SupplierQOS pub = supp_qos_fact.get_SupplierQOS (); receiver->connect (pub); // Create the appropriate event handler and register it with the reactor auto_ptr<ACE_Event_Handler> eh; if (mcast) { auto_ptr<TAO_ECG_Mcast_EH> mcast_eh(new TAO_ECG_Mcast_EH (receiver.in())); mcast_eh->reactor (orb->orb_core ()->reactor ()); mcast_eh->open (ec.in()); ACE_auto_ptr_reset(eh,mcast_eh.release()); //eh.reset(mcast_eh.release()); } else { auto_ptr<TAO_ECG_UDP_EH> udp_eh (new TAO_ECG_UDP_EH (receiver.in())); udp_eh->reactor (orb->orb_core ()->reactor ()); ACE_INET_Addr local_addr (listenport); if (udp_eh->open (local_addr) == -1) { std::cerr << "Cannot open EH" << std::endl; } ACE_auto_ptr_reset(eh,udp_eh.release()); //eh.reset(udp_eh.release()); } // Create an event (just a string in this case). const CORBA::String_var eventData = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (ecname)); // Create an event set for one event RtecEventComm::EventSet event (1); event.length (1); // Initialize event header. event[0].header.source = MY_SOURCE_ID; event[0].header.ttl = 1; event[0].header.type = MY_EVENT_TYPE; // Initialize data fields in event. event[0].data.any_value <<= eventData; if (iorfile != 0) { CORBA::String_var str = orb->object_to_string( ec.in() ); std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(iorfile) ); iorFile << str.in() << std::endl; iorFile.close(); } std::cout << "Starting main loop" << std::endl; const int EVENT_DELAY_MS = 10; while (1) { consumer->push (event); ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS); orb->run(tv); } orb->destroy(); return 0; } catch(const CORBA::Exception& exc) { std::cerr << "Caught CORBA::Exception" << std::endl << exc << std::endl; } return 1; }
int ECMS_Driver::run (int argc, ACE_TCHAR* argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (this->parse_args (argc, argv)) return 1; ACE_DEBUG ((LM_DEBUG, "Execution parameters:\n" " suppliers = <%d>\n" " event count = <%d>\n" " event period = <%d>\n" " event size = <%d>\n" " supplier Event A = <%d>\n" " supplier Event B = <%d>\n" " pid file name = <%s>\n", this->n_suppliers_, this->event_count_, this->event_period_, this->event_size_, this->event_a_, this->event_b_, this->pid_file_name_?this->pid_file_name_:ACE_TEXT("nil")) ); if (this->pid_file_name_ != 0) { FILE* pid = ACE_OS::fopen (this->pid_file_name_, "w"); if (pid != 0) { ACE_OS::fprintf (pid, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pid); } } int min_priority = ACE_Sched_Params::priority_min (ACE_SCHED_FIFO); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, min_priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) ACE_DEBUG ((LM_DEBUG, "%s: user is not superuser, " "so remain in time-sharing class\n", argv[0])); else ACE_ERROR ((LM_ERROR, "%s: ACE_OS::sched_params failed\n", argv[0])); } if (ACE_OS::thr_setprio (min_priority) == -1) { ACE_ERROR ((LM_ERROR, "(%P|%t) main thr_setprio failed," "no real-time features\n")); } CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to get the Naming Service.\n"), 1); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup ("EventService"); CORBA::Object_var ec_obj = naming_context->resolve (name); RtecEventChannelAdmin::EventChannel_var channel; if (CORBA::is_nil (ec_obj.in ())) channel = RtecEventChannelAdmin::EventChannel::_nil (); else channel = RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in ()); poa_manager->activate (); this->connect_suppliers (channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected supplier(s)\n")); this->activate_suppliers (); ACE_DEBUG ((LM_DEBUG, "suppliers are active\n")); // Wait for the supplier threads... if (ACE_Thread_Manager::instance ()->wait () == -1) { ACE_ERROR ((LM_ERROR, "Thread_Manager wait failed\n")); return 1; } ACE_DEBUG ((LM_DEBUG, "suppliers finished\n")); this->disconnect_suppliers (); // @@ Deactivate the suppliers (as CORBA Objects?) } catch (const CORBA::SystemException& sys_ex) { sys_ex._tao_print_exception ("SYS_EX in Supplier"); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("NON SYS EX in Supplier"); } return 0; }
RtecEventChannelAdmin::EventChannel_ptr FTEC_Gateway::activate(PortableServer::POA_ptr root_poa) { PortableServer::POA_var poa; PortableServer::POAManager_var mgr; if (impl_->local_orb) { int argc = 0; char** argv = 0; impl_->orb = CORBA::ORB_init(argc, argv, "FTEC_GatewayORB"); Interceptor_Destoryer::execute(impl_->orb.in()); poa = resolve_init<PortableServer::POA>(impl_->orb.in(), "RootPOA"); mgr = poa->the_POAManager(); mgr->activate(); } else { poa = PortableServer::POA::_duplicate(root_poa); mgr = poa->the_POAManager(); } PortableServer::IdUniquenessPolicy_var id_uniqueness_policy = poa->create_id_uniqueness_policy(PortableServer::MULTIPLE_ID); PortableServer::LifespanPolicy_var lifespan = poa->create_lifespan_policy(PortableServer::PERSISTENT); // create a USER_ID IdAssignmentPolicy object PortableServer::IdAssignmentPolicy_var assign = poa->create_id_assignment_policy(PortableServer::USER_ID); CORBA::PolicyList policy_list; policy_list.length(3); policy_list[0] = PortableServer::IdUniquenessPolicy::_duplicate( id_uniqueness_policy.in()); policy_list[1]= PortableServer::LifespanPolicy::_duplicate(lifespan.in()); policy_list[2]= PortableServer::IdAssignmentPolicy::_duplicate(assign.in()); impl_->poa = poa->create_POA("gateway_poa", mgr.in(), policy_list); id_uniqueness_policy->destroy(); lifespan->destroy(); assign->destroy(); FtRtecEventComm::ObjectId oid; oid.length(16); TAO_FtRt::UUID::create(oid.get_buffer()); RtecEventChannelAdmin::EventChannel_var gateway; activate_object_with_id(gateway.out(), impl_->poa.in(), this, oid); ++oid[9]; activate_object_with_id(impl_->consumer_admin.out(), impl_->poa.in(), &impl_->consumer_admin_servant, oid); ++oid[9]; activate_object_with_id(impl_->supplier_admin.out(), impl_->poa.in(), &impl_->supplier_admin_servant, oid); return gateway._retn(); }