From 822e8c49bdddfe87b20e040714aed627a668c583 Mon Sep 17 00:00:00 2001 From: nanbor Date: Sat, 29 Nov 2003 05:58:30 +0000 Subject: ChangeLogTag:Fri Nov 28 22:45:13 2003 Nanbor Wang --- TAO/CIAO/ChangeLog | 24 +++ TAO/CIAO/ciao/ServerActivator_Impl.cpp | 9 +- TAO/CIAO/ciao/ServerActivator_Impl.h | 6 +- .../Priority_Test/Controllers/Rate_Controller.cpp | 4 +- .../RTCCM/Priority_Test/Controllers/client.cpp | 75 +++++++--- .../RTCCM/Priority_Test/descriptors/basic_test.pl | 57 +++++-- .../Priority_Test/descriptors/no-rt-3rates.cad | 103 +++++++++++++ .../RTCCM/Priority_Test/descriptors/rate_test.pl | 166 +++++++++++++++++++++ TAO/CIAO/tools/ComponentServer/ComponentServer.cpp | 34 ++++- TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp | 16 +- 10 files changed, 445 insertions(+), 49 deletions(-) create mode 100644 TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/no-rt-3rates.cad create mode 100755 TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/rate_test.pl diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index 0ed94cbc029..78eb7f81e23 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,27 @@ +Fri Nov 28 22:45:13 2003 Nanbor Wang + + * ciao/ServerActivator_Impl.cpp: + * ciao/ServerActivator_Impl.h: + * tools/Daemon/CIAO_Daemon.cpp: Added support for specifying + optional command line flags for starting ComponentServer. + + * tools/ComponentServer/ComponentServer.cpp: Added support to run + the ComponentServer in FIFO scheduling class. You can do this + by defining the environment variable CIAO_FIFO_SCHED as 1. + + * tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp: Fixed + cut-and-paste errors in DLL entry points for creating component + in different rates. + + * tests/RTCCM/Priority_Test/descriptors/basic_test.pl: Enhanced + the script to optionally disable starting of daemon and running + of client controller. + + * tests/RTCCM/Priority_Test/Controllers/client.cpp: + * tests/RTCCM/Priority_Test/descriptors/rate_test.pl: + * tests/RTCCM/Priority_Test/descriptors/no-rt-3rates.cad: Extended + the test to handle starting and stoping of 3 controller objrefs. + Fri Nov 28 14:32:58 2003 Nanbor Wang * tests/RTCCM/Priority_Test/Controllers/Controller.mpc: diff --git a/TAO/CIAO/ciao/ServerActivator_Impl.cpp b/TAO/CIAO/ciao/ServerActivator_Impl.cpp index 24b74bbe755..bba93c72663 100644 --- a/TAO/CIAO/ciao/ServerActivator_Impl.cpp +++ b/TAO/CIAO/ciao/ServerActivator_Impl.cpp @@ -66,7 +66,8 @@ CIAO::ServerActivator_Impl::init (const char *server_location, CORBA::ULong spawn_delay, const char *installation_ior, const char *default_svcconf, - const char *svc_conf_map + const char *svc_conf_map, + const char *extra_flags ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { @@ -88,6 +89,9 @@ CIAO::ServerActivator_Impl::init (const char *server_location, if (default_svcconf != 0) this->default_svcconf_file_ = default_svcconf; + if (extra_flags != 0) + this->extra_flags_ = extra_flags; + this->server_path_ = CORBA::string_dup (server_location); this->installation_ior_ = CORBA::string_dup (installation_ior); @@ -333,6 +337,9 @@ CIAO::ServerActivator_Impl::create_component_server (const Components::ConfigVal additional_options += ACE_CString (config_info.rtcad_filename_.in ()); } + additional_options += " "; + additional_options += this->extra_flags_; + options.command_line ("%s -k %s -ORBInitRef ComponentInstallation=%s " "%s", this->server_path_.in (), diff --git a/TAO/CIAO/ciao/ServerActivator_Impl.h b/TAO/CIAO/ciao/ServerActivator_Impl.h index a1be2c2c6b3..c80df8abef8 100644 --- a/TAO/CIAO/ciao/ServerActivator_Impl.h +++ b/TAO/CIAO/ciao/ServerActivator_Impl.h @@ -138,7 +138,8 @@ namespace CIAO CORBA::ULong delay, const char *installation_ior, const char *default_svcconf, - const char *svcconf_map_file + const char *svcconf_map_file, + const char *extra_cmdline_flags ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); @@ -237,6 +238,9 @@ namespace CIAO /// Default svc.conf filename. ACE_CString default_svcconf_file_; + /// Extra command line flags + ACE_CString extra_flags_; + typedef ACE_Hash_Map_Manager_Ex, diff --git a/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp b/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp index 15d429a5d38..94419f545aa 100644 --- a/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp +++ b/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp @@ -208,7 +208,7 @@ extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr createControllerHome50_Impl (void) { if (CIAO::debug_level () > 0) - ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (25hz)\n")); + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (50hz)\n")); return new MyImpl::Rate_Controller_Home_i (50); } @@ -216,6 +216,6 @@ extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr createControllerHome75_Impl (void) { if (CIAO::debug_level () > 0) - ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (25hz)\n")); + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (75hz)\n")); return new MyImpl::Rate_Controller_Home_i (75); } diff --git a/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp b/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp index ecec707a994..b76d818e005 100644 --- a/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp +++ b/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp @@ -9,12 +9,13 @@ #include "ace/Get_Opt.h" #include "ace/streams.h" -char *controller_ior_ = 0; int ctrl_off = 0; long work = 80; +typedef ACE_Unbounded_Stack STRING_STACK; +typedef ACE_Unbounded_Stack CTRL_STACK; int -parse_args (int argc, char *argv[]) +parse_args (int argc, char *argv[], STRING_STACK &iors) { ACE_Get_Opt get_opts (argc, argv, "k:fw:"); int c; @@ -24,7 +25,7 @@ parse_args (int argc, char *argv[]) { case 'k': - controller_ior_ = get_opts.opt_arg (); + iors.push (get_opts.opt_arg ()); break; case 'f': // Turn off controller @@ -47,7 +48,7 @@ parse_args (int argc, char *argv[]) -1); } - if (controller_ior_ == 0 && ctrl_off == 0) + if (iors.is_empty () && ctrl_off == 0) ACE_ERROR_RETURN ((LM_ERROR, "Please provide controller IOR\n"), -1); @@ -63,28 +64,56 @@ main (int argc, char *argv[]) // Initialize orb CORBA::ORB_var orb = CORBA::ORB_init (argc, argv ACE_ENV_ARG_PARAMETER); - if (parse_args (argc, argv) != 0) - return -1; - - CORBA::Object_var obj - = orb->string_to_object (controller_ior_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + STRING_STACK IORs; - Priority_Test::Controller_var ctrlr - = Priority_Test::Controller::_narrow (obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + if (parse_args (argc, argv, IORs) != 0) + return -1; - if (CORBA::is_nil (ctrlr.in ())) - ACE_ERROR_RETURN ((LM_ERROR, "Unable to acquire 'Controller' objref\n"), -1); - if (ctrl_off != 0) - ctrlr->stop (ACE_ENV_SINGLE_ARG_PARAMETER); - else - ctrlr->start (work - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + CTRL_STACK controllers; + + while (!IORs.is_empty ()) + { + ACE_CString ior; + IORs.top (ior); + CORBA::Object_var obj + = orb->string_to_object (ior.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Priority_Test::Controller_var ctrlr + = Priority_Test::Controller::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ctrlr.in ())) + { + ACE_DEBUG ((LM_ERROR, + "Unable to acquire 'Controller' objref\n", + ior.c_str ())); + } + else + { + controllers.push (ctrlr); + } + IORs.pop (ior); + + } + + while (! controllers.is_empty ()) + { + Priority_Test::Controller_var ctrlr; + controllers.top (ctrlr); + + if (ctrl_off != 0) + ctrlr->stop (ACE_ENV_SINGLE_ARG_PARAMETER); + else + ctrlr->start (work + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + controllers.pop (ctrlr); + } orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/basic_test.pl b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/basic_test.pl index 4f9cc2d3ffb..14a803c62c3 100755 --- a/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/basic_test.pl +++ b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/basic_test.pl @@ -40,6 +40,24 @@ unlink $daemon_ior; unlink $am_ior; unlink $cookie; +$test_deploy = 0; +$no_daemon = 0; + +# Parse command line argument +while ( $#ARGV >= 0) +{ + if ($ARGV[0] =~ m/^-test_deploy/i) { + $test_deploy = 1; + } + elsif ($ARGV[0] =~ m/^-no_daemon/i) { + $no_daemon = 1; + } + else { + die "Invalid flag: $ARGV[0]\n"; + } + + shift; +} # CIAO Daemon command line arguments $daemon_args1 = "-ORBEndpoint iiop://localhost:10000 -o $daemon_ior -i CIAO_Installation_Data.ini -n $CIAO_ROOT/tools/ComponentServer/ComponentServer"; @@ -54,12 +72,14 @@ $ad_teardown = " -k file://$am_ior -d $cookie -x"; $DS = new PerlACE::Process ("$CIAO_ROOT/tools/Daemon/CIAO_Daemon", "$daemon_args1"); +if ($no_daemon == 0) { ## Starting up the CIAO daemon -$DS->Spawn (); -if (PerlACE::waitforfile_timed ($daemon_ior, 15) == -1) { - print STDERR "ERROR: Could not find daemon ior file <$daemon_ior>\n"; - $DS->Kill (); - exit 1; + $DS->Spawn (); + if (PerlACE::waitforfile_timed ($daemon_ior, 15) == -1) { + print STDERR "ERROR: Could not find daemon ior file <$daemon_ior>\n"; + $DS->Kill (); + exit 1; + } } ## Starting up the CIAO Assembly Manager @@ -91,23 +111,30 @@ if (PerlACE::waitforfile_timed ($controller_ior, 15) == -1) { exit 1; } -for ($work = $start_work; $work < $end_work; $work += $work_step) -{ - printf "Test work: $work\n"; +# Don't start the test +if ($test_deploy == 0) { + for ($work = $start_work; $work < $end_work; $work += $work_step) + { + printf "Test work: $work\n"; #Start the client to send the trigger message - $CL = new PerlACE::Process ("../Controllers/client", - "-k file://$controller_ior -w $work"); - $CL->SpawnWaitKill(60); + $CL = new PerlACE::Process ("../Controllers/client", + "-k file://$controller_ior -w $work"); + $CL->SpawnWaitKill(60); ## Now wait for the test to complete. Need to figure out a way to ## detect this. - sleep ($run_time); + sleep ($run_time); #Start the client to send the trigger message - $CL = new PerlACE::Process ("../Controllers/client", - "-k file://$controller_ior -f"); - $CL->SpawnWaitKill(60); + $CL = new PerlACE::Process ("../Controllers/client", + "-k file://$controller_ior -f"); + $CL->SpawnWaitKill(60); + } +} +else { + print "Test deploying the application -=-=- Not invoking client\n"; + sleep (1); } ## Now teardown the application diff --git a/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/no-rt-3rates.cad b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/no-rt-3rates.cad new file mode 100644 index 00000000000..349857c246e --- /dev/null +++ b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/no-rt-3rates.cad @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + worker + + + + some_device + + + + + + + worker + + + + some_device + + + + + + + worker + + + + some_device + + + + + + + diff --git a/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/rate_test.pl b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/rate_test.pl new file mode 100755 index 00000000000..9f80a0024bf --- /dev/null +++ b/TAO/CIAO/tests/RTCCM/Priority_Test/descriptors/rate_test.pl @@ -0,0 +1,166 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +# +# @@ Run this script from ../descriptors/ instead. +# + +use lib "$ENV{'ACE_ROOT'}/bin"; +use PerlACE::Run_Test; + +## Source in the environment setting +$ACE_ROOT=$ENV{'ACE_ROOT'}; +$CIAO_ROOT=$ENV{'CIAO_ROOT'}; + +if ($CIAO_ROOT eq "") { + $CIAO_ROOT="$ACE_ROOT/TAO/CIAO"; +} + + +$status = 0; +$assembly = PerlACE::LocalFile ("no-rt-3rates.cad"); +$deploy_config = PerlACE::LocalFile ("test.dat"); +#$deploy_config = PerlACE::LocalFile ("remote.dat"); +$daemon_ior = PerlACE::LocalFile ("daemon.ior"); +$am_ior = PerlACE::LocalFile ("am.ior"); +$c25_ior = PerlACE::LocalFile ("c25.ior"); +$c50_ior = PerlACE::LocalFile ("c50.ior"); +$c75_ior = PerlACE::LocalFile ("c75.ior"); +$cookie = PerlACE::LocalFile ("ck_demo_deployment"); + +## The following control how to iterate thru various work amount +$start_work = 10; +$end_work = 300; +$work_step = 300; +$run_time = 10; # run for $run_time sec. + +unlink $daemon_ior; +unlink $am_ior; +unlink $cookie; + +$test_deploy = 0; +$no_daemon = 0; + +# Parse command line argument +while ( $#ARGV >= 0) +{ + if ($ARGV[0] =~ m/^-test_deploy/i) { + $test_deploy = 1; + } + elsif ($ARGV[0] =~ m/^-no_daemon/i) { + $no_daemon = 1; + } + else { + die "Invalid flag: $ARGV[0]\n"; + } + + shift; +} + +# CIAO Daemon command line arguments +$daemon_args1 = "-ORBEndpoint iiop://localhost:10000 -o $daemon_ior -i CIAO_Installation_Data.ini -n $CIAO_ROOT/tools/ComponentServer/ComponentServer"; + +$assembly_manager_args = "-o $am_ior -c $deploy_config"; + +$ad_deploy = " -k file://$am_ior -o $cookie -a $assembly"; + +$ad_teardown = " -k file://$am_ior -d $cookie -x"; + +# CIAO daemon process definition +$DS = new PerlACE::Process ("$CIAO_ROOT/tools/Daemon/CIAO_Daemon", + "$daemon_args1"); + +if ($no_daemon == 0) { +## Starting up the CIAO daemon + $DS->Spawn (); + if (PerlACE::waitforfile_timed ($daemon_ior, 15) == -1) { + print STDERR "ERROR: Could not find daemon ior file <$daemon_ior>\n"; + $DS->Kill (); + exit 1; + } +} + +## Starting up the CIAO Assembly Manager +$AM = new PerlACE::Process("$CIAO_ROOT/tools/Assembly_Deployer/Assembly_Manager", + $assembly_manager_args); +$AM->Spawn (); +if (PerlACE::waitforfile_timed ($am_ior, 15) == -1) { + print STDERR "ERROR: Could not find assembly ior file <$am_ior>\n"; + $AM->Kill (); + $DS->Kill (); + exit 1; +} + +## Now actually deploy the application +$AD = new PerlACE::Process("$CIAO_ROOT/tools/Assembly_Deployer/Assembly_Deployer", + $ad_deploy); +if ($AD->SpawnWaitKill (60) == -1) { + print STDERR "ERROR: Failed to deploy assembly file <$assembly>\n"; + $AD->Kill (); + $AM->Kill (); + $DS->Kill (); +} + +## Make sure the application is up and running +if (PerlACE::waitforfile_timed ($c75_ior, 15) == -1) { + print STDERR "ERROR: Could not find controller ior file <$controller_ior>\n"; + $AM->Kill (); + $DS->Kill (); + exit 1; +} + +# Don't start the test +if ($test_deploy == 0) { + for ($work = $start_work; $work < $end_work; $work += $work_step) + { + printf "Test work: $work\n"; + +#Start the client to send the trigger message + $CL = new PerlACE::Process ("../Controllers/client", + "-k file://$c25_ior -k file://$c50_ior -k file://$c75_ior -w $work"); + $CL->SpawnWaitKill(60); + +## Now wait for the test to complete. Need to figure out a way to +## detect this. + sleep ($run_time); + +#Start the client to send the trigger message + $CL = new PerlACE::Process ("../Controllers/client", + "-k file://$c25_ior -k file://$c50_ior -k file://$c75_ior -f"); + $CL->SpawnWaitKill(60); + } +} +else { + print "Test deploying the application -=-=- Not invoking client\n"; + sleep (1); +} + +## Now teardown the application +$AD = new PerlACE::Process("$CIAO_ROOT/tools/Assembly_Deployer/Assembly_Deployer", + $ad_teardown); +if ($AD->SpawnWaitKill (60) == -1) { + print STDERR "ERROR: Failed to teardown assembly file <$assembly>\n"; + $AD->Kill (); + $AM->Kill (); + $DS->Kill (); + exit 1; +} + +#$ctrl = $DS->WaitKill (5); +#$AM->WaitKill(5); +#$AD->WaitKill(5); + +$AM->WaitKill (2); +$DS->Kill (); + + +unlink $cookie; +unlink $controller_ior; +unlink $daemon_ior; +unlink $am_ior; + +exit $status; diff --git a/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp b/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp index 6d174c548d5..23b08163562 100644 --- a/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp +++ b/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp @@ -13,6 +13,8 @@ #include "CIAO_common.h" #include "ace/SString.h" #include "ace/Get_Opt.h" +#include "ace/Env_Value_T.h" +#include "ace/Sched_Params.h" char *ior_file_name_ = 0; char *callback_ior_ = 0; @@ -33,11 +35,11 @@ parse_args (int argc, char *argv[]) case 'o': // get the file name to write to ior_file_name_ = get_opts.opt_arg (); - break; + break; case 'k': // get the activator callback IOR callback_ior_ = get_opts.opt_arg (); - break; + break; case '?': // display help for use of the server. default: @@ -46,6 +48,7 @@ parse_args (int argc, char *argv[]) "-n Don't not try to callback ServerActivator (testing)\n" "-o \n" "-k \n" + "-f: Enable to run in FIFO scheduling class\n" "\n", argv [0]), -1); @@ -61,6 +64,33 @@ parse_args (int argc, char *argv[]) int main (int argc, char *argv[]) { + // Define CIAO_FIFO_SCHED=1 to run component server in FIFO_SCHED class + ACE_Env_Value envar ("CIAO_FIFO_SCHED", 0); + if (envar != 0) + { + 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, + "ComponentServer (%P|%t): user is not superuser, " + "test runs in time-shared class\n")); + } + else + ACE_ERROR ((LM_ERROR, + "ComponentServer (%P|%t): sched_params failed\n")); + } + } + ACE_TRY_NEW_ENV { // Initialize orb diff --git a/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp b/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp index 6cac39afbe1..78c45c12fa8 100644 --- a/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp +++ b/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp @@ -27,11 +27,12 @@ char *installation_datafile_ = "CIAO_Installation_Data.ini"; char *section_name_ = 0; char *default_svcconf_ = 0; char *svcconf_config_ = 0; +char *extra_flags_ 0; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "i:n:o:d:s:c:m:"); + ACE_Get_Opt get_opts (argc, argv, "f:i:n:o:d:s:c:m:"); int c; while ((c = get_opts ()) != -1) @@ -66,6 +67,10 @@ parse_args (int argc, char *argv[]) svcconf_config_ = get_opts.opt_arg (); break; + case 'f': // get the extra command line flags for starting component server. + extra_flags_ = get_opts.opt_arg (); + break; + case '?': // display help for use of the server. default: ACE_ERROR_RETURN ((LM_ERROR, @@ -74,10 +79,10 @@ parse_args (int argc, char *argv[]) "-o \n" "-d