void do_primary_test (CORBA::Object_var &server, Messaging::ReplyHandler_var &callback) { try { CORBA::Request_var req = server->_request("do_forward"); if (CORBA::is_nil (server.in ())) { ACE_ERROR ((LM_ERROR, "Object reference <%s> is nil.\n", ior)); return; } ACE_DEBUG((LM_DEBUG,"Client sending test string\n")); CORBA::String_var test_string = CORBA::string_dup ("123 look at me"); req->add_in_arg ("text") <<= CORBA::Any::from_string(test_string.in(),30); req->sendc(callback.in()); } catch (CORBA::Exception &ex) { ACE_ERROR ((LM_ERROR, "Client caught exception: %C\n",ex._name())); } }
void test_octet_seq (const CORBA::Object_var object) { ACE_Sample_History history (niterations); Test::octet_load ol (sz); ol.length (sz); ACE_hrtime_t test_start = ACE_OS::gethrtime (); for (int i = 0; i < niterations; ++i) { ACE_hrtime_t start = ACE_OS::gethrtime (); Test::Timestamp start_time = static_cast <Test::Timestamp> (start); CORBA::Request_var request = object->_request ("test_octet_method"); request->add_in_arg("octet_load") <<= ol; request->add_in_arg("send_time") <<= start_time; request->set_return_type (CORBA::_tc_ulonglong); request->invoke (); ACE_hrtime_t now = ACE_OS::gethrtime (); history.sample (now - start); } ACE_hrtime_t test_end = ACE_OS::gethrtime (); ACE_DEBUG ((LM_DEBUG, "test finished\n")); ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "done\n")); if (do_dump_history) { history.dump_samples (ACE_TEXT("HISTORY"), gsf); } ACE_Basic_Stats stats; history.collect_basic_stats (stats); stats.dump_results (ACE_TEXT("Total"), gsf); ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf, test_end - test_start, stats.samples_count ()); }
int do_shutdown_test (CORBA::Object_var &server) { ACE_DEBUG ((LM_DEBUG, "[client] invoking shutdown on the server \n")); try { CORBA::Request_var req = server->_request("shutdown"); req->invoke(); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client: exception caught during shutdown - "); return 1; } return 0; }
VALUE rCORBA_Object_request(VALUE self, VALUE op_name) { CORBA::Object_ptr obj; CORBA::Request_var req; obj = r2tao_Object_r2t (self); Check_Type(op_name, T_STRING); R2TAO_TRY { req = obj->_request (RSTRING(op_name)->ptr); } R2TAO_CATCH; return r2tao_Request_t2r (req.in ()); }
CORBA::Request_ptr createRequest(GenericCmd const& cmd) { CORBA::Request_var req = cmd.reference->_request(cmd.methodName); for (CORBA::ULong i = 0; i < cmd.parameters.length(); ++i) { switch (cmd.parameters[i].direction) { case PARAM_IN: { CORBA::Any& a = req->add_in_arg(cmd.parameters[i].name); a = cmd.parameters[i].value; } break; case PARAM_OUT: { CORBA::Any& a = req->add_out_arg(cmd.parameters[i].name); a = cmd.parameters[i].value; } break; case PARAM_INOUT: { CORBA::Any& a = req->add_inout_arg(cmd.parameters[i].name); a = cmd.parameters[i].value; } break; default: MIRO_ASSERT(false); } } req->set_return_type(cmd.returnType); CORBA::ExceptionList_ptr e = req->exceptions(); for (CORBA::ULong i = 0; i < cmd.exceptions.length(); ++i) { e->add(cmd.exceptions[i]); } return req._retn(); }
int Worker::svc (void) { try { for (int i = 0; i < this->niterations_; ++i) { // Minimum CORBA does not define Object::_request, so we're just // skipping the DII part in those cases. #if (!defined(TAO_HAS_MINIMUM_CORBA) || (TAO_HAS_MINIMUM_CORBA == 0)) if (this->use_dii_too_) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Invoking server->invoked_by_client() via DII\n"))); CORBA::Request_var request = this->server_->_request ("invoked_by_client"); request->set_return_type (CORBA::_tc_void); request->invoke (); } #endif /* (!defined(TAO_HAS_MINIMUM_CORBA) || (TAO_HAS_MINIMUM_CORBA == 0)) */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Invoking server->invoked_by_client() via SII\n"))); this->server_->invoked_by_client (); if (TAO_debug_level > 0 && i % 100 == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Iteration = %d\n"), i)); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client: exception raised"); } return 0; }
int main(int argc, char * argv[]) { Miro::Log::init(argc, argv); Miro::Client client(argc, argv); if (parseArgs(argc, argv) == -1) return 1; GenericCmd cmd; cmd.objectName = CORBA::string_dup("Basic"); cmd.reference = client.resolveName<CORBA::Object>("Basic"); // // call s0 // cmd.methodName = CORBA::string_dup("s0"); cmd.returnType = CORBA::_tc_void; CORBA::Request_var req0 = createRequest(cmd); req0->invoke(); reportResult(req0); // // call s1 // cmd.methodName = CORBA::string_dup("s1"); cmd.parameters.length(3); cmd.parameters[0].name = CORBA::string_dup("p1"); cmd.parameters[0].direction = PARAM_IN; cmd.parameters[0].value <<= CORBA::Long(2); cmd.parameters[1].name = CORBA::string_dup("p1"); cmd.parameters[1].direction = PARAM_OUT; cmd.parameters[1].value <<= CORBA::Long(); cmd.parameters[2].name = CORBA::string_dup("p1"); cmd.parameters[2].direction = PARAM_INOUT; cmd.parameters[2].value <<= CORBA::Long(4); cmd.returnType = CORBA::_tc_long; CORBA::Request_var req1 = createRequest(cmd); req1->invoke(); reportResult(req1); // // call s2 // cmd.methodName = CORBA::string_dup("s2"); cmd.parameters.length(3); cmd.parameters[0].value <<= CORBA::string_dup("hello"); cmd.parameters[1].value <<= CORBA::string_dup(""); cmd.parameters[2].value <<= CORBA::string_dup("world"); cmd.returnType = CORBA::_tc_string; CORBA::Request_var req2 = createRequest(cmd); req2->invoke(); reportResult(req2); // // call e0 // cmd.methodName = CORBA::string_dup("e0"); cmd.parameters.length(0); cmd.exceptions.length(1); cmd.exceptions[0] = _tc_EFoo; cmd.returnType = CORBA::_tc_void; CORBA::Request_var reqE = createRequest(cmd); try { reqE->invoke(); } catch (XMP::EFoo const& e) { cout << "caught exception " << e.what << endl; } catch (CORBA::Exception const& e) { cout << "caught corba exception " << e << endl; } reportResult(reqE); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; // 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, "client (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "client (%P|%t): sched_params failed\n")); } try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var object = orb->string_to_object (ior); if (CORBA::is_nil (object.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Nil CORBA::Object reference <%s>\n", ior), 1); } for (int j = 0; j < 100; ++j) { CORBA::Request_var request = object->_request ("test_method"); CORBA::ULongLong dummy = 0; request->add_in_arg("send_time") <<= dummy; request->set_return_type (CORBA::_tc_ulonglong); request->invoke (); } ACE_Sample_History history (niterations); ACE_hrtime_t test_start = ACE_OS::gethrtime (); for (int i = 0; i < niterations; ++i) { ACE_hrtime_t start = ACE_OS::gethrtime (); CORBA::Request_var request = object->_request ("test_method"); CORBA::ULongLong start_time = static_cast <CORBA::ULongLong> (start); request->add_in_arg("send_time") <<= start_time; request->set_return_type (CORBA::_tc_ulonglong); request->invoke (); ACE_hrtime_t now = ACE_OS::gethrtime (); history.sample (now - start); } ACE_hrtime_t test_end = ACE_OS::gethrtime (); ACE_DEBUG ((LM_DEBUG, "test finished\n")); ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "done\n")); if (do_dump_history) { history.dump_samples (ACE_TEXT("HISTORY"), gsf); } ACE_Basic_Stats stats; history.collect_basic_stats (stats); stats.dump_results (ACE_TEXT("Total"), gsf); ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf, test_end - test_start, stats.samples_count ()); if (do_shutdown) { CORBA::Request_var request = object->_request ("shutdown"); request->invoke (); } } 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; CORBA::Object_var obj = orb->string_to_object(ior); const char* the_string = 0; ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Synchronous twoway DII\n")); CORBA::Request_var req = obj->_request ("get_string"); req->set_return_type (CORBA::_tc_string); req->invoke (); req->return_value () >>= the_string; ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", the_string)); ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Deferred twoway DII (using get_response())\n")); req = obj->_request ("get_string"); req->set_return_type (CORBA::_tc_string); req->send_deferred (); ACE_DEBUG ((LM_INFO, "(%P|%t) - Get response...\n")); req->get_response (); req->return_value () >>= the_string; ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", the_string)); ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Deferred twoway DII (using poll_response())\n")); req = obj->_request ("get_string"); req->set_return_type (CORBA::_tc_string); req->send_deferred (); do { ACE_OS::sleep(1); ACE_DEBUG ((LM_INFO, "(%P|%t) - Polling...\n")); } while (!req->poll_response ()); req->return_value () >>= the_string; ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", the_string)); ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Oneway shutdown DII\n")); req = obj->_request ("shutdown"); req->send_oneway (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; // 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, "client (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "client (%P|%t): sched_params failed\n")); } try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var object = orb->string_to_object (ior); if (CORBA::is_nil (object.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Nil CORBA::Object reference <%s>\n", ior), 1); } Test::octet_load oc; for (int j = 0; j < 100; ++j) { CORBA::Request_var request = object->_request ("test_octet_method"); Test::Timestamp dummy = 0; request->add_in_arg("octet_load") <<= oc; request->add_in_arg("send_time") <<= dummy; request->set_return_type (CORBA::_tc_ulonglong); request->invoke (); } // Test various sequence types if (ACE_OS::strcmp (data_type, ACE_TEXT("octet")) == 0 ) { test_octet_seq (object); } else if (ACE_OS::strcmp (data_type, ACE_TEXT("char")) == 0) { test_char_seq (object); } else if (ACE_OS::strcmp (data_type, ACE_TEXT("long")) == 0) { test_long_seq (object); } else if (ACE_OS::strcmp (data_type, ACE_TEXT("short")) == 0) { test_short_seq (object); } else if (ACE_OS::strcmp (data_type, ACE_TEXT("double")) == 0) { test_double_seq (object); } else if (ACE_OS::strcmp (data_type, ACE_TEXT("longlong")) == 0) { test_longlong_seq (object); } if (do_shutdown) { CORBA::Request_var request = object->_request ("shutdown"); request->invoke (); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }