void LiveEntry::do_ping (PortableServer::POA_ptr poa) { this->callback_ = new PingReceiver (this, poa); PortableServer::ObjectId_var oid = poa->activate_object (this->callback_.in()); CORBA::Object_var obj = poa->id_to_reference (oid.in()); ImplementationRepository::AMI_ServerObjectHandler_var cb = ImplementationRepository::AMI_ServerObjectHandler::_narrow (obj.in()); { ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); this->liveliness_ = LS_PING_AWAY; } try { this->ref_->sendc_ping (cb.in()); if (ImR_Locator_i::debug () > 3) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ") ACE_TEXT ("sendc_ping returned OK\n"))); } } catch (const CORBA::Exception &ex) { if (ImR_Locator_i::debug () > 3) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ") ACE_TEXT ("sendc_ping threw %C\n"), ex._name())); } this->status (LS_DEAD); } }
void activate (T & obj_ref, PortableServer::POA_ptr poa, PortableServer::ServantBase * servant, TAO_EC_Object_Deactivator & suggested_object_deactivator) { // Activate the servant into the POA. PortableServer::ObjectId_var obj_id = poa->activate_object (servant); suggested_object_deactivator.set_values (poa, obj_id.in ()); // Get the object reference of the activated object. CORBA::Object_var obj = poa->id_to_reference (obj_id.in ()); // Don't try to use T::_obj_type::_narrow, some compilers don't like it so // do this in two steps typedef typename T::_obj_type my_object_type; obj_ref = my_object_type::_narrow (obj.in()); if (CORBA::is_nil (obj_ref.in ())) { throw CORBA::INTERNAL (); } }
void test_reference_to_servant_active_object(PortableServer::POA_ptr root_poa) { test_i test; CORBA::ULong expected_refcount = 1; PortableServer::ObjectId_var id = root_poa->activate_object (&test); expected_refcount++; CORBA::Object_var object = root_poa->id_to_reference (id.in ()); PortableServer::ServantBase_var servant = root_poa->reference_to_servant (object.in ()); ++expected_refcount; root_poa->deactivate_object (id.in ()); --expected_refcount; CORBA::ULong refcount = test._refcount_value (); ACE_UNUSED_ARG (refcount); ACE_UNUSED_ARG (expected_refcount); ACE_ASSERT (expected_refcount == refcount); }
int create_object (PortableServer::POA_ptr poa, CORBA::ORB_ptr orb, Test_i *server_impl, const ACE_TCHAR *filename) { // Register with poa. PortableServer::ObjectId_var id = poa->activate_object (server_impl); CORBA::Object_var server = poa->id_to_reference (id.in ()); // Print out the IOR. CORBA::String_var ior = orb->object_to_string (server.in ()); ACE_DEBUG ((LM_DEBUG, "<%C>\n\n", ior.in ())); // Print ior to the file. if (filename != 0) { FILE *output_file= ACE_OS::fopen (filename, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", filename), -1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } return 0; }
CosNotifyFilter::FilterFactory_ptr TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_ptr filter_poa) { this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); CORBA::Object_var object = CORBA::Object::_nil(); try { PortableServer::ObjectId_var id = filter_poa->activate_object (this); object = filter_poa->id_to_reference (id.in()); } catch (PortableServer::POA::ServantAlreadyActive&) { try { object = filter_poa->servant_to_reference (this); } catch (CORBA::Exception& ) { return CosNotifyFilter::FilterFactory::_nil(); } } return CosNotifyFilter::FilterFactory::_narrow (object.in ()); }
int make_ior (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, Hello * servant, const ACE_TCHAR *ior_file) { CORBA::String_var poa_name = poa->the_name(); ACE_DEBUG ((LM_DEBUG, "Creating IOR from %C\n", poa_name.in())); PortableServer::ObjectId_var oid = poa->activate_object (servant); CORBA::Object_var o = poa->id_to_reference (oid.in ()); if (host_form == from_hostname || host_form == use_localhost) { CORBA::String_var ior = orb->object_to_string (o.in ()); FILE *output_file= ACE_OS::fopen (ior_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for writing IOR: %C", ior_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } return 0; }
Callback_ptr ServerApp::create_callback( PortableServer::POA_ptr poa, const char* servant_name) { PortableServer::ServantBase_var servant = new Callback_i(); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId("callback"); poa->activate_object_with_id(id.in(), servant.in()); CORBA::Object_var obj = poa->id_to_reference(id.in()); if (CORBA::is_nil(obj.in())) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to activate servant (%s).\n", servant_name)); throw TestException(); } Callback_var callback = Callback::_narrow (obj.in ()); return callback._retn (); }
CosNaming::NamingContext_ptr getNamingContextReference( PortableServer::POA_ptr poa, const char * oid) { PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(oid); CORBA::Object_var obj = poa->id_to_reference(id); return CosNaming::NamingContext::_narrow(obj); }
CosNotifyFilter::FilterFactory_ptr TAO_Notify_Tests_RT_Test_FilterFactory::create (PortableServer::POA_ptr filter_poa) { this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); // save the filter poa. PortableServer::ObjectId_var id = filter_poa->activate_object (this); CORBA::Object_var object = filter_poa->id_to_reference (id.in ()); CosNotifyFilter::FilterFactory_var filter = CosNotifyFilter::FilterFactory::_narrow (object.in ()); return filter._retn(); }
void create_object (PortableServer::POA_ptr poa, CORBA::ORB_ptr orb, PortableServer::Servant servant, const ACE_TCHAR *filename) { // Register with poa. PortableServer::ObjectId_var id = poa->activate_object (servant); CORBA::Object_var object = poa->id_to_reference (id.in ()); CORBA::String_var ior = orb->object_to_string (object.in ()); FILE *output_file= ACE_OS::fopen (filename, "w"); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); }
void ReconnectionCallback_i::init ( PortableServer::POA_ptr poa, CosNotifyChannelAdmin::EventChannelFactory_ptr ecf) { this->ecf_ = CosNotifyChannelAdmin::EventChannelFactory::_duplicate (ecf); PortableServer::ObjectId_var reconnection_callback_id = poa->activate_object (this); CORBA::Object_var obj = poa->id_to_reference (reconnection_callback_id.in ()); NotifyExt::ReconnectionCallback_var callback = NotifyExt::ReconnectionCallback::_narrow (obj.in ()); NotifyExt::ReconnectionRegistry_var registry = NotifyExt::ReconnectionRegistry::_narrow (ecf); this->callback_id_ = registry->register_callback (callback.in ()); this->id_is_valid_ = true; }
void test_poas (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, PortableServer::POA_ptr first_poa, PortableServer::POA_ptr second_poa, PortableServer::POA_ptr third_poa, PortableServer::POA_ptr forth_poa, int perform_deactivation_test) { { test_i servant (root_poa); CORBA::Object_var obj = root_poa->create_reference ("IDL:test:1.0"); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id = root_poa->reference_to_id (obj.in ()); root_poa->activate_object_with_id (id.in (), &servant); obj = root_poa->id_to_reference (id.in ()); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ServantBase_var servant_from_reference = root_poa->reference_to_servant (obj.in ()); PortableServer::ServantBase_var servant_from_id = root_poa->id_to_servant (id.in ()); if (servant_from_reference.in () != servant_from_id.in () || servant_from_reference.in () != &servant) { ACE_ERROR ((LM_ERROR, "Mismatched servant_from_reference, " "servant_from_id and &servant\n")); } obj = root_poa->servant_to_reference (&servant); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = servant._this (); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id_from_servant = root_poa->servant_to_id (&servant); ACE_ASSERT (id_from_servant.in () == id.in ()); root_poa->deactivate_object (id.in ()); if (perform_deactivation_test) { root_poa->activate_object_with_id (id.in (), &servant); servant_from_reference = root_poa->reference_to_servant (obj.in ()); ACE_ASSERT (servant_from_reference.in () == &servant); root_poa->deactivate_object (id.in ()); } } { test_i servant (root_poa); PortableServer::ObjectId_var id = root_poa->activate_object (&servant); CORBA::Object_var obj = root_poa->id_to_reference (id.in ()); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = root_poa->create_reference_with_id (id.in (), "IDL:test:1.0"); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); root_poa->deactivate_object (id.in ()); } { test_i servant (first_poa); CORBA::Object_var obj = first_poa->create_reference ("IDL:test:1.0"); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id = first_poa->reference_to_id (obj.in ()); first_poa->activate_object_with_id (id.in (), &servant); obj = first_poa->id_to_reference (id.in ()); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ServantBase_var servant_from_reference = first_poa->reference_to_servant (obj.in ()); PortableServer::ServantBase_var servant_from_id = first_poa->id_to_servant (id.in ()); if (servant_from_reference .in () != servant_from_id.in () || servant_from_reference.in () != &servant) { ACE_ERROR ((LM_ERROR, "Mismatched servant_from_reference, " "servant_from_id and &servant\n")); } first_poa->deactivate_object (id.in ()); if (perform_deactivation_test) { first_poa->activate_object_with_id (id.in (), &servant); servant_from_reference = first_poa->reference_to_servant (obj.in ()); ACE_ASSERT (servant_from_reference.in () == &servant); first_poa->deactivate_object (id.in ()); } } { test_i servant (first_poa); PortableServer::ObjectId_var id = first_poa->activate_object (&servant); CORBA::Object_var obj = first_poa->id_to_reference (id.in ()); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = first_poa->create_reference_with_id (id.in (), "IDL:test:1.0"); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); first_poa->deactivate_object (id.in ()); } { test_i servant (second_poa); CORBA::Object_var obj = second_poa->create_reference ("IDL:test:1.0"); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id = second_poa->reference_to_id (obj.in ()); second_poa->activate_object_with_id (id.in (), &servant); obj = second_poa->id_to_reference (id.in ()); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ServantBase_var servant_from_reference = second_poa->reference_to_servant (obj.in ()); PortableServer::ServantBase_var servant_from_id = second_poa->id_to_servant (id.in ()); if (servant_from_reference.in () != servant_from_id.in () || servant_from_reference.in () != &servant) { ACE_ERROR ((LM_ERROR, "Mismatched servant_from_reference, " "servant_from_id and &servant\n")); } obj = second_poa->servant_to_reference (&servant); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = servant._this (); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id_from_servant = second_poa->servant_to_id (&servant); ACE_ASSERT (id_from_servant.in () == id.in ()); second_poa->deactivate_object (id.in ()); if (perform_deactivation_test) { second_poa->activate_object_with_id (id.in (), &servant); servant_from_reference = second_poa->reference_to_servant (obj.in ()); ACE_ASSERT (servant_from_reference.in () == &servant); second_poa->deactivate_object (id.in ()); } } { test_i servant (second_poa); PortableServer::ObjectId_var id = second_poa->activate_object (&servant); CORBA::Object_var obj = second_poa->id_to_reference (id.in ()); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = second_poa->create_reference_with_id (id.in (), "IDL:test:1.0"); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); second_poa->deactivate_object (id.in ()); } { test_i servant (third_poa); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello"); CORBA::Object_var obj = third_poa->create_reference_with_id (id.in (), "IDL:test:1.0"); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id_from_reference = third_poa->reference_to_id (obj.in ()); string = PortableServer::ObjectId_to_string (id_from_reference.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); ACE_ASSERT (id_from_reference.in () == id.in ()); third_poa->activate_object_with_id (id.in (), &servant); obj = third_poa->id_to_reference (id.in ()); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ServantBase_var servant_from_reference = third_poa->reference_to_servant (obj.in ()); PortableServer::ServantBase_var servant_from_id = third_poa->id_to_servant (id.in ()); if (servant_from_reference.in () != servant_from_id.in () || servant_from_reference.in () != &servant) { ACE_ERROR ((LM_ERROR, "Mismatched servant_from_reference, " "servant_from_id and &servant\n")); } obj = third_poa->servant_to_reference (&servant); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); obj = servant._this (); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id_from_servant = third_poa->servant_to_id (&servant); string = PortableServer::ObjectId_to_string (id_from_servant.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); ACE_ASSERT (id_from_servant.in () == id.in ()); third_poa->deactivate_object (id.in ()); if (perform_deactivation_test) { third_poa->activate_object_with_id (id.in (), &servant); servant_from_reference = third_poa->reference_to_servant (obj.in ()); ACE_ASSERT (servant_from_reference.in () == &servant); third_poa->deactivate_object (id.in ()); } } { test_i servant (forth_poa); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello"); CORBA::Object_var obj = forth_poa->create_reference_with_id (id.in (), "IDL:test:1.0"); CORBA::String_var string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ObjectId_var id_from_reference = forth_poa->reference_to_id (obj.in ()); string = PortableServer::ObjectId_to_string (id_from_reference.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); ACE_ASSERT (id_from_reference.in () == id.in ()); forth_poa->activate_object_with_id (id.in (), &servant); obj = forth_poa->id_to_reference (id.in ()); string = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); PortableServer::ServantBase_var servant_from_reference = forth_poa->reference_to_servant (obj.in ()); PortableServer::ServantBase_var servant_from_id = forth_poa->id_to_servant (id.in ()); if (servant_from_reference.in () != servant_from_id.in () || servant_from_reference.in () != &servant) { ACE_ERROR ((LM_ERROR, "Mismatched servant_from_reference, " "servant_from_id and &servant\n")); } forth_poa->deactivate_object (id.in ()); if (perform_deactivation_test) { forth_poa->activate_object_with_id (id.in (), &servant); servant_from_reference = forth_poa->reference_to_servant (obj.in ()); ACE_ASSERT (servant_from_reference.in () == &servant); forth_poa->deactivate_object (id.in ()); } } }
void FooServantList::create_and_activate(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) { poa_ = PortableServer::POA::_duplicate (poa); for (unsigned i = 0; i < this->num_servants_; i++) { ACE_TCHAR buf[32]; ACE_OS::sprintf(buf, ACE_TEXT("%02d"), i + 1); ACE_TString servant_name = this->prefix_ + ACE_TEXT("_") + buf; this->servants_[i] = new Foo_i(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str()),this); this->safe_servants_[i] = this->servants_[i]; PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str())); poa->activate_object_with_id(id.in(), this->safe_servants_[i].in()); CORBA::Object_var obj = poa->id_to_reference(id.in()); if (CORBA::is_nil(obj.in())) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to activate servant (%s).\n", servant_name.c_str())); throw TestException(); } // create the collocated object reference. if (this->collocated_test_ && i == 0) { Foo_var collocated = Foo::_narrow (obj.in ()); // Create the servant object. Callback_i* servant = new Callback_i (); // local smart pointer variable to deal with releasing the reference // to the servant object when the smart pointer object falls out of scope. PortableServer::ServantBase_var safe_servant(servant); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId("callback"); poa->activate_object_with_id(id.in(), safe_servant.in()); CORBA::Object_var obj = poa->id_to_reference(id.in()); if (CORBA::is_nil(obj.in())) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to activate servant (%s).\n", servant_name.c_str())); throw TestException(); } Callback_var callback = Callback::_narrow (obj.in ()); collocated_client_ = new ClientTask(orb, collocated.in (), callback.in (), true); if (collocated_client_->open() != 0) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to open the collocated client.\n")); throw TestException(); } } CORBA::String_var ior = this->orb_->object_to_string(obj.in()); ACE_TString filename = servant_name + ACE_TEXT(".ior"); FILE* ior_file = ACE_OS::fopen(filename.c_str(), "w"); if (ior_file == 0) { ACE_ERROR((LM_ERROR, "(%P|%t) Cannot open output file (%s) for writing IOR.", filename.c_str())); throw TestException(); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) writing IOR to file %s\n", filename.c_str())); } ACE_OS::fprintf(ior_file, "%s", ior.in()); ACE_OS::fclose(ior_file); } }
int run_buffer_size (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, Test::AMI_Buffering_ptr ami_buffering, Test::AMI_Buffering_Admin_ptr ami_buffering_admin) { TAO::BufferingConstraint buffering_constraint; buffering_constraint.mode = TAO::BUFFER_MESSAGE_BYTES; buffering_constraint.message_count = 0; buffering_constraint.message_bytes = BUFFER_SIZE; buffering_constraint.timeout = 0; Test::AMI_Buffering_var flusher; int test_failed = configure_policies (orb, buffering_constraint, ami_buffering, flusher.out ()); if (test_failed != 0) return test_failed; Test::Payload payload (PAYLOAD_LENGTH); payload.length (PAYLOAD_LENGTH); Reply_Handler *reply_handler_impl; ACE_NEW_RETURN (reply_handler_impl, Reply_Handler, 1); PortableServer::ServantBase_var owner_transfer(reply_handler_impl); PortableServer::ObjectId_var id = root_poa->activate_object (reply_handler_impl); CORBA::Object_var object_act = root_poa->id_to_reference (id.in ()); Test::AMI_AMI_BufferingHandler_var reply_handler = Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ()); CORBA::ULong bytes_sent = 0; for (int i = 0; i != iterations; ++i) { sync_server (orb, flusher.in ()); CORBA::ULong initial_bytes_received = ami_buffering_admin->bytes_received_count (); if (initial_bytes_received != bytes_sent) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d data lost (%u != %u)\n", i, initial_bytes_received, bytes_sent)); } while (1) { ami_buffering->sendc_receive_data (reply_handler.in (), payload); bytes_sent += PAYLOAD_LENGTH; CORBA::ULong bytes_received = ami_buffering_admin->bytes_received_count (); ACE_Time_Value tv (0, 10 * 1000); orb->run (tv); CORBA::ULong payload_delta = bytes_sent - initial_bytes_received; if (bytes_received != initial_bytes_received) { // The queue has been flushed, check that enough data // has been sent. The check cannot be precise because // the ORB counts the GIOP message overhead, in this // test we assume the overhead to be less than 10% if (payload_delta < CORBA::ULong (GIOP_OVERHEAD * BUFFER_SIZE)) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d flush before " "minimum buffer size was reached. " "Sent = %u, Minimum buffer = %u bytes\n", i, payload_delta, BUFFER_SIZE)); } break; } if (payload_delta > 2 * BUFFER_SIZE) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d no flush past " "buffer size threshold. " "Sent = %u, Minimum buffer = %u bytes\n", i, payload_delta, BUFFER_SIZE)); break; } } } int liveness_test_failed = run_liveness_test (orb, reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin); if (liveness_test_failed) test_failed = 1; return test_failed; }
int run_timeout_reactive (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, Test::AMI_Buffering_ptr ami_buffering, Test::AMI_Buffering_Admin_ptr ami_buffering_admin) { TAO::BufferingConstraint buffering_constraint; buffering_constraint.mode = TAO::BUFFER_TIMEOUT; buffering_constraint.message_count = 0; buffering_constraint.message_bytes = 0; buffering_constraint.timeout = TIMEOUT_MILLISECONDS * 10000; Test::AMI_Buffering_var flusher; int test_failed = configure_policies (orb, buffering_constraint, ami_buffering, flusher.out ()); if (test_failed != 0) return test_failed; Test::Payload payload (PAYLOAD_LENGTH); payload.length (PAYLOAD_LENGTH); for (int j = 0; j != PAYLOAD_LENGTH; ++j) payload[j] = CORBA::Octet(j % 256); Reply_Handler *reply_handler_impl = 0; ACE_NEW_RETURN (reply_handler_impl, Reply_Handler, 1); PortableServer::ServantBase_var owner_transfer(reply_handler_impl); PortableServer::ObjectId_var id = root_poa->activate_object (reply_handler_impl); CORBA::Object_var object_act = root_poa->id_to_reference (id.in ()); Test::AMI_AMI_BufferingHandler_var reply_handler = Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ()); CORBA::ULong send_count = 0; int retry_attempt = 0; for (int i = 0; i != iterations; ++i) { sync_server (orb, flusher.in ()); CORBA::ULong initial_receive_count = ami_buffering_admin->request_count (); if (initial_receive_count != send_count) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d message lost (%u != %u)\n", i, initial_receive_count, send_count)); } ACE_Time_Value start = ACE_OS::gettimeofday (); for (int j = 0; j != 20; ++j) { ami_buffering->sendc_receive_data (reply_handler.in (), payload); send_count++; } while (1) { CORBA::ULong receive_count = ami_buffering_admin->request_count (); ACE_Time_Value tv (0, 10 * 1000); orb->run (tv); ACE_Time_Value elapsed = ACE_OS::gettimeofday () - start; if (receive_count != initial_receive_count) { if (elapsed.msec () < TIMEOUT_MILLISECONDS) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d flush before " "timeout expired. " "Elapsed = %d, Timeout = %d msecs\n", i, elapsed.msec (), TIMEOUT_MILLISECONDS)); } // terminate the while loop. break; } if (elapsed.msec () > TIMEOUT_TOLERANCE) { if (retry_attempt++ < 10) { ACE_DEBUG ((LM_DEBUG, "DEBUG: Retry attempt %d beyond TIMEOUT_TOLERANCE.\n", retry_attempt)); continue; } test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d no flush past " "timeout threshold. " "Elapsed = %d, Timeout = %d msecs\n", i, elapsed.msec (), TIMEOUT_TOLERANCE)); break; } } } #if 0 int liveness_test_failed = run_liveness_test (orb, reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin); if (liveness_test_failed) test_failed = 1; #endif /* 0 */ return test_failed; }
int run_message_count (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, Test::AMI_Buffering_ptr ami_buffering, Test::AMI_Buffering_Admin_ptr ami_buffering_admin) { TAO::BufferingConstraint buffering_constraint; buffering_constraint.mode = TAO::BUFFER_MESSAGE_COUNT; buffering_constraint.message_count = BUFFERED_MESSAGES_COUNT; buffering_constraint.message_bytes = 0; buffering_constraint.timeout = 0; Test::AMI_Buffering_var flusher; int test_failed = configure_policies (orb, buffering_constraint, ami_buffering, flusher.out ()); if (test_failed != 0) return test_failed; Test::Payload payload (PAYLOAD_LENGTH); payload.length (PAYLOAD_LENGTH); for (int j = 0; j != PAYLOAD_LENGTH; ++j) payload[j] = CORBA::Octet(j % 256); Reply_Handler *reply_handler_impl = 0; ACE_NEW_RETURN (reply_handler_impl, Reply_Handler, 1); PortableServer::ServantBase_var owner_transfer(reply_handler_impl); PortableServer::ObjectId_var id = root_poa->activate_object (reply_handler_impl); CORBA::Object_var object_act = root_poa->id_to_reference (id.in ()); Test::AMI_AMI_BufferingHandler_var reply_handler = Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ()); CORBA::ULong send_count = 0; for (int i = 0; i != iterations; ++i) { sync_server (orb, flusher.in ()); CORBA::ULong initial_receive_count = ami_buffering_admin->request_count (); if (initial_receive_count != send_count) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d message lost (%u != %u)\n", i, initial_receive_count, send_count)); } while (1) { ami_buffering->sendc_receive_data (reply_handler.in (), payload); send_count++; CORBA::ULong receive_count = ami_buffering_admin->request_count (); ACE_Time_Value tv (0, 10 * 1000); orb->run (tv); CORBA::ULong iteration_count = send_count - initial_receive_count; if (receive_count != initial_receive_count) { if (iteration_count < CORBA::ULong(BUFFERED_MESSAGES_COUNT)) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d flush before " "message count reached. " "Iteration count = %u, Threshold = %u\n", i, iteration_count, BUFFERED_MESSAGES_COUNT)); } break; } if (iteration_count > 2 * BUFFERED_MESSAGES_COUNT) { test_failed = 1; ACE_DEBUG ((LM_DEBUG, "DEBUG: Iteration %d no flush past " "message count threshold. " "Iteration count = %u, Threshold = %u\n", i, iteration_count, BUFFERED_MESSAGES_COUNT)); break; } } } int liveness_test_failed = run_liveness_test (orb, reply_handler.in (), ami_buffering, flusher.in (), ami_buffering_admin); if (liveness_test_failed) test_failed = 1; return test_failed; }
void test_object_deactivation (PortableServer::POA_ptr poa, const PortableServer::ObjectId &id) { test_i servant; int expected_exception_raised = 0; PortableServer::ObjectId_var invalid_id = PortableServer::string_to_ObjectId ("invalid id"); try { poa->deactivate_object (invalid_id.in ()); } catch (const PortableServer::POA::ObjectNotActive& ) { // This is the correct exception! Ignore expected_exception_raised = 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Exception caught of incorrect type"); ACE_ASSERT (0); } // Make sure an exception was raised and it was of the correct // type. ACE_ASSERT (expected_exception_raised); poa->activate_object_with_id (id, &servant); poa->deactivate_object (id); // Reset flag expected_exception_raised = 0; try { poa->deactivate_object (id); } catch (const PortableServer::POA::ObjectNotActive& ) { // This is the correct exception! Ignore expected_exception_raised = 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Exception caught of incorrect type"); ACE_ASSERT (0); } // Make sure an exception was raised and it was of the correct // type. ACE_ASSERT (expected_exception_raised); poa->activate_object_with_id (id, &servant); servant.poa_ = PortableServer::POA::_duplicate (poa); servant.id_ = id; CORBA::Object_var object = poa->id_to_reference (id); test_var test = test::_narrow (object.in ()); test->deactivate_self (); // ACE_ASSERT dissappears in non-debug builds ACE_UNUSED_ARG (expected_exception_raised); }