diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-07 20:37:02 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-07 20:37:02 +0000 |
commit | f6ce8853b17956a37d630b0aae81414f49c30d5c (patch) | |
tree | a59ce88414dd3c8032b6d224a379afc2db1ae8a3 | |
parent | 0004c4e0d55404c72d74e09d587053f0eb694ecf (diff) | |
download | ATCD-f6ce8853b17956a37d630b0aae81414f49c30d5c.tar.gz |
fixed DualEC shutdown, strategized browser concurrency
-rw-r--r-- | TAO/ChangeLog-99c | 21 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java | 18 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/DOVEBrowserApplet.java | 1 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/DemoCore.java | 12 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/MTDataHandlerAdapter.java | 27 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/PushConsumer.java | 12 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java | 34 | ||||
-rwxr-xr-x | TAO/examples/Simulator/DOVEBrowser/make.bat | 1 | ||||
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.cpp | 3 | ||||
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/DualEC_Sup.cpp | 134 | ||||
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/DualEC_Sup.h | 11 |
11 files changed, 229 insertions, 45 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index dfaf1da0909..9abba0949b1 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,24 @@ +Sun Feb 7 14:32:00 1999 Chris Gill <cdgill@cs.wustl.edu> + + * TAO/orbsvcs/tests/Simulator/DOVEBrowser/DOVEBrowser.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/DOVEBrowserApplet.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/DemoCore.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/MTDataHandlerAdapter.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/PushConsumer.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/PushConsumerFactory.java + TAO/orbsvcs/tests/Simulator/DOVEBrowser/make.bat : strategized + browser concurrency: can either use direct orb upcalls (default) + or use queueing in active data handler adapter objects + (via the -queue command line switch). + + * TAO/orbsvcs/tests/Simulator/Event_Supplier/DOVE_Supplier + TAO/orbsvcs/tests/Simulator/Event_Supplier/DualEC_Sup.{cpp, h}: + fixed shutdown to ensure disconnection of the scheduler and EC + servants, deregistration of these from the Naming Service. Also + added command line switches -n and -w to set the number of + usec slept before generating each navigation or weapons event, + respectively. + Sun Feb 7 11:44:58 1999 Carlos O'Ryan <coryan@cs.wustl.edu> * TAO_IDL/driver/drv_args.cpp: diff --git a/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java index 522cf2bf177..6c3ef2e71e3 100644 --- a/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java +++ b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java @@ -23,9 +23,13 @@ public class DOVEBrowser { } public void init (String nameServiceIOR, String nameServicePort, - String[] args) { + String[] args, boolean use_queueing) { - demoCore_ = new DemoCore (nameServiceIOR, nameServicePort, args, null); + demoCore_ = new DemoCore (nameServiceIOR, + nameServicePort, + args, + use_queueing, + null); demoCore_.show (); demoCore_.run (); } @@ -33,6 +37,7 @@ public class DOVEBrowser { public static void main (String[] args) { String nameServiceIOR = null; String nameServicePort = null; + boolean use_queueing = false; int arg_index = 0; // Loop through command line arguments, acting on relevant options @@ -41,7 +46,12 @@ public class DOVEBrowser { System.out.println ("args.length [" + args.length + "] arg_index [" + arg_index + "]"); // Set the name service IOR - if ((args[arg_index].equals ("-ORBnameserviceior")) && + if (args[arg_index].equals ("-queue")) + { + ++arg_index; + use_queueing = true; + } + else if ((args[arg_index].equals ("-ORBnameserviceior")) && (args.length > arg_index + 1)) { System.out.println ("switch [" + args[arg_index] + "]"); @@ -69,7 +79,7 @@ public class DOVEBrowser { } DOVEBrowser doveBrowser = new DOVEBrowser(); - doveBrowser.init (nameServiceIOR, nameServicePort, args); + doveBrowser.init (nameServiceIOR, nameServicePort, args, use_queueing); } } diff --git a/TAO/examples/Simulator/DOVEBrowser/DOVEBrowserApplet.java b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowserApplet.java index efa59d65fdf..160eb3a363b 100644 --- a/TAO/examples/Simulator/DOVEBrowser/DOVEBrowserApplet.java +++ b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowserApplet.java @@ -35,6 +35,7 @@ public class DOVEBrowserApplet extends java.applet.Applet { demoCore_ = new DemoCore (nameServiceIOR_, // name service IOR null, // name service port null, // args + false, // don't use queueing this); // pointer to the applet demoCore_.show (); demoCore_.run (); diff --git a/TAO/examples/Simulator/DOVEBrowser/DemoCore.java b/TAO/examples/Simulator/DOVEBrowser/DemoCore.java index a659437a69a..173e40a8ef5 100644 --- a/TAO/examples/Simulator/DOVEBrowser/DemoCore.java +++ b/TAO/examples/Simulator/DOVEBrowser/DemoCore.java @@ -28,13 +28,17 @@ public class DemoCore extends Frame { private int countVisComp_ = 0; private GridBagLayout gridbag_; private GridBagConstraints constraints_; + private boolean use_queueing_ = false; DemoCore (String nameServiceIOR, String nameServicePort, String[] args, + boolean use_queueing, java.applet.Applet applet) { super (); + use_queueing = use_queueing; + setSize (600,400); setBounds (new Rectangle (50,50,800,500)); setVisible (true); @@ -48,8 +52,12 @@ public class DemoCore extends Frame { // Instantiate the DataHandler and the PushConsumer dataHandler_ = new NavWeapDataHandler (); - pushConsumerFactory_ = new PushConsumerFactory (dataHandler_, nameServiceIOR, - nameServicePort, args, applet); + pushConsumerFactory_ = new PushConsumerFactory (dataHandler_, + nameServiceIOR, + nameServicePort, + args, + use_queueing_, + applet); // List of Visualization Components vis_comp_list_ = new java.util.Vector(); diff --git a/TAO/examples/Simulator/DOVEBrowser/MTDataHandlerAdapter.java b/TAO/examples/Simulator/DOVEBrowser/MTDataHandlerAdapter.java index 949e3fcb9b1..5025c0a8e6d 100644 --- a/TAO/examples/Simulator/DOVEBrowser/MTDataHandlerAdapter.java +++ b/TAO/examples/Simulator/DOVEBrowser/MTDataHandlerAdapter.java @@ -11,18 +11,37 @@ public class MTDataHandlerAdapter extends Thread // Both the queue and the underlying data handler are private private MTQueue queue_ = null; private DataHandler dataHandler_ = null; - + private boolean use_queueing_ = false; + // Constructor. - MTDataHandlerAdapter (DataHandler dh) + MTDataHandlerAdapter (DataHandler dh, boolean use_queueing) { dataHandler_ = dh; - queue_ = new MTQueue (); + use_queueing_ = use_queueing; + if (use_queueing_) + { + queue_ = new MTQueue (); + } } // Enqueue an event set for the handler thread. public void push (RtecEventComm.Event[] events) { - queue_.enqueue_tail (events); + if (use_queueing_) + { + queue_.enqueue_tail (events); + } + else + { + for (int i = 0; i < events.length; ++i) + { + if(events[i].header.type == + PushConsumer.ACE_ES_EVENT_NOTIFICATION) + { + dataHandler_.update (events[i]); + } + } + } } // Process enqueued event sets in a separate thread. diff --git a/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java b/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java index 370a1068bd0..7e17de6fc0e 100644 --- a/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java +++ b/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java @@ -46,11 +46,17 @@ public class PushConsumer extends RtecEventComm._PushConsumerImplBase private RtecEventChannelAdmin.ConsumerAdmin consumer_admin_; private RtecEventChannelAdmin.ProxyPushSupplier suppliers_; - public PushConsumer (org.omg.CORBA.ORB orb, DataHandler dataHandler) + public PushConsumer (org.omg.CORBA.ORB orb, + DataHandler dataHandler, + boolean use_queueing) { orb_ = orb; - dataHandlerAdapter_ = new MTDataHandlerAdapter (dataHandler); - dataHandlerAdapter_.start (); + dataHandlerAdapter_ = + new MTDataHandlerAdapter (dataHandler, use_queueing); + if (use_queueing) + { + dataHandlerAdapter_.start (); + } } diff --git a/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java b/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java index f5fd4de40ac..f3632cd43fa 100644 --- a/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java +++ b/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java @@ -32,14 +32,18 @@ public class PushConsumerFactory { private String[] ss_names_ = null; private int ss_names_count_ = 0; + private boolean use_queueing_ = false; + public PushConsumerFactory (DataHandler dataHandler, String nameServiceIOR, String nameServicePort, String[] args, + boolean use_queueing, java.applet.Applet applet) { try - { + { + use_queueing_ = use_queueing; dataHandler_ = dataHandler; // if the DOVE Browser is running as an Applet @@ -98,6 +102,14 @@ public class PushConsumerFactory { ec_names_count_ += 2; ss_names_count_ += 2; } + else if ((args[arg_index].equals ("-dualECdemo1")) || + (args[arg_index].equals ("-dualECdemo2"))) + { + System.out.println ("switch [" + args[arg_index] + "]"); + ++arg_index; + ++ec_names_count_; + ++ss_names_count_; + } // Skip over anything else else { @@ -148,6 +160,22 @@ public class PushConsumerFactory { ec_names_count_ += 2; ss_names_count_ += 2; } + else if (args[arg_index].equals ("-dualECdemo1")) + { + ss_names_[ss_names_count_] = "DUAL_SCHED_HI"; + ec_names_[ec_names_count_] = "DUAL_EC_HI"; + ++arg_index; + ++ec_names_count_; + ++ss_names_count_; + } + else if (args[arg_index].equals ("-dualECdemo2")) + { + ss_names_[ss_names_count_] = "DUAL_SCHED_LO"; + ec_names_[ec_names_count_] = "DUAL_EC_LO"; + ++arg_index; + ++ec_names_count_; + ++ss_names_count_; + } // Skip over anything else. else { @@ -264,7 +292,9 @@ public class PushConsumerFactory { ec_names_[ec_number] + ": demo_consumer_" + ec_number + "."); - PushConsumer pushConsumer_ = new PushConsumer (orb_, dataHandler_); + PushConsumer pushConsumer_ = new PushConsumer (orb_, + dataHandler_, + use_queueing_); System.out.println ("Initializing the Push Consumer for " + ec_names_[ec_number] + ": demo_consumer_" + ec_number + "."); diff --git a/TAO/examples/Simulator/DOVEBrowser/make.bat b/TAO/examples/Simulator/DOVEBrowser/make.bat index d4b5b820157..e1749928ec4 100755 --- a/TAO/examples/Simulator/DOVEBrowser/make.bat +++ b/TAO/examples/Simulator/DOVEBrowser/make.bat @@ -85,6 +85,7 @@ javac *.java @del Weapons.java @del WeaponsHelper.java @del WeaponsHolder.java +@del NavWeapTerminator*.java @del Navigation.java @del NavigationHelper.java @del NavigationHolder.java diff --git a/TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.cpp b/TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.cpp index d917a62b220..04303511c63 100644 --- a/TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.cpp +++ b/TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.cpp @@ -337,12 +337,13 @@ DOVE_Supplier::connect_Supplier (ACE_Scheduler_Factory::POD_RT_Info * rt_info) } TAO_CATCHANY { - TAO_TRY_ENV.print_exception ("DOVE_Supplier::open"); + TAO_TRY_ENV.print_exception ("DOVE_Supplier::connect_supplier"); return -1; } TAO_ENDTRY; return 0; + } diff --git a/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.cpp b/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.cpp index ccf574d8f69..3d2a8d4d8b0 100644 --- a/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.cpp +++ b/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.cpp @@ -50,7 +50,11 @@ static const char usage [] = " [-p to suppress prioritization of operations]]\n"; DualEC_Supplier::DualEC_Supplier (int argc, char** argv) -: sched_hi_impl_ (0), +: channel_hi_name_ (1), + channel_lo_name_ (1), + sched_hi_name_ (1), + sched_lo_name_ (1), + sched_hi_impl_ (0), sched_lo_impl_ (0), ec_hi_impl_ (0), ec_lo_impl_ (0), @@ -71,6 +75,22 @@ DualEC_Supplier::DualEC_Supplier (int argc, char** argv) { TAO_TRY { + this->sched_hi_name_.length (1); + this->sched_hi_name_[0].id = CORBA::string_dup ("DUAL_SCHED_HI"); + TAO_CHECK_ENV; + + this->sched_lo_name_.length (1); + this->sched_lo_name_[0].id = CORBA::string_dup ("DUAL_SCHED_LO"); + TAO_CHECK_ENV; + + this->channel_hi_name_.length (1); + this->channel_hi_name_[0].id = CORBA::string_dup ("DUAL_EC_HI"); + TAO_CHECK_ENV; + + this->channel_lo_name_.length (1); + this->channel_lo_name_[0].id = CORBA::string_dup ("DUAL_EC_LO"); + TAO_CHECK_ENV; + this->terminator_ = terminator_impl_._this (TAO_TRY_ENV); TAO_CHECK_ENV; } @@ -108,11 +128,31 @@ DualEC_Supplier::DualEC_Supplier (int argc, char** argv) DualEC_Supplier::~DualEC_Supplier () { - this->dOVE_Supplier_Hi_.disconnect (); - this->dOVE_Supplier_Lo_.disconnect (); + TAO_TRY + { + this->dOVE_Supplier_Hi_.disconnect (); + this->dOVE_Supplier_Lo_.disconnect (); + + // Unbind the schedulers from the NS. + this->naming_context_->unbind (this->sched_hi_name_, TAO_TRY_ENV); + TAO_CHECK_ENV; + this->naming_context_->unbind (this->sched_lo_name_, TAO_TRY_ENV); + TAO_CHECK_ENV; + + // Unbind the ECs from the NS. + this->naming_context_->unbind (this->channel_hi_name_, TAO_TRY_ENV); + TAO_CHECK_ENV; + this->naming_context_->unbind (this->channel_lo_name_, TAO_TRY_ENV); + TAO_CHECK_ENV; + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("DualEC_Supplier::~DualEC_Supplier"); + } + TAO_ENDTRY; - // CDG - TBD - unregister the ECs from the NS - // CDG - TBD - destroy the ECs + // @@TBD - destroy the ECs + // @@TBD - destroy the schedulers } int @@ -271,6 +311,8 @@ DualEC_Supplier::run_nav_thread (void *arg) { any.replace (_tc_Navigation, *nav, 0, TAO_TRY_ENV); + // Sleep briefly to avoid too much livelock (a little is good). + ACE_OS::sleep (sup->nav_pause_); sup->navigation_Supplier->notify (any); } @@ -339,6 +381,8 @@ DualEC_Supplier::run_weap_thread (void *arg) { any.replace (_tc_Weapons, *weap, 0, TAO_TRY_ENV); + // Sleep briefly to avoid too much livelock (a little is good). + ACE_OS::sleep (sup->weap_pause_); sup->weapons_Supplier->notify (any); } @@ -381,7 +425,7 @@ DualEC_Supplier::run_weap_thread (void *arg) int DualEC_Supplier::create_schedulers (void) { - // CDG - TBD - look at a command line modified setting, + // @@TBD - look at a command line modified setting, // create either a runtime or a config scheduler for // each instance @@ -414,16 +458,12 @@ DualEC_Supplier::create_schedulers (void) // Register Scheduling Service Implementations with Naming Service - CosNaming::Name sched_hi_name (1); - sched_hi_name.length (1); - sched_hi_name[0].id = CORBA::string_dup ("DUAL_SCHED_HI"); - naming_context_->bind (sched_hi_name, sched_hi_.in (), TAO_TRY_ENV); + this->naming_context_->bind (this ->sched_hi_name_, + this->sched_hi_.in (), TAO_TRY_ENV); TAO_CHECK_ENV; - CosNaming::Name sched_lo_name (1); - sched_lo_name.length (1); - sched_lo_name[0].id = CORBA::string_dup ("DUAL_SCHED_LO"); - naming_context_->bind (sched_lo_name, sched_lo_.in (), TAO_TRY_ENV); + naming_context_->bind (this->sched_lo_name_, + this->sched_lo_.in (), TAO_TRY_ENV); TAO_CHECK_ENV; } } @@ -470,16 +510,12 @@ DualEC_Supplier::create_event_channels (void) // Register Event Service Implementations with Naming Service - CosNaming::Name channel_hi_name (1); - channel_hi_name.length (1); - channel_hi_name[0].id = CORBA::string_dup ("DUAL_EC_HI"); - naming_context_->bind (channel_hi_name, ec_hi_.in (), TAO_TRY_ENV); + naming_context_->bind (this->channel_hi_name_, + this->ec_hi_.in (), TAO_TRY_ENV); TAO_CHECK_ENV; - CosNaming::Name channel_lo_name (1); - channel_lo_name.length (1); - channel_lo_name[0].id = CORBA::string_dup ("DUAL_EC_LO"); - naming_context_->bind (channel_lo_name, ec_lo_.in (), TAO_TRY_ENV); + naming_context_->bind (this->channel_lo_name_, + this->ec_lo_.in (), TAO_TRY_ENV); TAO_CHECK_ENV; } @@ -596,7 +632,15 @@ DualEC_Supplier::start_generating_events (void) this->compute_schedules (); // Load the scheduling data for the simulation. - this->load_schedule_data (this->schedule_data_); + this->load_schedule_data (); + + // Sleep for 15 seconds to give time for registrations. + ACE_DEBUG ((LM_DEBUG, + "DUAL_SCHED_HI, DUAL_SCHED_LO, DUAL_EC_HI and " + "DUAL_EC_LO are registered with the Naming Service.\n" + "Sleeping 15 seconds before generating events")); + ACE_Time_Value tv (15, 0); + ACE_OS::sleep (tv); // Spawn thread to run over the navigation data and generate events. ACE_Thread_Manager event_thread_manager; @@ -701,8 +745,8 @@ DualEC_Supplier::load_schedule_data () } - if ((strcmp((*sched_data)->operation_name, "high_20") == 0) || - (strcmp((*sched_data)->operation_name, "low_20") == 0)) + if ((strcmp(data.operation_name, "high_20") == 0) || + (strcmp(data.operation_name, "low_20") == 0)) { ACE_NEW (weap, Weapons); if (weap == 0) @@ -758,7 +802,7 @@ DualEC_Supplier::load_schedule_data () nav->position_longitude = ACE_OS::rand() % 180; nav->altitude = ACE_OS::rand() % 100; nav->heading = ACE_OS::rand() % 180; - this nav_roll_ = (this->nav_roll_ >= 180) ? -180 : this->nav_roll_ + 1; + this->nav_roll_ = (this->nav_roll_ >= 180) ? -180 : this->nav_roll_ + 1; nav->roll = this->nav_roll_; this->nav_pitch_ = (this->nav_pitch_ >= 90) ? -90 : this->nav_pitch_ + 1; nav->pitch = this->nav_pitch_; @@ -786,7 +830,6 @@ DualEC_Supplier::load_schedule_data () return; } } - } } @@ -795,7 +838,7 @@ DualEC_Supplier::load_schedule_data () unsigned int DualEC_Supplier::get_options (int argc, char *argv []) { - ACE_Get_Opt get_opt (argc, argv, "f:m:t:dsrp"); + ACE_Get_Opt get_opt (argc, argv, "f:m:n:w:dsrp"); int opt; int temp; @@ -834,6 +877,41 @@ DualEC_Supplier::get_options (int argc, char *argv []) 1); break; + case 'n': + temp = ACE_OS::atoi (get_opt.optarg); + if (temp >= 0) + { + this->nav_pause_ = + ACE_Time_Value(0, ACE_static_cast (long, temp)); + ACE_DEBUG ((LM_DEBUG, + "Navigation pause: %d usec\n", + temp)); + } + else + ACE_ERROR_RETURN ((LM_ERROR, + "%s: navigation pause must be >= 0", + argv[0]), + 1); + break; + + + case 'w': + temp = ACE_OS::atoi (get_opt.optarg); + if (temp >= 0) + { + this->weap_pause_ = + ACE_Time_Value(0, ACE_static_cast (long, temp)); + ACE_DEBUG ((LM_DEBUG, + "Weapons pause: %d usec\n", + temp)); + } + else + ACE_ERROR_RETURN ((LM_ERROR, + "%s: weapons pause must be >= 0", + argv[0]), + 1); + break; + case 'd': this->dump_schedule_headers_ = 1; diff --git a/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.h b/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.h index 4fa4acf1bda..b59ad5cbfe0 100644 --- a/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.h +++ b/TAO/examples/Simulator/Event_Supplier/DualEC_Sup.h @@ -107,12 +107,21 @@ private: unsigned int get_options (int argc, char *argv []); // Get command line options. + // Time values to pause before notifying the supplier each time. + ACE_Time_Value nav_pause_; + ACE_Time_Value weap_pause_; + // POA client references. PortableServer::POA_var root_POA_var_; PortableServer::POAManager_var poa_manager_; - // Naming Service client references. + // Naming Service client reference and names to use. CosNaming::NamingContext_var naming_context_; + CosNaming::Name channel_hi_name_; + CosNaming::Name channel_lo_name_; + CosNaming::Name sched_hi_name_; + CosNaming::Name sched_lo_name_; + // Scheduling Service servant implementation pointers. POA_RtecScheduler::Scheduler * sched_hi_impl_; |