From 251a1ecc3aa8c9e61d391621b40ef8af857d6f75 Mon Sep 17 00:00:00 2001 From: elliott_c Date: Mon, 13 Aug 2007 11:36:33 +0000 Subject: ChangeLogTag: Mon Aug 13 11:38:23 UTC 2007 Chad Elliott --- TAO/ChangeLog | 22 +- TAO/configure.ac | 1 + TAO/orbsvcs/tests/Notify/MC/Makefile.am | 218 +++++++++++++++++++ TAO/orbsvcs/tests/Notify/MC/MonitorControl.mpc | 41 ++++ .../tests/Notify/MC/MonitorTestInterface.idl | 9 + .../Notify/MC/Notify_Structured_Push_Consumer.cpp | 87 ++++++++ .../Notify/MC/Notify_Structured_Push_Consumer.h | 42 ++++ .../tests/Notify/MC/Structured_Consumer.cpp | 142 +++++++++++++ .../tests/Notify/MC/Structured_Supplier.cpp | 184 ++++++++++++++++ TAO/orbsvcs/tests/Notify/MC/notify.conf | 5 + TAO/orbsvcs/tests/Notify/MC/notify.conf.xml | 12 ++ TAO/orbsvcs/tests/Notify/MC/run_test.pl | 108 ++++++++++ TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp | 233 +++++++++++++++++++++ TAO/orbsvcs/tests/Notify/Makefile.am | 1 + 14 files changed, 1104 insertions(+), 1 deletion(-) create mode 100644 TAO/orbsvcs/tests/Notify/MC/Makefile.am create mode 100644 TAO/orbsvcs/tests/Notify/MC/MonitorControl.mpc create mode 100644 TAO/orbsvcs/tests/Notify/MC/MonitorTestInterface.idl create mode 100644 TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.cpp create mode 100644 TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.h create mode 100644 TAO/orbsvcs/tests/Notify/MC/Structured_Consumer.cpp create mode 100644 TAO/orbsvcs/tests/Notify/MC/Structured_Supplier.cpp create mode 100644 TAO/orbsvcs/tests/Notify/MC/notify.conf create mode 100644 TAO/orbsvcs/tests/Notify/MC/notify.conf.xml create mode 100755 TAO/orbsvcs/tests/Notify/MC/run_test.pl create mode 100644 TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp diff --git a/TAO/ChangeLog b/TAO/ChangeLog index ce38b6962a6..15ba8344ff1 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,23 @@ +Mon Aug 13 11:38:23 UTC 2007 Chad Elliott + + * configure.ac: + * orbsvcs/tests/Notify/MC/Makefile.am: + * orbsvcs/tests/Notify/MC/MonitorControl.mpc: + * orbsvcs/tests/Notify/MC/MonitorTestInterface.idl: + * orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.h: + * orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.cpp: + * orbsvcs/tests/Notify/MC/Structured_Consumer.cpp: + * orbsvcs/tests/Notify/MC/Structured_Supplier.cpp: + * orbsvcs/tests/Notify/MC/notify.conf: + * orbsvcs/tests/Notify/MC/notify.conf.xml: + * orbsvcs/tests/Notify/MC/run_test.pl: + * orbsvcs/tests/Notify/MC/test_monitor.cpp: + * orbsvcs/tests/Notify/Makefile.am: + + Added a new test that involves a slow consumer and has a test + monitor checking the state of the notification service at various + times. + Mon Aug 13 11:19:28 UTC 2007 Chad Elliott * orbsvcs/orbsvcs/Notify/Consumer.h: @@ -191,7 +211,7 @@ Sat Aug 11 11:38:47 UTC 2007 Phil Mesnier Re-applying Dale's change. The lock up I noticed was the result of attempting to recursively grab a non-recursive lock. With - that sorted out, the patch is otherwise fine. At last on my + that sorted out, the patch is otherwise fine. At least on my machine. Sat Aug 11 02:34:18 UTC 2007 Phil Mesnier diff --git a/TAO/configure.ac b/TAO/configure.ac index 8313f5a90cf..5e4371b2ff7 100644 --- a/TAO/configure.ac +++ b/TAO/configure.ac @@ -518,6 +518,7 @@ if test $tao_build_tests = yes; then orbsvcs/tests/Notify/Destroy/Makefile orbsvcs/tests/Notify/Discarding/Makefile orbsvcs/tests/Notify/Driver/Makefile + orbsvcs/tests/Notify/MC/Makefile orbsvcs/tests/Notify/MT_Dispatching/Makefile orbsvcs/tests/Notify/Makefile orbsvcs/tests/Notify/Ordering/Makefile diff --git a/TAO/orbsvcs/tests/Notify/MC/Makefile.am b/TAO/orbsvcs/tests/Notify/MC/Makefile.am new file mode 100644 index 00000000000..def53cc9c4b --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/Makefile.am @@ -0,0 +1,218 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs foo.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDLFLAGS = -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf +TAO_ROOT = $(top_srcdir) + +noinst_PROGRAMS = + +## Makefile.MonitorControl_Idl.am + +BUILT_SOURCES = \ + MonitorTestInterfaceC.cpp \ + MonitorTestInterfaceC.h \ + MonitorTestInterfaceC.inl \ + MonitorTestInterfaceS.cpp \ + MonitorTestInterfaceS.h \ + MonitorTestInterfaceS.inl + +CLEANFILES = \ + MonitorTestInterface-stamp \ + MonitorTestInterfaceC.cpp \ + MonitorTestInterfaceC.h \ + MonitorTestInterfaceC.inl \ + MonitorTestInterfaceS.cpp \ + MonitorTestInterfaceS.h \ + MonitorTestInterfaceS.inl + +MonitorTestInterfaceC.cpp MonitorTestInterfaceC.h MonitorTestInterfaceC.inl MonitorTestInterfaceS.cpp MonitorTestInterfaceS.h MonitorTestInterfaceS.inl: MonitorTestInterface-stamp + +MonitorTestInterface-stamp: $(srcdir)/MonitorTestInterface.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/MonitorTestInterface.idl + @touch "$@" + +noinst_HEADERS = \ + MonitorTestInterface.idl + +## Makefile.MonitorControl_Consumer.am + +if BUILD_CORBA_MESSAGING +if BUILD_EXCEPTIONS + +noinst_PROGRAMS += Structured_Consumer + +Structured_Consumer_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs \ + -I$(TAO_ROOT)/orbsvcs/tests/Notify/lib \ + -I$(TAO_BUILDDIR)/orbsvcs/tests/Notify/lib \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Structured_Consumer_SOURCES = \ + MonitorTestInterfaceC.cpp \ + Notify_Structured_Push_Consumer.cpp \ + Structured_Consumer.cpp \ + Notify_Structured_Push_Consumer.h + +Structured_Consumer_LDADD = \ + $(TAO_BUILDDIR)/orbsvcs/tests/Notify/lib/libTAO_NotifyTests.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicInterface.la \ + $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicAny.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_ETCL.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Skel.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Skel.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif BUILD_EXCEPTIONS +endif BUILD_CORBA_MESSAGING + +## Makefile.MonitorControl_Monitor.am + +if BUILD_EXCEPTIONS + +BUILT_SOURCES += \ + MonitorTestInterfaceC.cpp \ + MonitorTestInterfaceC.h \ + MonitorTestInterfaceC.inl \ + MonitorTestInterfaceS.cpp \ + MonitorTestInterfaceS.h \ + MonitorTestInterfaceS.inl + +CLEANFILES += \ + MonitorTestInterface-stamp \ + MonitorTestInterfaceC.cpp \ + MonitorTestInterfaceC.h \ + MonitorTestInterfaceC.inl \ + MonitorTestInterfaceS.cpp \ + MonitorTestInterfaceS.h \ + MonitorTestInterfaceS.inl + + + +noinst_PROGRAMS += test_monitor + +test_monitor_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +test_monitor_SOURCES = \ + MonitorTestInterfaceC.cpp \ + MonitorTestInterfaceS.cpp \ + test_monitor.cpp \ + MonitorTestInterfaceC.h \ + MonitorTestInterfaceC.inl \ + MonitorTestInterfaceS.h \ + MonitorTestInterfaceS.inl + +test_monitor_LDADD = \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_MC_Ext.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_MC.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/tao/libTAO_IORTable.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicAny.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_ETCL.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Skel.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Skel.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif BUILD_EXCEPTIONS + +## Makefile.MonitorControl_Supplier.am + +if BUILD_CORBA_MESSAGING +if BUILD_EXCEPTIONS + +noinst_PROGRAMS += Structured_Supplier + +Structured_Supplier_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs \ + -I$(TAO_ROOT)/orbsvcs/tests/Notify/lib \ + -I$(TAO_BUILDDIR)/orbsvcs/tests/Notify/lib \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Structured_Supplier_SOURCES = \ + MonitorTestInterfaceC.cpp \ + Structured_Supplier.cpp \ + Notify_Structured_Push_Consumer.h + +Structured_Supplier_LDADD = \ + $(TAO_BUILDDIR)/orbsvcs/tests/Notify/lib/libTAO_NotifyTests.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicInterface.la \ + $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicAny.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_ETCL.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Skel.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Skel.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif BUILD_EXCEPTIONS +endif BUILD_CORBA_MESSAGING + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/Notify/MC/MonitorControl.mpc b/TAO/orbsvcs/tests/Notify/MC/MonitorControl.mpc new file mode 100644 index 00000000000..3d1b7ebcabe --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/MonitorControl.mpc @@ -0,0 +1,41 @@ +project(*idl): taoidldefaults { + custom_only = 1 +} + +project(*monitor): notification_mc_ext { + after += *idl + exename = test_monitor + + Source_Files { + MonitorTestInterfaceC.cpp + MonitorTestInterfaceS.cpp + test_monitor.cpp + } +} + +project(*consumer): notifytest { + after += *idl + exename = Structured_Consumer + + IDL_Files { + } + + Source_Files { + MonitorTestInterfaceC.cpp + Notify_Structured_Push_Consumer.cpp + Structured_Consumer.cpp + } +} + +project(*supplier): notifytest { + after += *idl + exename = Structured_Supplier + + IDL_Files { + } + + Source_Files { + MonitorTestInterfaceC.cpp + Structured_Supplier.cpp + } +} diff --git a/TAO/orbsvcs/tests/Notify/MC/MonitorTestInterface.idl b/TAO/orbsvcs/tests/Notify/MC/MonitorTestInterface.idl new file mode 100644 index 00000000000..86c64e05b6f --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/MonitorTestInterface.idl @@ -0,0 +1,9 @@ +// $Id$ + +interface MonitorTestInterface +{ + enum Which { NotifyService, Supplier, Consumer }; + + oneway void running(in Which proc); + oneway void finished(in Which proc); +}; diff --git a/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.cpp new file mode 100644 index 00000000000..39f166f97d9 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.cpp @@ -0,0 +1,87 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/OS_NS_unistd.h" +#include "Notify_Structured_Push_Consumer.h" +#include "Notify_Test_Client.h" +#include "orbsvcs/Notify/Notify_Extensions.h" +#include "common.h" + +// ****************************************************************** +// Subroutine Section +// ****************************************************************** + +Notify_Structured_Push_Consumer::Notify_Structured_Push_Consumer ( + const char* name, + unsigned int expected, + Notify_Test_Client& client) + : name_ (name), + expected_ (expected), + count_ (0), + client_ (client) +{ + this->client_.consumer_start (this); +} + + +void +Notify_Structured_Push_Consumer::_connect ( + CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin) +{ + CosNotifyComm::StructuredPushConsumer_var objref = this->_this (); + + CosNotifyChannelAdmin::ProxySupplier_var proxysupplier = + consumer_admin->obtain_notification_push_supplier ( + CosNotifyChannelAdmin::STRUCTURED_EVENT, + proxy_id_); + + this->proxy_ = + CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow ( + proxysupplier.in ()); + + this->proxy_->connect_structured_push_consumer (objref.in ()); + + CosNotification::EventTypeSeq added (1); + CosNotification::EventTypeSeq removed (1); + added.length (1); + removed.length (1); + + added[0].domain_name = CORBA::string_dup ("*"); + added[0].type_name = CORBA::string_dup ("examples"); + + removed[0].domain_name = CORBA::string_dup ("*"); + removed[0].type_name = CORBA::string_dup ("*"); + + this->subscription_change (added, removed); + + // give ownership to POA + this->_remove_ref (); +} + + +void +Notify_Structured_Push_Consumer::push_structured_event ( + const CosNotification::StructuredEvent&) + ACE_THROW_SPEC ((CORBA::SystemException, CosEventComm::Disconnected)) +{ + ACE_DEBUG ((LM_DEBUG, "-")); + static const ACE_Time_Value sl (0, 2000); + + this->count_++; + if (this->count_ > this->expected_) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Structured Consumer (%P|%t): ERROR: too " + "many events received.\n"))); + } + + if (this->count_ >= this->expected_) + { + ACE_DEBUG ((LM_DEBUG, "\nConsumer received %u events.\n", count_)); + this->client_.consumer_done (this); + } + ACE_OS::sleep (sl); +} diff --git a/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.h new file mode 100644 index 00000000000..91dac17f200 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/Notify_Structured_Push_Consumer.h @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Notify_Structured_Push_Consumer.h + * + * $Id$ + * + * A structured push consumer implementation. + * + * @author Chad Elliott + */ +//============================================================================= + +#ifndef TAO_NOTIFY_STRUCTURED_PUSH_CONSUMER_H +#define TAO_NOTIFY_STRUCTURED_PUSH_CONSUMER_H + +#include "Notify_StructuredPushConsumer.h" +#include "orbsvcs/TimeBaseC.h" + +class Notify_Test_Client; + +class Notify_Structured_Push_Consumer: + public TAO_Notify_Tests_StructuredPushConsumer +{ +public: + Notify_Structured_Push_Consumer (const char* name, + unsigned int expected, + Notify_Test_Client& client); + + void _connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin); + +protected: + void push_structured_event (const CosNotification::StructuredEvent&) + ACE_THROW_SPEC ((CORBA::SystemException, CosEventComm::Disconnected)); + + ACE_CString name_; + unsigned int expected_; + unsigned int count_; + Notify_Test_Client& client_; +}; + +#endif /* TAO_NOTIFY_STRUCTURED_PUSH_CONSUMER_H */ diff --git a/TAO/orbsvcs/tests/Notify/MC/Structured_Consumer.cpp b/TAO/orbsvcs/tests/Notify/MC/Structured_Consumer.cpp new file mode 100644 index 00000000000..f39b20bbbe7 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/Structured_Consumer.cpp @@ -0,0 +1,142 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +#include "Notify_Structured_Push_Consumer.h" +#include "MonitorTestInterfaceC.h" + +#include "Notify_Test_Client.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static const char* ior = "file://test_monitor.ior"; +static unsigned int expected = 2000; +static Notify_Structured_Push_Consumer* consumer_1 = 0; + +class Consumer_Client : public Notify_Test_Client +{ +public: + virtual int parse_args (int argc, char* argv[]); +}; + + +int +Consumer_Client::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:e:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + + case 'e': + expected = ACE_OS::atoi (get_opts.optarg); + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k " + "-e " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + + +static CosNotifyChannelAdmin::ConsumerAdmin_ptr +create_consumeradmin (CosNotifyChannelAdmin::EventChannel_ptr ec) +{ + CosNotifyChannelAdmin::AdminID adminid = 0; + CosNotifyChannelAdmin::ConsumerAdmin_var admin = + ec->new_for_consumers (CosNotifyChannelAdmin::OR_OP, adminid); + + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin.in ()); +} + + +static void +create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin, + Notify_Test_Client* client) +{ + // startup the consumer + ACE_NEW_THROW_EX (consumer_1, + Notify_Structured_Push_Consumer ("consumer1", + expected, + *client), + CORBA::NO_MEMORY ()); + consumer_1->init (client->root_poa ()); + consumer_1->_connect (admin); +} + +// ****************************************************************** +// Main Section +// ****************************************************************** + +int main (int argc, char* argv[]) +{ + int status = 0; + try + { + Consumer_Client client; + + status = client.init (argc, argv); + if (status != 0) + ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"),1); + + CosNotifyChannelAdmin::EventChannel_var ec = + client.create_event_channel ("MyEventChannel", 0); + + CORBA::ORB_ptr orb = client.orb (); + CORBA::Object_var object = + orb->string_to_object (ior); + + MonitorTestInterface_var sig = + MonitorTestInterface::_narrow (object.in ()); + + if (CORBA::is_nil (sig.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Error: Narrow failed.\n"),1); + + CosNotifyChannelAdmin::ConsumerAdmin_var admin = + create_consumeradmin (ec.in ()); + + if (CORBA::is_nil (admin.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"),1); + + create_consumers (admin.in (), &client); + + sig->running (MonitorTestInterface::Consumer); + + ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n")); + + client.ORB_run (); + + ACE_DEBUG ((LM_DEBUG, "Consumer done.\n")); + consumer_1->disconnect (); + + ec->destroy (); + + sig->finished (MonitorTestInterface::Consumer); + } + catch (const CORBA::Exception& e) + { + e._tao_print_exception ("Consumer Error: "); + status = 1; + } + + return status; +} diff --git a/TAO/orbsvcs/tests/Notify/MC/Structured_Supplier.cpp b/TAO/orbsvcs/tests/Notify/MC/Structured_Supplier.cpp new file mode 100644 index 00000000000..4402e1644c9 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/Structured_Supplier.cpp @@ -0,0 +1,184 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +#include "tao/ORB_Core.h" + +#include "MonitorTestInterfaceC.h" +#include "Notify_StructuredPushSupplier.h" +#include "Notify_Test_Client.h" + + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static TAO_Notify_Tests_StructuredPushSupplier* supplier_1 = 0; +static int max_events = 2000; +static const char* ior_output_file = "supplier.ior"; +static const char* ior = "file://test_monitor.ior"; + +// ****************************************************************** +// Subroutine Section +// ****************************************************************** + +class Supplier_Client : public Notify_Test_Client +{ +public: + virtual int parse_args (int argc, char* argv[]); +}; + +int +Supplier_Client::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:e:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'e': + max_events = ACE_OS::atoi (get_opts.optarg); + break; + + case 'o': + ior_output_file = get_opts.optarg; + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o -e <# of events> -d" + "\n", + argv [0]), + -1); + } + + // Indicates sucessful parsing of the command line + return 0; +} + + +static CosNotifyChannelAdmin::SupplierAdmin_ptr +create_supplieradmin (CosNotifyChannelAdmin::EventChannel_ptr ec) +{ + CosNotifyChannelAdmin::AdminID adminid = 0; + CosNotifyChannelAdmin::SupplierAdmin_var admin = + ec->new_for_suppliers (CosNotifyChannelAdmin::AND_OP, adminid); + + return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (admin.in ()); +} + + +static void +SendEvent (int id) +{ + CosNotification::StructuredEvent event; + + event.header.fixed_header.event_type.domain_name = CORBA::string_dup ("DOC_TAO"); + event.header.fixed_header.event_type.type_name = CORBA::string_dup ("examples"); + + event.filterable_data.length (1); + event.filterable_data[0].name = CORBA::string_dup ("id"); + event.filterable_data[0].value <<= id; + + try + { + supplier_1->send_event (event); + } + catch (const CORBA::Exception& e) + { + e._tao_print_exception ("Error: "); + } +} + +static void +create_suppliers (CosNotifyChannelAdmin::SupplierAdmin_ptr admin, + PortableServer::POA_ptr poa) +{ + // startup the supplier + ACE_NEW_THROW_EX (supplier_1, + TAO_Notify_Tests_StructuredPushSupplier (), + CORBA::NO_MEMORY ()); + + supplier_1->init (poa); + supplier_1->connect (admin); + + CosNotification::EventTypeSeq added (1); + CosNotification::EventTypeSeq removed (1); + added.length (1); + removed.length (1); + added[0].domain_name = CORBA::string_dup ("DOC_TAO"); + added[0].type_name = CORBA::string_dup ("examples"); + + removed[0].domain_name = CORBA::string_dup ("*"); + removed[0].type_name = CORBA::string_dup ("*"); + + supplier_1->offer_change (added, removed); +} + + +// ****************************************************************** +// Main Section +// ****************************************************************** + +int main (int argc, char* argv[]) +{ + int status = 0; + try + { + Supplier_Client client; + status = client.init (argc, argv); + + if (status == 0) + { + CosNotifyChannelAdmin::EventChannel_var ec = + client.create_event_channel ("MyEventChannel", 1); + + CORBA::ORB_ptr orb = client.orb (); + CORBA::Object_var object = + orb->string_to_object (ior); + + MonitorTestInterface_var sig = + MonitorTestInterface::_narrow (object.in ()); + + if (CORBA::is_nil (sig.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Error: Narrow failed.\n"),1); + + CosNotifyChannelAdmin::SupplierAdmin_var admin = + create_supplieradmin (ec.in ()); + if (!CORBA::is_nil (admin.in ())) + { + create_suppliers (admin.in (), client.root_poa ()); + + sig->running (MonitorTestInterface::Supplier); + + ACE_DEBUG ((LM_DEBUG, + "1 supplier sending %d events...\n", max_events)); + for (int i = 0; i < max_events; ++i) + { + ACE_DEBUG ((LM_DEBUG, "+")); + SendEvent (i); + } + ACE_DEBUG ((LM_DEBUG, + "\nSupplier sent %d events.\n", max_events)); + + sig->finished (MonitorTestInterface::Supplier); + + supplier_1->disconnect (); + } + } + } + catch (const CORBA::Exception& e) + { + e._tao_print_exception ("Supplier Error: "); + status = 1; + } + + return status; +} diff --git a/TAO/orbsvcs/tests/Notify/MC/notify.conf b/TAO/orbsvcs/tests/Notify/MC/notify.conf new file mode 100644 index 00000000000..ed57ba4881e --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/notify.conf @@ -0,0 +1,5 @@ +## $Id$ + +dynamic TAO_MonitorAndControl Service_Object * TAO_CosNotification_MC:_make_TAO_MonitorAndControl () "-o monitor.ior -NoNameSvc" +dynamic TAO_MC_Notify_Service Service_Object * TAO_CosNotification_MC_Ext:_make_TAO_MC_Notify_Service () "" +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 1" diff --git a/TAO/orbsvcs/tests/Notify/MC/notify.conf.xml b/TAO/orbsvcs/tests/Notify/MC/notify.conf.xml new file mode 100644 index 00000000000..d64854e8bfd --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/notify.conf.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/TAO/orbsvcs/tests/Notify/MC/run_test.pl b/TAO/orbsvcs/tests/Notify/MC/run_test.pl new file mode 100755 index 00000000000..bb832eea23e --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/run_test.pl @@ -0,0 +1,108 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; +use strict; + +PerlACE::check_privilege_group(); + +my $ior = PerlACE::LocalFile('test_monitor.ior'); +my $monitorior = PerlACE::LocalFile('monitor.ior'); +my $namingior = PerlACE::LocalFile('naming.ior'); +my $notifyior = PerlACE::LocalFile('notify.ior'); +my $notify_conf = PerlACE::LocalFile("notify$PerlACE::svcconf_ext"); +my $port = PerlACE::random_port(); +my $nscorbaloc = "-ORBInitRef NameService=corbaloc:iiop:" . + "localhost:$port/NameService"; +my $NS = new PerlACE::Process("../../../Naming_Service/Naming_Service", + "-ORBEndpoint iiop://localhost:$port " . + "-o $namingior"); +my $TS = new PerlACE::Process("../../../Notify_Service/Notify_Service", + "$nscorbaloc " . + "-IORoutput $notifyior -ORBSvcConf " . + "$notify_conf"); +my $MON = new PerlACE::Process("test_monitor", + "-k file://$monitorior"); +my $STS = new PerlACE::Process("Structured_Supplier", + "$nscorbaloc"); +my $STC = new PerlACE::Process("Structured_Consumer", + "$nscorbaloc"); + +unlink($ior, $monitorior, $notifyior, $namingior); + +$NS->Spawn(); +if (PerlACE::waitforfile_timed( + $namingior, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: waiting for the naming service to start\n"; + $NS->Kill(); + exit(1); +} + +$TS->Spawn(); +if (PerlACE::waitforfile_timed( + $notifyior, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: waiting for the notify service to start\n"; + $TS->Kill(); + $NS->Kill(); + exit(1); +} + +$MON->Spawn(); +if (PerlACE::waitforfile_timed( + $ior, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: waiting for the supplier to start\n"; + $MON->Kill(); + $TS->Kill(); + $NS->Kill(); + exit(1); +} + +my $client = $STC->Spawn(); +if ($client != 0) { + print STDERR "ERROR: starting the consumer\n"; + $STC->Kill(); + $MON->Kill(); + $TS->Kill(); + $NS->Kill(); + exit(1); +} + +## Wait for the consumer to create the event channel in +## the Notify_Service and register it with the Name Service +sleep(2); + +my $server = $STS->SpawnWaitKill(30); +if ($server != 0) { + print STDERR "ERROR: waiting for the supplier\n"; + $STS->Kill(); + $STC->Kill(); + $MON->Kill(); + $TS->Kill(); + $NS->Kill(); + exit(1); +} + +$client = $STC->WaitKill(60); +if ($client != 0) { + print STDERR "ERROR: waiting for the consumer\n"; + $STC->Kill(); + $MON->Kill(); + $TS->Kill(); + $NS->Kill(); + exit(1); +} + +$MON->Kill(); +$TS->Kill(); +$NS->Kill(); + +unlink($ior, $monitorior, $notifyior, $namingior); +exit(0); diff --git a/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp b/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp new file mode 100644 index 00000000000..0ae3b04d6f5 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/MC/test_monitor.cpp @@ -0,0 +1,233 @@ +// $Id$ + +#include "MonitorTestInterfaceS.h" +#include "orbsvcs/Notify/MonitorControl/NotificationServiceMCC.h" +#include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtC.h" +#include "ace/Get_Opt.h" + +class MonitorTestInterface_i: public virtual POA_MonitorTestInterface +{ +public: + MonitorTestInterface_i ( + CosNotification::NotificationServiceMonitorControl_ptr nsm) + : nsm_ (CosNotification::NotificationServiceMonitorControl::_duplicate (nsm)) { + } + + virtual void running (MonitorTestInterface::Which proc) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void finished (MonitorTestInterface::Which proc) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + ACE_CString base_; + CosNotification::NotificationServiceMonitorControl_var nsm_; +}; + +void +MonitorTestInterface_i::running (MonitorTestInterface::Which proc) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_CString str; + CosNotification::NotificationServiceMonitorControl::Data_var data; + CosNotification::NotificationServiceMonitorControl::NameList list; + CosNotification::NotificationServiceMonitorControl::Numeric num; + + switch(proc) + { + case MonitorTestInterface::NotifyService: + data = + nsm_->get_statistic(NotifyMonitoringExt::EventChannelFactoryNames); + list = data->list (); + if (list.length () != 1) + ACE_ERROR ((LM_ERROR, "ERROR: There should be only one Event " + "Channel Factory\n")); + this->base_ = list[0]; + this->base_ += "/"; + + str = this->base_ + NotifyMonitoringExt::ActiveEventChannelCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 0) + ACE_ERROR ((LM_ERROR, "ERROR: There should be no active Event " + "Channels\n")); + + str = this->base_ + NotifyMonitoringExt::InactiveEventChannelCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 0) + ACE_ERROR ((LM_ERROR, "ERROR: There should be no inactive Event " + "Channels\n")); + break; + case MonitorTestInterface::Consumer: + str = this->base_ + NotifyMonitoringExt::ActiveEventChannelNames; + data = + nsm_->get_statistic (str.c_str ()); + list = data->list (); + if (list.length () != 1) + ACE_ERROR ((LM_ERROR, "ERROR: There should be only one active " + "Event Channel\n")); + + // Base will now be the factory plus the event channel + this->base_ = list[0]; + this->base_ += "/"; + + str = this->base_ + NotifyMonitoringExt::EventChannelConsumerCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 1) + ACE_ERROR ((LM_ERROR, "ERROR: There should be only one Consumer\n")); + + str = this->base_ + NotifyMonitoringExt::EventChannelQueueElementCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 0) + ACE_ERROR ((LM_ERROR, "ERROR: There should be no events queued\n")); + break; + case MonitorTestInterface::Supplier: + str = this->base_ + NotifyMonitoringExt::EventChannelSupplierCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 1) + ACE_ERROR ((LM_ERROR, "ERROR: There should be only one Supplier\n")); + break; + default: + ACE_ERROR ((LM_ERROR, "ERROR: Impossible enum value %d\n", proc)); + } +} + +void +MonitorTestInterface_i::finished (MonitorTestInterface::Which proc) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_CString str; + CosNotification::NotificationServiceMonitorControl::Data_var data; + CosNotification::NotificationServiceMonitorControl::Numeric num; + + switch(proc) + { + case MonitorTestInterface::NotifyService: + ACE_ERROR ((LM_ERROR, "ERROR: This should not be called\n")); + break; + case MonitorTestInterface::Consumer: + // By the time the consumer finishes, it should have destroyed + // the event channel + this->running (MonitorTestInterface::NotifyService); + break; + case MonitorTestInterface::Supplier: + str = this->base_ + NotifyMonitoringExt::EventChannelConsumerCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last != 1) + ACE_ERROR ((LM_ERROR, "ERROR: There should still be one Consumer\n")); + + str = this->base_ + NotifyMonitoringExt::EventChannelQueueElementCount; + data = nsm_->get_statistic(str.c_str ()); + num = data->num (); + if (num.last == 0) + ACE_ERROR ((LM_ERROR, "ERROR: There should be at least one " + "event queued\n")); + break; + default: + ACE_ERROR ((LM_ERROR, "ERROR: Impossible enum value %d\n", proc)); + } +} + +static const ACE_TCHAR* ior_output_file = ACE_TEXT ("test_monitor.ior"); +static const ACE_TCHAR* monitor_ior = 0; + +static int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("k:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + monitor_ior = get_opts.opt_arg (); + break; + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k " + "-o " + "\n", + argv [0]), + -1); + } + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR* argv[]) +{ + int status = 0; + 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 (ACE_TEXT_ALWAYS_CHAR (monitor_ior)); + CosNotification::NotificationServiceMonitorControl_var nsm = + CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ()); + + if (CORBA::is_nil (nsm.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to locate the " + "Notification Service Monitor\n"), + 1); + } + + MonitorTestInterface_i* mti = 0; + ACE_NEW_RETURN (mti, MonitorTestInterface_i (nsm.in ()), 1); + PortableServer::ServantBase_var owner_transfer (mti); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + PortableServer::ObjectId_var id = root_poa->activate_object (mti); + CORBA::Object_var object = root_poa->id_to_reference (id.in ()); + + MonitorTestInterface_var test = + MonitorTestInterface::_narrow (object.in ()); + CORBA::String_var ior = orb->object_to_string (test.in ()); + + // Test the case where there are no consumers or suppliers first + // before we write out our IOR + mti->running (MonitorTestInterface::NotifyService); + + FILE *output_file= ACE_OS::fopen (ior_output_file, ACE_TEXT ("w")); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s\n", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); + poa_manager->activate (); + + orb->run (); + orb->destroy (); + } + catch(const CORBA::Exception& ex) + { + ex._tao_print_exception ("test_monitor: "); + status++; + } + + return status; +} diff --git a/TAO/orbsvcs/tests/Notify/Makefile.am b/TAO/orbsvcs/tests/Notify/Makefile.am index 29772df03b2..66affb025c6 100644 --- a/TAO/orbsvcs/tests/Notify/Makefile.am +++ b/TAO/orbsvcs/tests/Notify/Makefile.am @@ -22,6 +22,7 @@ SUBDIRS = \ Persistent_POA \ Ordering \ MT_Dispatching \ + MC \ Driver \ Discarding \ Destroy \ -- cgit v1.2.1