PriorityBand_Setup::PriorityBand_Setup (CORBA::ORB_ptr orb, const RTCORBA_Setup &rtcorba_setup) { CORBA::PolicyManager_var policy_manager = RIR_Narrow<CORBA::PolicyManager>::resolve (orb, "ORBPolicyManager"); RTCORBA::RTORB_var rtorb = RIR_Narrow<RTCORBA::RTORB>::resolve (orb, "RTORB"); const RTCORBA::ThreadpoolLanes &lanes = rtcorba_setup.lanes (); RTCORBA::PriorityBands priority_bands (3); priority_bands.length (3); for (CORBA::ULong i = 0; i != lanes.length (); ++i) { priority_bands[i].low = lanes[i].lane_priority; priority_bands[i].high = lanes[i].lane_priority; } CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = rtorb->create_priority_banded_connection_policy (priority_bands); policy_manager->set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE); policy_list[0]->destroy (); }
RTPOA_Setup::RTPOA_Setup (CORBA::ORB_ptr orb, const RTCORBA_Setup &rtcorba_setup) { RTPortableServer::POA_var root_poa = RIR_Narrow<RTPortableServer::POA>::resolve (orb, "RootPOA"); RTCORBA::RTORB_var rtorb = RIR_Narrow<RTCORBA::RTORB>::resolve (orb, "RTORB"); const CORBA::ULong stacksize = 1024 * 1024; // 1 Mb const RTCORBA::ThreadpoolLanes &lanes = rtcorba_setup.lanes (); const CORBA::Boolean allow_borrowing = 0; const CORBA::Boolean allow_request_buffering = 0; const CORBA::ULong max_buffered_requests = 0; // dummy value const CORBA::ULong max_request_buffer_size = 0; // dummy value RTCORBA::ThreadpoolId pool_id = rtorb->create_threadpool_with_lanes (stacksize, lanes, allow_borrowing, allow_request_buffering, max_buffered_requests, max_request_buffer_size); // @@ We need an 'auto_ptr for thread pools' here! CORBA::PolicyList policies (4); policies.length (4); policies[0] = rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, rtcorba_setup.process_priority ()); policies[1] = root_poa->create_id_assignment_policy (PortableServer::SYSTEM_ID); policies[2] = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); #if 0 policies.length (3); #else policies[3] = rtorb->create_threadpool_policy (pool_id); #endif /* 0 */ PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); this->poa_ = root_poa->create_POA ("RTEC_Perf", poa_manager.in (), policies); for (CORBA::ULong i = 0; i != policies.length (); ++i) { policies[i]->destroy (); } }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); object = orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (object.in ()); int parse_args_result = parse_args (argc, argv); if (parse_args_result != 0) return parse_args_result; object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); object = orb->string_to_object (ior); test_var receiver = test::_narrow (object.in ()); test_i *servant = new test_i (orb.in (), root_poa.in (), rtorb.in (), policy_manager.in (), receiver.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); test_var test = servant->_this (); CORBA::String_var ior = orb->object_to_string (test.in ()); FILE *output_file = ACE_OS::fopen (ior_file, "w"); ACE_ASSERT (output_file != 0); u_int result = ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_ASSERT (result == ACE_OS::strlen (ior.in ())); ACE_UNUSED_ARG (result); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_OS::sleep(1); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args(argc, argv) != 0) return 1; // Get the RTORB. CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (obj.in()); //create the private connections policy. This means that every connection // to the server uses his own socket. CORBA::PolicyList policies (1); policies.length (1); policies[0] = rtorb->create_private_connection_policy (); CORBA::Object_var pol_current_object = orb->resolve_initial_references ("PolicyCurrent"); CORBA::PolicyCurrent_var policy_current = CORBA::PolicyCurrent::_narrow (pol_current_object.in ()); if (CORBA::is_nil (policy_current.in ())) { ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n")); return 1; } policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); Test::Hello_var *hello_array = 0; ACE_NEW_RETURN (hello_array, Test::Hello_var [cache_size], -1); int iter = 1; for (iter = 1; iter <= cache_size; ++iter) { char object_string[256]; char reference_string[256]; ACE_OS::sprintf (reference_string, "TransportCacheTest%d", iter); ACE_OS::sprintf (object_string, "corbaloc:iiop:localhost:%d/", port_nr); ACE_OS::strcat (object_string, reference_string); CORBA::Object_var hello_obj = orb->string_to_object (object_string); orb->register_initial_reference (reference_string, hello_obj.in ()); CORBA::String_var ior_string = orb->object_to_string (hello_obj.in()); ACE_DEBUG((LM_DEBUG, ACE_TEXT("IOR string for reference %d : %C\n"), iter, ior_string.in ())); hello_array[iter-1] = Test::Hello::_narrow(hello_obj.in ()); } //now we've got the references -> call each and everyone of them for (iter = 0; iter < cache_size; ++iter) { Test::Hello_var hello = hello_array[iter]; if (CORBA::is_nil (hello.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("Nil Test::Hello reference\n")), 1); } CORBA::String_var the_string = hello->get_string (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C> from reference %d\n", the_string.in (), iter + 1)); } //shutdown the server if (iter >= 0) hello_array[0]->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
void CIDL_SenderImpl::SenderExec_i::start ( ::CORBA::ULong iterations, ::CORBA::ULong invocation_rate, ::CORBA::Boolean count_missed_end_deadlines, ::CORBA::Boolean do_dump_history, ::CORBA::Boolean print_missed_invocations, ::CORBA::ULong message_size, ::CORBA::ULong test_protocol_tag, ::CORBA::Boolean print_statistics, ::CORBA::ULong number_of_connection_attempts, ::CORBA::Boolean enable_diffserv_code_points, ::CORBA::Short priority, ::Protocols::Sender_Controller::Test_Type test_type ) { ACE_DEBUG ((LM_DEBUG, "CIDL_SenderImpl::SenderExec_i::start\n")); gsf = ACE_High_Res_Timer::global_scale_factor (); int argc = 0; char **argv = 0; this->orb_ = CORBA::ORB_init (argc, argv); CORBA::Object_var object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("NetworkPriorityMappingManager"); RTCORBA::NetworkPriorityMappingManager_var mapping_manager = RTCORBA::NetworkPriorityMappingManager::_narrow (object.in ()); Custom_Network_Priority_Mapping *custom_network_priority_mapping = new Custom_Network_Priority_Mapping; // Set the desired corba priority on the network mapping manager custom_network_priority_mapping->corba_priority (priority); mapping_manager->mapping (custom_network_priority_mapping); Protocols::test_var test = this->context_->get_connection_reader (); Worker worker (this->orb_.in (), rtorb.in (), policy_manager.in (), test.in (), iterations, invocation_rate, count_missed_end_deadlines, do_dump_history, print_missed_invocations, message_size, test_protocol_tag, number_of_connection_attempts, enable_diffserv_code_points, test_type); worker.setup (); worker.run (); if (print_statistics) worker.print_stats (); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB first. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); /* * The following code should be reenabled once the OMG spec has * been fixed such that a RTCORBA::PriorityModelPolicy can be * created by using the ORB::create_policy interface. * { RTCORBA::PriorityModelPolicy_var policy1 = rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, RTCORBA::minPriority); CORBA::Any policy_value; policy_value <<= RTCORBA::CLIENT_PROPAGATED; policy_value <<= RTCORBA::minPriority; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE, policy_value); RTCORBA::PriorityModelPolicy_var policy2 = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->priority_model () == policy2->priority_model ()); ACE_ASSERT (policy1->server_priority () == policy2->server_priority ()); } */ { RTCORBA::ThreadpoolId poolid = 0; RTCORBA::ThreadpoolPolicy_var policy1 = rtorb->create_threadpool_policy (poolid); CORBA::Any policy_value; policy_value <<= poolid; CORBA::Policy_var policy = orb->create_policy (RTCORBA::THREADPOOL_POLICY_TYPE, policy_value); RTCORBA::ThreadpoolPolicy_var policy2 = RTCORBA::ThreadpoolPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->threadpool () == policy2->threadpool ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ServerProtocolPolicy_var policy1 = rtorb->create_server_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::SERVER_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ServerProtocolPolicy_var policy2 = RTCORBA::ServerProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ClientProtocolPolicy_var policy1 = rtorb->create_client_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ClientProtocolPolicy_var policy2 = RTCORBA::ClientProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::PrivateConnectionPolicy_var policy1 = rtorb->create_private_connection_policy (); CORBA::Any policy_value; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PrivateConnectionPolicy_var policy2 = RTCORBA::PrivateConnectionPolicy::_narrow (policy.in ()); } { RTCORBA::PriorityBands empty_priority_bands; RTCORBA::PriorityBandedConnectionPolicy_var policy1 = rtorb->create_priority_banded_connection_policy (empty_priority_bands); CORBA::Any policy_value; policy_value <<= empty_priority_bands; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PriorityBandedConnectionPolicy_var policy2 = RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy.in ()); RTCORBA::PriorityBands_var priority_bands1 = policy1->priority_bands (); RTCORBA::PriorityBands_var priority_bands2 = policy2->priority_bands (); ACE_ASSERT (priority_bands1->length () == priority_bands2->length ()); } ACE_DEBUG ((LM_DEBUG, "%s successful\n", argv[0])); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }