diff options
author | yamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-12-08 01:19:59 +0000 |
---|---|---|
committer | yamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-12-08 01:19:59 +0000 |
commit | 96742f20fe998607786eda574240f52eb5c9562f (patch) | |
tree | 19d230b7007e040f46c3436bfe462a8166ac70fc | |
parent | deec8aca8d6544420c127bc84de2d93075ec7370 (diff) | |
download | ATCD-96742f20fe998607786eda574240f52eb5c9562f.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp | 111 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/child.h | 47 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp | 234 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/client.h | 11 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/server.cpp | 230 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/AVStreams/benchmark/server.h | 29 |
6 files changed, 289 insertions, 373 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp b/TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp index 4e7dcc9d485..225bf115633 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp @@ -4,8 +4,55 @@ ACE_RCSID(benchmark, child, "$Id$") -// Bench_Server_StreamEndPoint methods. +Server_Globals::Server_Globals (void) + :ready_cond_ (ready_mtx_), + hostname_ (0), + port_ (0) +{ +} + +int +Server_Globals::parse_args (int argc,char **argv) +{ + ACE_Get_Opt opts (argc,argv,"pa:r"); + + char child_name [BUFSIZ], buf[BUFSIZ]; + ACE_OS::strcpy (child_name,"child_process"); + this->strategy_ = REACTIVE_STRATEGY; + int c; + while ((c = opts ()) != -1) + { + switch (c) + { + case 'p': + // process based strategy + this->strategy_ = PROCESS_STRATEGY; + break; + case 'a': + ACE_NEW_RETURN (addr_, + ACE_INET_Addr (opts.optarg), + -1); + this->port_ = this->addr_->get_port_number (); + this->hostname_ = (char*) this->addr_->get_host_name (); + break; + case 'r': + //Reactive Stratgey + this->strategy_ = REACTIVE_STRATEGY; + break; + case 'c': + ACE_OS::strcpy (child_name,opts.optarg); + break; + default: + ACE_ERROR_RETURN ((LM_ERROR,"Usage: server [-p/-r]"),-1); + } + } + ACE_OS::sprintf (buf,"%s -ORBobjrefstyle url",child_name); + this->process_options_.command_line (buf); + return 0; +} + +// Bench_Server_StreamEndPoint methods. Bench_Server_StreamEndPoint::Bench_Server_StreamEndPoint (void) { } @@ -19,7 +66,6 @@ Bench_Server_StreamEndPoint::handle_open (void) int Bench_Server_StreamEndPoint::handle_close (void) { - // called when streamendpoint is being destructed return 0; } @@ -49,72 +95,65 @@ Bench_Server_StreamEndPoint::handle_connection_requested (AVStreams::flowSpec &t CORBA::Environment &/* env */) { - ACE_DEBUG ((LM_DEBUG,"(%P|%t) Bench_Server_StreamEndPoint::handle_connection_requested:() length =%d\n", + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Bench_Server_StreamEndPoint::handle_connection_requested:() length =%d\n", the_spec.length ())); - - TAO_Forward_FlowSpec_Entry *entry; - ACE_NEW_RETURN (entry, - TAO_Forward_FlowSpec_Entry, - 0); - - entry->parse (the_spec[0]); - // ACE_OS::strcpy(client_address_string, "danzon:5000"); - ACE_INET_Addr client_addr (entry->address_str ());//client_address_string); - char address [BUFSIZ]; - ACE_OS::strcpy (address, client_addr.get_host_name ()); - ACE_OS::strcat (address, ":5000"); - - ACE_INET_Addr new_client_addr (address); - + char buf [BUFSIZ]; + SERVER_GLOBALS::instance ()->addr_->addr_to_string (buf, BUFSIZ); + ACE_INET_Addr client_addr (buf); + u_short local_port = 0; ACE_INET_Addr local_addr (local_port); if (this->connector_.connect (this->tcp_stream_, - new_client_addr, + client_addr, 0, local_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Connection to server failed: %p\n", "connect "), 0); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t) tcp connect succeeded %d\n",this->tcp_stream_.get_handle ())); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) tcp connect succeeded %d\n", + this->tcp_stream_.get_handle ())); int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; if (this->tcp_stream_.set_option (SOL_SOCKET, - SO_SNDBUF, - (void *) &sndbufsize, - sizeof (sndbufsize)) == -1 + SO_SNDBUF, + (void *) &sndbufsize, + sizeof (sndbufsize)) == -1 && errno != ENOTSUP) return 0; else if (this->tcp_stream_.set_option (SOL_SOCKET, SO_RCVBUF, - (void *) &rcvbufsize, - sizeof (rcvbufsize)) == -1 + (void *) &rcvbufsize, + sizeof (rcvbufsize)) == -1 && errno != ENOTSUP) return 0; int one = 1; if (this->tcp_stream_.set_option (SOL_SOCKET, TCP_NODELAY, - (char *)& one, - sizeof (one)) == -1 ) + (char *)& one, + sizeof (one)) == -1 ) return 0; - + ACE_NEW_RETURN (this->stream_handler_, ttcp_Stream_Handler (this->tcp_stream_.get_handle ()), 0); int result; - + result = TAO_ORB_Core_instance ()->reactor ()->register_handler (this->stream_handler_, ACE_Event_Handler::READ_MASK); if (result < 0) return 0; - - ACE_DEBUG ((LM_DEBUG,"(%P|%t) register handler for tcp_Stream success\n")); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) register handler for tcp_Stream success\n")); return 1; } @@ -136,8 +175,6 @@ ttcp_Stream_Handler::get_handle (void) const int ttcp_Stream_Handler::handle_input (ACE_HANDLE /* handle */) { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) Bench_Server_StreamEndPoint::handle_input ()\n")); - char buf[BUFSIZ]; int result = ACE_OS::read (this->control_handle_,buf,BUFSIZ); if (result < 0 ) @@ -150,4 +187,8 @@ ttcp_Stream_Handler::handle_input (ACE_HANDLE /* handle */) return 0; } - +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Singleton<Server_Globals,ACE_SYNCH_MUTEX>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Singleton <Server_Globals,ACE_SYNCH_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/child.h b/TAO/orbsvcs/tests/AVStreams/benchmark/child.h index 2e06d225380..19cd6a3d6e5 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/child.h +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/child.h @@ -3,6 +3,8 @@ #ifndef TAO_AV_BENCH_CHILD_H #define TAO_AV_BENCH_CHILD_H + +#include "ace/Log_Msg.h" #include "ace/Get_Opt.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -20,6 +22,51 @@ #include "ace/SOCK_Connector.h" #include "client.h" +class Server_Globals +{ + // = TITLE + // Globals class to be used as a singleton. + // + // = DESCRIPTION + // This is used both by the client. +public: + Server_Globals (void); + // constructor. + + int parse_args (int argc,char **argv); + //parse the arguments. + + ACE_Barrier *barrier_; + // barrier for the client threads. + + int ready_; + // ready flag used by the high priority thread to wake up the low + // priority threads after it's parsed the arguments. + + ACE_SYNCH_MUTEX ready_mtx_; + // mutex for the condition variable. + + ACE_SYNCH_CONDITION ready_cond_; + // condition variable for the low priority threads to wait + //until the high priority thread is done with the arguments parsing. + + char *hostname_; + // hostname to bind to. + + u_short port_; + // port number to bind to. + enum strategy {PROCESS_STRATEGY=0,REACTIVE_STRATEGY=1}; + strategy strategy_; + // strategy to be used for MMDevice. + + ACE_INET_Addr* addr_; + + ACE_Process_Options process_options_; + // The process options for the process to be spawned by the process strategy +}; + +typedef ACE_Singleton <Server_Globals,ACE_SYNCH_MUTEX> SERVER_GLOBALS; + class ttcp_Stream_Handler : public virtual ACE_Event_Handler { diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp b/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp index 7962c44421e..d3481b9596a 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp @@ -29,20 +29,15 @@ Client_StreamEndPoint::handle_close (void) CORBA::Boolean Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec) { - // return 1; - the_spec.length (0); - ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_preconnect called\n")); return 0; } // called by the A/V framework after calling connect. Passes the -// server streamendpoints' flowspec which we use to connect our +// serer streamendpoints' flowspec which we use to connect our // datagram socket. CORBA::Boolean Client_StreamEndPoint::handle_postconnect (AVStreams::flowSpec& /* server_spec */) { - // return 1; - ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_postconnect called \n")); return 0; } @@ -95,59 +90,19 @@ ttcp_Client_StreamEndPoint::ttcp_Client_StreamEndPoint (Client *client) CORBA::Boolean ttcp_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec) { - // listen for the tcp socket. - - ACE_INET_Addr tcp_addr; - - // tcp_addr.set (TCP_PORT,"mambo-atm.cs.wustl.edu"); - tcp_addr.set (TCP_PORT); - - if (this->acceptor_.open (tcp_addr, + ACE_INET_Addr addr (GLOBALS::instance ()->port_, GLOBALS::instance ()->hostname_); + + if (this->acceptor_.open (addr, TAO_ORB_Core_instance ()->reactor ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR,"%p\n","open"),0); - ACE_INET_Addr local_addr; + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n","open") + ,0); + ACE_INET_Addr local_addr; if (this->acceptor_.acceptor ().get_local_addr (local_addr) == -1) - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t)acceptor get local addr failed %p"),0); - - - char client_address_string [BUFSIZ]; - - ::sprintf (client_address_string, - "%s:%d", - local_addr.get_host_name (), - local_addr.get_port_number ()); - - ACE_INET_Addr addr (client_address_string); - - - char *flowname_; - ACE_NEW_RETURN (flowname_, - char [BUFSIZ], - 0); - ACE_OS::sprintf (flowname_, - "Data_%s", - "TCP"); - - char flow_protocol_str [BUFSIZ]; - ACE_OS::strcpy (flow_protocol_str,""); - - TAO_Forward_FlowSpec_Entry entry (flowname_, - "IN", - "USER_DEFINED", - flow_protocol_str, - "TCP", - &addr); - - entry.set_local_addr (&addr); - - the_spec [0] = CORBA::string_dup (entry.entry_to_string ()); - the_spec.length (1); - - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) client flow spec is %s\n", - client_address_string)); + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t)acceptor get local addr failed %p"), + 0); return 1; } @@ -155,7 +110,8 @@ ttcp_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec) CORBA::Boolean ttcp_Client_StreamEndPoint::handle_postconnect (AVStreams::flowSpec& /* server_spec */) { - ACE_DEBUG ((LM_DEBUG,"ttcp_Client_StreamEndPoint::handle_postconnect \n")); + ACE_DEBUG ((LM_DEBUG, + "ttcp_Client_StreamEndPoint::handle_postconnect \n")); this->client_->set_stream (this->peer ()); return 1; } @@ -167,13 +123,13 @@ ttcp_Client_StreamEndPoint::open (void *) return 0; } -Client::Client (int argc, char **argv,int task_id) - :ttcp_reactive_strategy_ (&orb_manager_,this), - reactive_strategy_ (&orb_manager_), - client_mmdevice_ (0), - argc_ (argc), - argv_ (argv), - task_id_ (task_id) +Client::Client (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, int task_id) + : orb_ (orb), + poa_ (poa), + ttcp_reactive_strategy_ (orb, poa,this), + reactive_strategy_ (orb, poa), + client_mmdevice_ (0), + task_id_ (task_id) { } @@ -221,7 +177,6 @@ Globals::parse_args (int argc, this->thread_count_ = ACE_OS::atoi (opts.optarg); break; case 's': - // use ttcp strategy. this->strategy_ = TTCP_REACTIVE; break; case '?': @@ -237,7 +192,6 @@ int Client::svc (void) { - printf ("Within the SVC method\n"); // Now start pumping data. ACE_High_Res_Timer timer; ACE_Time_Value tv1,tv2; @@ -245,23 +199,12 @@ Client::svc (void) ACE_DEBUG ((LM_DEBUG, "(%P|%t) Thread created\n")); - if (GLOBALS::instance ()->parse_args (this->argc_,this->argv_) == -1) - return -1; ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY { - this->orb_manager_.init (this->argc_, - this->argv_, - ACE_TRY_ENV); - ACE_TRY_CHECK; - if (this->task_id_ == 0) { ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ready_mon, GLOBALS::instance ()->ready_mtx_, 1)); - if (GLOBALS::instance ()->parse_args (this->argc_, - this->argv_) == -1) - return -1; ACE_NEW_RETURN (GLOBALS::instance ()->barrier_, ACE_Barrier (GLOBALS::instance ()->thread_count_), @@ -288,14 +231,18 @@ Client::svc (void) -1); break; } - + // activate the client MMDevice with the ORB - this->orb_manager_.activate (this->client_mmdevice_, - ACE_TRY_ENV); + this->poa_->activate_object (this->client_mmdevice_, + ACE_TRY_ENV); ACE_TRY_CHECK; - - this->orb_manager_.activate_poa_manager (ACE_TRY_ENV); - + + //Activate POA Manager + PortableServer::POAManager_var mgr + = this->poa_->the_POAManager (); + + mgr->activate (); + if (this->bind_to_server () == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Error binding to the naming service\n"), @@ -307,48 +254,43 @@ Client::svc (void) ACE_DEBUG ((LM_DEBUG, "(%P|%t) All threads finished, starting tests.\n")); ACE_Time_Value tv (0); - this->orb_manager_.run (ACE_TRY_ENV,&tv); + this->orb_->run (&tv, ACE_TRY_ENV); ACE_TRY_CHECK; AVStreams::streamQoS_var the_qos (new AVStreams::streamQoS); AVStreams::flowSpec_var the_flows (new AVStreams::flowSpec); - // Bind the client and server mmdevices. - - ACE_INET_Addr addr ("danzon:5000"); - - char* flowname_; - ACE_NEW_RETURN (flowname_, - char [BUFSIZ], - 0); - ACE_OS::sprintf (flowname_, - "Data_%s", - "TCP"); - TAO_Forward_FlowSpec_Entry entry (flowname_, - "IN", - "USER_DEFINED", - "", - "TCP", - &addr); - - AVStreams::flowSpec flow_spec (1); - flow_spec [0] = CORBA::string_dup (entry.entry_to_string ()); - flow_spec.length (1); - + + ACE_DEBUG ((LM_DEBUG, + "Host %d ,Port %s\n", + GLOBALS::instance ()->port_, GLOBALS::instance ()->hostname_)); + + ACE_INET_Addr addr (GLOBALS::instance ()->port_, + GLOBALS::instance ()->hostname_); + + char buf [BUFSIZ]; + addr.addr_to_string (buf, BUFSIZ); + + ACE_DEBUG ((LM_DEBUG, + "Client Svc %s\n", + buf)); + + AVStreams::flowSpec flow_spec (0); + timer.start (); - this->streamctrl_.bind_devs - (this->client_mmdevice_->_this (), - this->server_mmdevice_.in (), - the_qos.inout (), - flow_spec, - ACE_TRY_ENV); + this->streamctrl_.bind_devs (this->client_mmdevice_->_this (), + this->server_mmdevice_.in (), + the_qos.inout (), + flow_spec, + ACE_TRY_ENV); ACE_TRY_CHECK; - timer.stop (); timer.elapsed_time (tv1); + long time_taken = tv1.sec () + tv1.usec () /1000000; tv1.dump (); + ACE_DEBUG ((LM_DEBUG,"(%P|%t)time taken for stream setup is %ld \n", time_taken )); - + #if !defined (ACE_LACKS_SOCKET_BUFSIZ) int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; @@ -367,6 +309,7 @@ Client::svc (void) if ((result == -1)&& (errno != ENOTSUP)) ACE_ERROR_RETURN ((LM_ERROR,"set_option failed for rcvbufsize:%p\n",""),-1); #endif /* ACE_LACKS_SOCKET_BUFSIZ */ + #if defined (TCP_NODELAY) int one = 1; result = this->stream_.set_option (SOL_SOCKET, @@ -415,21 +358,8 @@ Client::bind_to_server (void) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - /* - CORBA::Object_var naming_obj = - this->orb_manager_.orb ()->resolve_initial_references ("NameService"); - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to resolve the Name Service.\n"), - -1); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_obj.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; - */ - // Initialize the naming services - if (my_name_client_.init (this->orb_manager_.orb ()) != 0) + if (my_name_client_.init (this->orb_.in()) != 0) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize " "the TAO_Naming_Client. \n"), @@ -439,11 +369,11 @@ Client::bind_to_server (void) server_mmdevice_name.length (1); server_mmdevice_name [0].id = CORBA::string_dup ("Bench_Server_MMDevice"); - CORBA::Object_var server_mmdevice_obj = - my_name_client_->resolve (server_mmdevice_name, - ACE_TRY_ENV); + CORBA::Object_var server_mmdevice_obj + = my_name_client_->resolve (server_mmdevice_name, + ACE_TRY_ENV); ACE_TRY_CHECK; - + this->server_mmdevice_ = AVStreams::MMDevice::_narrow (server_mmdevice_obj.in (), ACE_TRY_ENV); @@ -472,8 +402,8 @@ Client::establish_stream (void) AVStreams::streamQoS_var the_qos (new AVStreams::streamQoS); AVStreams::flowSpec_var the_flows (new AVStreams::flowSpec); - // Bind the client and server mmdevices. + // Bind the client and server mmdevices. ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { @@ -501,9 +431,10 @@ Client::establish_stream (void) // ----------------------------------------------------------- // Video_Endpoint_Reactive_Strategy_A methods -ttcp_Endpoint_Reactive_Strategy_A::ttcp_Endpoint_Reactive_Strategy_A (TAO_ORB_Manager *orb_manager, - Client *client) - : TAO_AV_Endpoint_Reactive_Strategy_A<ttcp_Client_StreamEndPoint,TAO_VDev,AV_Null_MediaCtrl> (orb_manager), +ttcp_Endpoint_Reactive_Strategy_A::ttcp_Endpoint_Reactive_Strategy_A (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Client *client) + : TAO_AV_Endpoint_Reactive_Strategy_A<ttcp_Client_StreamEndPoint,TAO_VDev,AV_Null_MediaCtrl> (orb, poa), client_ (client) { } @@ -524,8 +455,14 @@ int main (int argc, char **argv) { + //TAO_debug_level++; + + if (GLOBALS::instance ()->parse_args (argc, argv) == -1) + return -1; + GLOBALS::instance ()->thread_count_ = 1; - // Preliminary argument processing. + + // Preliminary argument processing. int i; for (i=0;i< argc;i++) { @@ -535,15 +472,30 @@ main (int argc, char **argv) ACE_OS::atoi (argv[i+1]); } + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv); + + CORBA::Object_var obj + = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa + = PortableServer::POA::_narrow (obj); + + //Activate POA Manager + PortableServer::POAManager_var mgr + = poa->the_POAManager (); + + mgr->activate (); + for (i = 0; i < GLOBALS::instance ()->thread_count_; i++) { - Client *client; + Client* client; ACE_NEW_RETURN (client, - Client (argc, - argv, + Client (orb.in (), + poa.in (), i), -1); - + if (client->activate (THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Error in activate: %p", diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/client.h b/TAO/orbsvcs/tests/AVStreams/benchmark/client.h index c33f6f2b4ca..7cd84ea8431 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/client.h +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/client.h @@ -97,12 +97,15 @@ private: // The Acceptor. Client *client_; + + }; class ttcp_Endpoint_Reactive_Strategy_A : public TAO_AV_Endpoint_Reactive_Strategy_A<ttcp_Client_StreamEndPoint,TAO_VDev,AV_Null_MediaCtrl> { public: - ttcp_Endpoint_Reactive_Strategy_A (TAO_ORB_Manager *orb_manager, + ttcp_Endpoint_Reactive_Strategy_A (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, Client *client_ptr); // constructor . The orb manager is needed for the TAO_AV_Endpoint_Reactive_Strategy_A. @@ -169,7 +172,7 @@ class Client : public ACE_Task<ACE_SYNCH> // one of these per client thread { public: - Client (int argc, char **argv, int task_id); + Client (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, int task_id); virtual int svc (void); @@ -182,6 +185,10 @@ private: TAO_ORB_Manager orb_manager_; + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + TAO_Naming_Client my_name_client_; ttcp_Endpoint_Reactive_Strategy_A ttcp_reactive_strategy_; diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/server.cpp b/TAO/orbsvcs/tests/AVStreams/benchmark/server.cpp index 57193844f71..66abe6e7a52 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/server.cpp +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/server.cpp @@ -5,158 +5,52 @@ ACE_RCSID(benchmark, server, "$Id$") -// // AV_Server_Sig_Handler routines -// AV_Server_Sig_Handler::AV_Server_Sig_Handler (void) -// { -// } -// int -// AV_Server_Sig_Handler::register_handler (void) -// { -// // Assign the Sig_Handler a dummy I/O descriptor. Note that even -// // though we open this file "Write Only" we still need to use the -// // ACE_Event_Handler::NULL_MASK when registering this with the -// // ACE_Reactor (see below). -// this->handle_ = ACE_OS::open (ACE_DEV_NULL, O_WRONLY); -// // ACE_ASSERT (this->handle_ != -1); -// // ACE_DEBUG ((LM_DEBUG,"(%P|%t) sig_handler == %d\n",this->handle_)); -// // Register signal handler object. Note that NULL_MASK is used to -// // keep the ACE_Reactor from calling us back on the "/dev/null" -// // descriptor. - -// if (TAO_ORB_Core_instance ()->reactor ()->register_handler -// (this, ACE_Event_Handler::NULL_MASK) == -1) -// ACE_ERROR_RETURN ((LM_ERROR, -// "%p\n", -// "register_handler"), -// -1); - -// // handles these signals. -// // this->sig_set.fill_set (); -// // this->sig_set.sig_add (SIGCHLD); -// // this->sig_set.sig_add (SIGBUS); -// // this->sig_set.sig_add (SIGINT); -// // this->sig_set.sig_add (SIGTERM); - -// // Register the signal handler object to catch the signals. if -// // if (TAO_ORB_Core_instance ()->reactor ()->register_handler -// // (this->sig_set, this) == -1) -// // ACE_ERROR_RETURN ((LM_ERROR, -// // "%p\n", -// // "register_handler"), -// // -1); -// return 0; -// } - -// // Called by the ACE_Reactor to extract the fd. -// ACE_HANDLE -// AV_Server_Sig_Handler::get_handle (void) const -// { -// return this->handle_; -// } - -// int -// AV_Server_Sig_Handler::handle_input (ACE_HANDLE) -// { -// ACE_DEBUG ((LM_DEBUG, "(%t) handling asynchonrous input...\n")); -// return 0; -// } - -// int -// AV_Server_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask) -// { -// ACE_DEBUG ((LM_DEBUG, "(%t) closing down Sig_Handler...\n")); -// return 0; -// } - -// // This method handles all the signals that are being caught by this -// // object. In our simple example, we are simply catching SIGALRM, -// // SIGINT, and SIGQUIT. Anything else is logged and ignored. -// // -// // There are several advantages to using this approach. First, -// // the behavior triggered by the signal is handled in the main event -// // loop, rather than in the signal handler. Second, the ACE_Reactor's -// // signal handling mechanism eliminates the need to use global signal -// // handler functions and data. - -// // int -// // AV_Server_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) -// // { -// // ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); - -// // // switch (signum) -// // // { -// // // case SIGCHLD: -// // // // Handle the death of child signal. -// // // this->clear_child (SIGCHLD); -// // // break; -// // // case SIGBUS: -// // // // Handle the Bus error signal -// // // case SIGINT: -// // // // Handle the interrupt signal -// // // case SIGTERM: -// // // // Handle the process termination signal. -// // // this->int_handler (signum); -// // // break; -// // // default: -// // // // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %S: not handled, returning to program\n", signum)); -// // // break; -// // // } -// // return 0; -// // } - -// AV_Server_Sig_Handler::~AV_Server_Sig_Handler (void) -// { -// TAO_ORB_Core_instance ()->reactor ()->remove_handler (this->sig_set); -// } +Server::Server (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) + : orb_ (orb), + poa_ (poa), + process_strategy_ (&SERVER_GLOBALS::instance ()->process_options_), + reactive_strategy_(orb, poa), + mmdevice_ (0) +{ +} -//------------------------------------------------------------ -Server::Server (void) - :process_strategy_ (&process_options_), - reactive_strategy_(&orb_manager_), - mmdevice_ (0) +CORBA::ORB_ptr +Server::orb (void) { + return this->orb_; } - -// Initializes the mpeg server +// Initializes the server int -Server::init (int argc, - char *argv[], - CORBA::Environment& ACE_TRY_ENV) +Server::init (int argc, char** argv, CORBA::Environment& ACE_TRY_ENV) { ACE_TRY { - // Initialize the orb_manager - this->orb_manager_.init_child_poa (argc, - argv, - "child_poa", - ACE_TRY_ENV); - ACE_TRY_CHECK; - - CORBA::ORB_var orb = - this->orb_manager_.orb (); - PortableServer::POA_var child_poa = - this->orb_manager_.child_poa (); + //Activate POA Manager + PortableServer::POAManager_var mgr + = this->poa_->the_POAManager (); - - int result = this->parse_args (argc,argv); + mgr->activate (); + + int result = SERVER_GLOBALS::instance ()->parse_args (argc, + argv); + if (result == -1) ACE_ERROR_RETURN ((LM_ERROR,"parse args failed\n"),-1); - // Initialize the naming services - if (my_name_client_.init (orb.in ()) != 0) + // Initialize the naming services + if (my_name_client_.init (this->orb_.in ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize " "the TAO_Naming_Client. \n"), -1); - - // Register the video mmdevice object with the ORB - switch (this->strategy_) + + switch (SERVER_GLOBALS::instance ()->strategy_) { case REACTIVE_STRATEGY: ACE_NEW_RETURN (this->mmdevice_, @@ -169,35 +63,27 @@ Server::init (int argc, -1); break; default: - ACE_ERROR_RETURN ((LM_ERROR,"Invalid strategy\n"),-1); + ACE_ERROR_RETURN ((LM_ERROR, + "Invalid strategy\n"), + -1); } - // create the video server mmdevice with the naming service pointer. - this->orb_manager_.activate_under_child_poa ("Bench_Server_MMDevice", - this->mmdevice_, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - // Register the mmdevice with the naming service. + + // Register the mmdevice with the naming service. CosNaming::Name server_mmdevice_name (1); server_mmdevice_name.length (1); server_mmdevice_name [0].id = CORBA::string_dup ("Bench_Server_MMDevice"); - // Register the video control object with the naming server. this->my_name_client_->rebind (server_mmdevice_name, this->mmdevice_->_this (), ACE_TRY_ENV); ACE_TRY_CHECK; - // result = this->signal_handler_.register_handler (); - // if (result < 0) - // ACE_ERROR_RETURN ((LM_ERROR, - // "(%P|%t) Error registering signal handler"), - // -1); } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"Server::init"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Server::init"); return -1; } ACE_ENDTRY; @@ -205,37 +91,6 @@ Server::init (int argc, return 0; } -int -Server::parse_args (int argc,char **argv) -{ - ACE_Get_Opt opts (argc,argv,"pr"); - - char child_name [BUFSIZ], buf[BUFSIZ]; - ACE_OS::strcpy (child_name,"child_process"); - this->strategy_ = REACTIVE_STRATEGY; - int c; - while ((c = opts ()) != -1) - { - switch (c) - { - case 'p': - // process based strategy - this->strategy_ = PROCESS_STRATEGY; - break; - case 'r': - this->strategy_ = REACTIVE_STRATEGY; - break; - case 'c': - ACE_OS::strcpy (child_name,opts.optarg); - break; - default: - ACE_ERROR_RETURN ((LM_ERROR,"Usage: server [-p/-r]"),-1); - } - } - ACE_OS::sprintf (buf,"%s -ORBobjrefstyle url",child_name); - this->process_options_.command_line (buf); - return 0; -} // Runs the server int @@ -244,7 +99,7 @@ Server::run (CORBA::Environment& ACE_TRY_ENV) // Run the ORB event loop while (1) { - this->orb_manager_.run (ACE_TRY_ENV); + this->orb_->run (ACE_TRY_ENV); ACE_CHECK_RETURN (-1); if (errno== EINTR) continue; @@ -274,14 +129,27 @@ Server::~Server (void) int main (int argc, char **argv) { - Server server; + + //TAO_debug_level++; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv); + + CORBA::Object_var obj + = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa + = PortableServer::POA::_narrow (obj); + + Server server (orb, poa); + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { + if (server.init (argc, argv, ACE_TRY_ENV) == -1) return 1; - ACE_TRY_CHECK; - + server.run (ACE_TRY_ENV); ACE_TRY_CHECK; } diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/server.h b/TAO/orbsvcs/tests/AVStreams/benchmark/server.h index df3e11256ec..fd72238ab91 100644 --- a/TAO/orbsvcs/tests/AVStreams/benchmark/server.h +++ b/TAO/orbsvcs/tests/AVStreams/benchmark/server.h @@ -5,7 +5,6 @@ // NOTE: If you encounter trouble resolving the Naming Service, try // running the Naming Service and the server in the same window. [MJB] - #ifndef TAO_AV_BENCH_SERVER_H #define TAO_AV_BENCH_SERVER_H @@ -63,25 +62,26 @@ private: class Server { public: - Server (void); + Server (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa); // Default constructor - int init (int argc, - char **argv, - CORBA::Environment& env); + int init (int argc, char** argv, CORBA::Environment& env); int run (CORBA::Environment& env); + + CORBA::ORB_ptr orb (void); + ~Server (void); private: - enum strategy {PROCESS_STRATEGY=0,REACTIVE_STRATEGY=1}; - int parse_args (int argc, char **argv); - // parses the arguments. - - TAO_ORB_Manager orb_manager_; + //TAO_ORB_Manager orb_manager_; // the TAO ORB manager. + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + TAO_Naming_Client my_name_client_; // The TAO Naming server @@ -90,8 +90,7 @@ private: // AV_Server_Sig_Handler signal_handler_; - ACE_Process_Options process_options_; - // The process options for the process to be spawned by the process strategy + TAO_AV_Endpoint_Process_Strategy_B process_strategy_; // The proces strategy for the video. @@ -102,8 +101,10 @@ private: TAO_MMDevice *mmdevice_; // The video server multimedia device - strategy strategy_; - // flag indicating strategy. + enum strategy {PROCESS_STRATEGY=0,REACTIVE_STRATEGY=1}; + }; + + #endif /* TAO_AV_BENCH_SERVER_H */ |