summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs
diff options
context:
space:
mode:
authorelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-06-23 12:32:43 +0000
committerelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-06-23 12:32:43 +0000
commitb28574f478d5744b9fe5196afa44dd89e10d50c9 (patch)
tree1bf45be4f8e15b9440c6439eada9344da8cb4c90 /TAO/orbsvcs
parenta3b65db893a471a9d1efe69d843a758065dbdbf5 (diff)
downloadATCD-b28574f478d5744b9fe5196afa44dd89e10d50c9.tar.gz
ChangeLogTag: Mon Jun 23 12:32:07 UTC 2008 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'TAO/orbsvcs')
-rw-r--r--TAO/orbsvcs/Notify_Service/Makefile.am10
-rw-r--r--TAO/orbsvcs/Notify_Service/Notify_Service.cpp55
-rw-r--r--TAO/orbsvcs/Notify_Service/Notify_Service.h6
-rw-r--r--TAO/orbsvcs/Notify_Service/Notify_Service.mpc4
-rw-r--r--TAO/orbsvcs/Notify_Service/README6
-rw-r--r--TAO/orbsvcs/tests/Notify/Makefile.am3
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Makefile.am165
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.cpp86
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.h41
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Structured_Consumer.cpp127
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Structured_Supplier.cpp230
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/Timeout.mpc33
-rwxr-xr-xTAO/orbsvcs/tests/Notify/Timeout/run_test.pl87
-rw-r--r--TAO/orbsvcs/tests/Notify/Timeout/sig.idl10
14 files changed, 859 insertions, 4 deletions
diff --git a/TAO/orbsvcs/Notify_Service/Makefile.am b/TAO/orbsvcs/Notify_Service/Makefile.am
index cca6bb555de..28b6d119b8a 100644
--- a/TAO/orbsvcs/Notify_Service/Makefile.am
+++ b/TAO/orbsvcs/Notify_Service/Makefile.am
@@ -17,6 +17,7 @@ bin_PROGRAMS =
## Makefile.NT_Notify_Service.am
+if BUILD_CORBA_MESSAGING
if BUILD_EXCEPTIONS
if BUILD_WINNT
if !BUILD_ACE_FOR_TAO
@@ -40,6 +41,9 @@ NT_Notify_Service_SOURCES = \
Notify_Service.h
NT_Notify_Service_LDADD = \
+ $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PI.la \
+ $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \
$(TAO_BUILDDIR)/tao/libTAO_IORTable.la \
$(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \
$(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \
@@ -61,9 +65,11 @@ NT_Notify_Service_LDADD = \
endif !BUILD_ACE_FOR_TAO
endif BUILD_WINNT
endif BUILD_EXCEPTIONS
+endif BUILD_CORBA_MESSAGING
## Makefile.Notify_Service.am
+if BUILD_CORBA_MESSAGING
if BUILD_EXCEPTIONS
bin_PROGRAMS += Notify_Service
@@ -83,6 +89,9 @@ Notify_Service_SOURCES = \
Notify_Service.h
Notify_Service_LDADD = \
+ $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PI.la \
+ $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \
$(TAO_BUILDDIR)/tao/libTAO_IORTable.la \
$(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \
$(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \
@@ -102,6 +111,7 @@ Notify_Service_LDADD = \
$(ACE_BUILDDIR)/ace/libACE.la
endif BUILD_EXCEPTIONS
+endif BUILD_CORBA_MESSAGING
## Clean up template repositories, etc.
clean-local:
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
index faa9ccf7ff1..00df2ac718f 100644
--- a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
+++ b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
@@ -8,6 +8,11 @@
#include "tao/debug.h"
#include "tao/IORTable/IORTable.h"
#include "tao/ORB_Core.h"
+
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+#include "tao/Messaging/Messaging.h"
+#endif /* TAO_HAS_CORBA_MESSAGING != 0 */
+
#include "ace/Arg_Shifter.h"
#include "ace/Get_Opt.h"
#include "ace/Sched_Params.h"
@@ -24,6 +29,7 @@ TAO_Notify_Service_Driver::TAO_Notify_Service_Driver (void)
, register_event_channel_ (false)
, nthreads_ (1)
, separate_dispatching_orb_ (false)
+, timeout_ (0)
{
// No-Op.
}
@@ -43,6 +49,8 @@ TAO_Notify_Service_Driver::init_ORB (int& argc, ACE_TCHAR *argv [])
this->orb_ = CORBA::ORB_init (command_line.get_argc(),
command_line.get_ASCII_argv());
+ this->apply_timeout (this->orb_);
+
CORBA::Object_var object =
this->orb_->resolve_initial_references("RootPOA");
@@ -72,9 +80,42 @@ TAO_Notify_Service_Driver::init_dispatching_ORB (int& argc, ACE_TCHAR *argv [])
command_line.get_ASCII_argv(),
"dispatcher");
+ this->apply_timeout (this->dispatching_orb_);
+
return 0;
}
+void
+TAO_Notify_Service_Driver::apply_timeout (CORBA::ORB_ptr orb)
+{
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+ if (this->timeout_ != 0)
+ {
+ // convert from msec to "TimeT"
+ CORBA::Any timeout;
+ TimeBase::TimeT value = 10000 * this->timeout_;
+ timeout <<= value;
+
+ CORBA::Object_var object =
+ orb->resolve_initial_references ("ORBPolicyManager");
+ CORBA::PolicyManager_var policy_manager =
+ CORBA::PolicyManager::_narrow (object.in ());
+ if (CORBA::is_nil (policy_manager.in ()))
+ throw CORBA::INTERNAL ();
+
+ CORBA::PolicyList policy_list (1);
+ policy_list.length (1);
+ policy_list[0] = orb->create_policy (
+ Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
+ timeout);
+ policy_manager->set_policy_overrides (policy_list, CORBA::SET_OVERRIDE);
+ policy_list[0]->destroy ();
+ }
+#else
+ ACE_UNUSED_ARG (orb);
+#endif /* TAO_HAS_CORBA_MESSAGING != 0 */
+}
+
int
TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[])
{
@@ -401,6 +442,17 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[])
this->nthreads_ = ACE_OS::atoi (current_arg);
arg_shifter.consume_arg ();
}
+ else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Timeout"))))
+ {
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+ this->timeout_ = ACE_OS::atoi (current_arg);
+ arg_shifter.consume_arg ();
+#else
+ ACE_DEBUG((LM_DEBUG,
+ "WARNING: CORBA Messaging has been disabled. The "
+ "timeout will not be applied.\n"));
+#endif /* TAO_HAS_CORBA_MESSAGING != 0 */
+ }
else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-?")) == 0)
{
ACE_DEBUG((LM_DEBUG,
@@ -408,7 +460,8 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[])
"-Boot -[No]NameSvc "
"-IORoutput file_name "
"-Channel -ChannelName channel_name "
- "-ORBRunThreads threads\n"
+ "-ORBRunThreads threads "
+ "-Timeout <msec>\n"
"default: %s -Factory NotifyEventChannelFactory "
"-NameSvc -Channel NotifyEventChannel -ORBRunThreads 1\n",
argv[0], argv[0]));
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.h b/TAO/orbsvcs/Notify_Service/Notify_Service.h
index b856c554e3c..86b57b125a9 100644
--- a/TAO/orbsvcs/Notify_Service/Notify_Service.h
+++ b/TAO/orbsvcs/Notify_Service/Notify_Service.h
@@ -91,6 +91,9 @@ protected:
/// initialize the dispatching ORB.
int init_dispatching_ORB (int& argc, ACE_TCHAR *argv []);
+ /// Apply a relative round-trip timeout to the ORB
+ void apply_timeout (CORBA::ORB_ptr orb);
+
TAO_Notify_Service* notify_service_;
/// Resolve the naming service.
@@ -143,6 +146,9 @@ protected:
/// indicate that a separate ORB is used for dispatching events.
bool separate_dispatching_orb_;
+
+ /// The relative round-trip timeout
+ suseconds_t timeout_;
};
#include /**/ "ace/post.h"
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.mpc b/TAO/orbsvcs/Notify_Service/Notify_Service.mpc
index 3c4aab00044..8a2fed924a9 100644
--- a/TAO/orbsvcs/Notify_Service/Notify_Service.mpc
+++ b/TAO/orbsvcs/Notify_Service/Notify_Service.mpc
@@ -1,7 +1,7 @@
// -*- MPC -*-
// $Id$
-project : valuetype, orbsvcsexe, install, notification_serv, naming, iortable {
+project : valuetype, orbsvcsexe, install, notification_serv, naming, iortable, messaging_optional {
exename = Notify_Service
Source_Files {
Notify_Server.cpp
@@ -12,7 +12,7 @@ project : valuetype, orbsvcsexe, install, notification_serv, naming, iortable {
}
}
-project(NT_Notify_Service) : valuetype, orbsvcsexe, install, notification_serv, naming, iortable {
+project(NT_Notify_Service) : valuetype, orbsvcsexe, install, notification_serv, naming, iortable, messaging_optional {
avoids += ace_for_tao
requires += winnt
exename = NT_Notify_Service
diff --git a/TAO/orbsvcs/Notify_Service/README b/TAO/orbsvcs/Notify_Service/README
index 3dc06134774..43584eaca8d 100644
--- a/TAO/orbsvcs/Notify_Service/README
+++ b/TAO/orbsvcs/Notify_Service/README
@@ -54,6 +54,12 @@ Command line arguments:
and use a separate ORB dedicated to dispatching of
events.
+"-Timeout msec" : Applies a relative round-trip timeout of msec microseconds
+ to the main ORB and, if -UseSeparateDispatchingORB 1 is
+ specified, to the dispatching ORB. This requires the
+ 'corba_messaging' MPC feature during building of the
+ Notify_Service, which is on by default.
+
!! The -Notify_TPReactor option is deprecated!! use the -ORBRunThreads
option instead.
diff --git a/TAO/orbsvcs/tests/Notify/Makefile.am b/TAO/orbsvcs/tests/Notify/Makefile.am
index 4f481444031..7411a1a6d95 100644
--- a/TAO/orbsvcs/tests/Notify/Makefile.am
+++ b/TAO/orbsvcs/tests/Notify/Makefile.am
@@ -30,7 +30,8 @@ SUBDIRS = \
Bug_2561_Regression \
Bug_1385_Regression \
Blocking \
- Basic
+ Basic \
+ Timeout
if BUILD_TESTS
SUBDIRS += performance-tests
diff --git a/TAO/orbsvcs/tests/Notify/Timeout/Makefile.am b/TAO/orbsvcs/tests/Notify/Timeout/Makefile.am
new file mode 100644
index 00000000000..563a99e8313
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Makefile.am
@@ -0,0 +1,165 @@
+## 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 TAO.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.Timeout_Idl.am
+
+BUILT_SOURCES = \
+ sigC.cpp \
+ sigC.h \
+ sigC.inl \
+ sigS.cpp \
+ sigS.h \
+ sigS.inl
+
+CLEANFILES = \
+ sig-stamp \
+ sigC.cpp \
+ sigC.h \
+ sigC.inl \
+ sigS.cpp \
+ sigS.h \
+ sigS.inl
+
+sigC.cpp sigC.h sigC.inl sigS.cpp sigS.h sigS.inl: sig-stamp
+
+sig-stamp: $(srcdir)/sig.idl $(TAO_IDL_DEP)
+ $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/sig.idl
+ @touch "$@"
+
+noinst_HEADERS = \
+ sig.idl
+
+## Makefile.Timeout_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 = \
+ Notify_Structured_Push_Consumer.cpp \
+ Structured_Consumer.cpp \
+ sigC.cpp \
+ Notify_Structured_Push_Consumer.h
+
+Structured_Consumer_LDFLAGS = \
+ -L$(TAO_ROOT)/orbsvcs/tests/Notify/lib
+
+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 \
+ $(ACE_BUILDDIR)/ace/ETCL/libACE_ETCL_Parser.la \
+ $(TAO_BUILDDIR)/tao/ETCL/libTAO_ETCL.la \
+ $(ACE_BUILDDIR)/ace/ETCL/libACE_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.Timeout_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 = \
+ Structured_Supplier.cpp \
+ sigC.cpp \
+ sigS.cpp \
+ Notify_Structured_Push_Consumer.h
+
+Structured_Supplier_LDFLAGS = \
+ -L$(TAO_ROOT)/orbsvcs/tests/Notify/lib
+
+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 \
+ $(ACE_BUILDDIR)/ace/ETCL/libACE_ETCL_Parser.la \
+ $(TAO_BUILDDIR)/tao/ETCL/libTAO_ETCL.la \
+ $(ACE_BUILDDIR)/ace/ETCL/libACE_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/Timeout/Notify_Structured_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.cpp
new file mode 100644
index 00000000000..3a998318656
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.cpp
@@ -0,0 +1,86 @@
+// $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_DEBUG ((LM_DEBUG, "-"));
+ static const ACE_Time_Value sl (1, 0);
+
+ 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/Timeout/Notify_Structured_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.h
new file mode 100644
index 00000000000..0341ce0cb28
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Notify_Structured_Push_Consumer.h
@@ -0,0 +1,41 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file Notify_Structured_Push_Consumer.h
+ *
+ * $Id$
+ *
+ * A structured push consumer implementation.
+ *
+ * @author Chad Elliott <elliott_c@ociweb.com>
+ */
+//=============================================================================
+
+#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_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/Timeout/Structured_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Timeout/Structured_Consumer.cpp
new file mode 100644
index 00000000000..5e9736dc7aa
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Structured_Consumer.cpp
@@ -0,0 +1,127 @@
+// $Id$
+
+// ******************************************************************
+// Include Section
+// ******************************************************************
+
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+
+#include "sigC.h"
+#include "Notify_Structured_Push_Consumer.h"
+#include "Notify_Test_Client.h"
+
+// ******************************************************************
+// Data Section
+// ******************************************************************
+
+static const char* ior = "file://supplier.ior";
+static unsigned int expected = 2;
+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:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.optarg;
+ break;
+
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "\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 ACE_TMAIN (int argc, ACE_TCHAR* 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", 1);
+
+ CORBA::ORB_ptr orb = client.orb ();
+ CORBA::Object_var object =
+ orb->string_to_object (ior);
+
+ sig_var sig = sig::_narrow (object.in ());
+
+ 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);
+
+ ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n"));
+
+ sig->go ();
+ ACE_Time_Value tv (5);
+ orb->run (tv);
+
+ ACE_DEBUG ((LM_DEBUG, "Consumer done.\n"));
+ }
+ catch (const CORBA::Exception& e)
+ {
+ e._tao_print_exception ("Consumer Error: ");
+ status = 1;
+ }
+
+ return status;
+}
diff --git a/TAO/orbsvcs/tests/Notify/Timeout/Structured_Supplier.cpp b/TAO/orbsvcs/tests/Notify/Timeout/Structured_Supplier.cpp
new file mode 100644
index 00000000000..075533eb2c9
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Structured_Supplier.cpp
@@ -0,0 +1,230 @@
+// $Id$
+
+// ******************************************************************
+// Include Section
+// ******************************************************************
+
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+
+#include "tao/ORB_Core.h"
+
+#include "sigS.h"
+#include "Notify_StructuredPushSupplier.h"
+#include "Notify_Test_Client.h"
+
+// ******************************************************************
+// Data Section
+// ******************************************************************
+
+static TAO_Notify_Tests_StructuredPushSupplier* supplier_1 = 0;
+static int max_events = 10;
+static const char* ior_output_file = "supplier.ior";
+
+// ******************************************************************
+// Subroutine Section
+// ******************************************************************
+
+class sig_i : public POA_sig
+{
+public:
+ sig_i(CORBA::ORB_ptr orb)
+ : orb_(orb)
+ , started_(false)
+ {
+ }
+
+ void go (void)
+ {
+ started_ = true;
+ }
+
+ void done (void)
+ {
+ started_ = false;
+ }
+
+ void wait_for_startup()
+ {
+ while (! started_) {
+ ACE_Time_Value tv(0, 100 * 1000); // 100ms
+ orb_->run(tv);
+ }
+ }
+
+private:
+ CORBA::ORB_ptr orb_;
+ bool started_;
+};
+
+
+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:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.optarg;
+ break;
+
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\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 ACE_TMAIN (int argc, ACE_TCHAR* 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", 0);
+
+ CORBA::ORB_ptr orb = client.orb ();
+
+ sig_i* sig_impl;
+ ACE_NEW_RETURN (sig_impl, sig_i (orb), 1);
+ PortableServer::ServantBase_var owner_transfer(sig_impl);
+
+ CORBA::Object_var object =
+ orb->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (object.in ());
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (sig_impl);
+
+ object = root_poa->id_to_reference (id.in ());
+
+ sig_var sig = sig::_narrow (object.in ());
+
+ CORBA::String_var ior = orb->object_to_string (sig.in ());
+
+ // Output the IOR to the <ior_output_file>
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ if (output_file != 0)
+ {
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+ }
+
+ CosNotifyChannelAdmin::SupplierAdmin_var admin =
+ create_supplieradmin (ec.in ());
+ if (!CORBA::is_nil (admin.in ()))
+ {
+ create_suppliers (admin.in (), client.root_poa ());
+
+ sig_impl->wait_for_startup();
+
+ 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));
+
+ ACE_OS::unlink (ior_output_file);
+ supplier_1->disconnect ();
+
+ ec->destroy ();
+ }
+ }
+ }
+ catch (const CORBA::Exception& e)
+ {
+ e._tao_print_exception ("Supplier Error: ");
+ status = 1;
+ }
+
+ return status;
+}
diff --git a/TAO/orbsvcs/tests/Notify/Timeout/Timeout.mpc b/TAO/orbsvcs/tests/Notify/Timeout/Timeout.mpc
new file mode 100644
index 00000000000..03812871b87
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/Timeout.mpc
@@ -0,0 +1,33 @@
+// $Id$
+
+project(*idl): taoidldefaults {
+ custom_only = 1
+}
+
+project(*consumer): notifytest {
+ after += *idl
+ exename = Structured_Consumer
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ sigC.cpp
+ Notify_Structured_Push_Consumer.cpp
+ Structured_Consumer.cpp
+ }
+}
+
+project(*supplier): notifytest {
+ after += *idl
+ exename = Structured_Supplier
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ sigC.cpp
+ sigS.cpp
+ Structured_Supplier.cpp
+ }
+}
diff --git a/TAO/orbsvcs/tests/Notify/Timeout/run_test.pl b/TAO/orbsvcs/tests/Notify/Timeout/run_test.pl
new file mode 100755
index 00000000000..90e31a387cb
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/run_test.pl
@@ -0,0 +1,87 @@
+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('supplier.ior');
+my $namingior = PerlACE::LocalFile('naming.ior');
+my $notifyior = PerlACE::LocalFile('notify.ior');
+my $nscorbaloc = "-ORBInitRef NameService=file://$namingior";
+my $NS = new PerlACE::Process("../../../Naming_Service/Naming_Service",
+ "-o $namingior");
+my $TS = new PerlACE::Process("../../../Notify_Service/Notify_Service",
+ "$nscorbaloc " .
+ "-IORoutput $notifyior -Timeout 750");
+my $STS = new PerlACE::Process("Structured_Supplier",
+ "$nscorbaloc");
+my $STC = new PerlACE::Process("Structured_Consumer",
+ "$nscorbaloc");
+
+unlink($ior, $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);
+}
+
+my $server = $STS->Spawn();
+if ($server != 0) {
+ print STDERR "ERROR: starting the consumer\n";
+ $STS->Kill();
+ $TS->Kill();
+ $NS->Kill();
+ exit(1);
+}
+
+## Wait for the supplier to create the event channel in
+## the Notify_Service and register it with the Name Service
+sleep(2);
+
+my $client = $STC->SpawnWaitKill(20);
+if ($client != 0) {
+ print STDERR "ERROR: waiting for the supplier\n";
+ $STS->Kill();
+ $STC->Kill();
+ $TS->Kill();
+ $NS->Kill();
+ exit(1);
+}
+
+$server = $STS->WaitKill(10);
+if ($server != 0) {
+ print STDERR "ERROR: waiting for the consumer\n";
+ $STS->Kill();
+ $STC->Kill();
+ $TS->Kill();
+ $NS->Kill();
+ exit(1);
+}
+
+
+$TS->Kill();
+$NS->Kill();
+
+unlink($ior, $notifyior, $namingior);
+exit(0);
diff --git a/TAO/orbsvcs/tests/Notify/Timeout/sig.idl b/TAO/orbsvcs/tests/Notify/Timeout/sig.idl
new file mode 100644
index 00000000000..e24bfd036c7
--- /dev/null
+++ b/TAO/orbsvcs/tests/Notify/Timeout/sig.idl
@@ -0,0 +1,10 @@
+// $Id$
+
+interface sig
+{
+ // Tell the server to start
+ oneway void go ();
+
+ // Tell the server the consumer is done
+ oneway void done ();
+};