diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter')
11 files changed, 954 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Makefile.am b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Makefile.am new file mode 100644 index 00000000000..9cac82d4d1e --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Makefile.am @@ -0,0 +1,162 @@ +## 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 = -Ge 1 -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.Seq_Multi_ETCL_Filter_Idl.am + +if !BUILD_ACE_FOR_TAO + +BUILT_SOURCES = \ + goC.cpp \ + goC.h \ + goC.inl \ + goS.cpp \ + goS.h \ + goS.inl + +CLEANFILES = \ + go-stamp \ + goC.cpp \ + goC.h \ + goC.inl \ + goS.cpp \ + goS.h \ + goS.inl + +goC.cpp goC.h goC.inl goS.cpp goS.h goS.inl: go-stamp + +go-stamp: $(srcdir)/go.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/go.idl + @touch $@ + + +noinst_HEADERS = \ + go.idl + +endif !BUILD_ACE_FOR_TAO + +## Makefile.Seq_Multi_ETCL_Filter_Ntf_Seq_Cons.am + +if BUILD_CORBA_MESSAGING +if !BUILD_ACE_FOR_TAO +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS += Sequence_Consumer + +Sequence_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 \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Sequence_Consumer_SOURCES = \ + Notify_Sequence_Push_Consumer.cpp \ + Sequence_Consumer.cpp \ + goC.cpp \ + Notify_Sequence_Push_Consumer.h + +Sequence_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)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicAny.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_MINIMUM_CORBA +endif !BUILD_ACE_FOR_TAO +endif BUILD_CORBA_MESSAGING + +## Makefile.Seq_Multi_ETCL_Filter_Ntf_Seq_Supp.am + +if BUILD_CORBA_MESSAGING +if !BUILD_ACE_FOR_TAO +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS += Sequence_Supplier + +Sequence_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 \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Sequence_Supplier_SOURCES = \ + Sequence_Supplier.cpp \ + goC.cpp \ + goS.cpp \ + Notify_Sequence_Push_Consumer.h + +Sequence_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)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNotification_Serv.la \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicAny.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_MINIMUM_CORBA +endif !BUILD_ACE_FOR_TAO +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/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.cpp new file mode 100644 index 00000000000..9a7df06e215 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.cpp @@ -0,0 +1,86 @@ +// $Id$ + +#include "ace/OS_NS_unistd.h" +#include "Notify_Sequence_Push_Consumer.h" +#include "Notify_Test_Client.h" +#include "orbsvcs/TimeBaseC.h" +#include "common.h" +#include "tao/debug.h" + +Notify_Sequence_Push_Consumer::Notify_Sequence_Push_Consumer ( + const char* name, + unsigned int low, + unsigned int high, + Notify_Test_Client& client) + : name_ (name), + low_ (low), + high_ (high), + count_ (0), + client_ (client) +{ + this->client_.consumer_start (this); +} + + +void +Notify_Sequence_Push_Consumer::_connect ( + CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CosNotifyComm::SequencePushConsumer_var objref = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CosNotifyChannelAdmin::ProxySupplier_var proxysupplier = + consumer_admin->obtain_notification_push_supplier ( + CosNotifyChannelAdmin::SEQUENCE_EVENT, + proxy_id_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->proxy_ = + CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow ( + proxysupplier.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CosNotification::QoSProperties properties (3); + properties.length (3); + properties[0].name = CORBA::string_dup (CosNotification::MaximumBatchSize); + properties[0].value <<= (CORBA::Long) 3; + properties[1].name = CORBA::string_dup (CosNotification::PacingInterval); + properties[1].value <<= (TimeBase::TimeT) 1 * 1000 * 10000; + + this->proxy_->set_qos (properties); + this->proxy_->connect_sequence_push_consumer (objref.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // give ownership to POA + this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + + +void +Notify_Sequence_Push_Consumer::push_structured_events ( + const CosNotification::EventBatch& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG((LM_DEBUG, "{%u}", events.length())); + + this->count_ += events.length(); + + if (this->count_ > this->high_) + { + this->client_.consumer_done (this); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Sequence Consumer (%P|%t): ERROR: too " + "many events received.\n"))); + ACE_THROW (CORBA::INTERNAL ()); + } + else if (this->count_ >= this->low_) + { + this->client_.consumer_done (this); + } +} diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.h new file mode 100644 index 00000000000..7a11dd60c37 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Notify_Sequence_Push_Consumer.h @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ +// $Id$ +// ========================================================================== +// +// = LIBRARY +// TAO/orbsvcs/tests/Notify/Discarding +// +// = FILENAME +// Notify_Sequence_Push_Consumer.h +// +// = DESCRIPTION +// A sequence push consumer implementation. +// +// = AUTHOR +// Chad Elliott <elliott_c@ociweb.com> +// +// ========================================================================== +#ifndef TAO_NOTIFY_SEQUENCE_PUSH_CONSUMER_H +#define TAO_NOTIFY_SEQUENCE_PUSH_CONSUMER_H + +#include "Notify_SequencePushConsumer.h" + +class Notify_Test_Client; + +class Notify_Sequence_Push_Consumer: public TAO_Notify_Tests_SequencePushConsumer +{ +public: + Notify_Sequence_Push_Consumer (const char* name, + unsigned int low, + unsigned int high, + Notify_Test_Client& client); + + void _connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +protected: + void push_structured_events (const CosNotification::EventBatch& + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + ACE_CString name_; + unsigned int low_; + unsigned int high_; + unsigned int count_; + Notify_Test_Client& client_; +}; + +#endif /* TAO_NOTIFY_SEQUENCE_PUSH_CONSUMER_H */ diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/README b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/README new file mode 100644 index 00000000000..0aac6bd0c6c --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/README @@ -0,0 +1,36 @@ +Sequence Event ETCL Filter Test +=============================== + + +Description +----------- + +This test checks push supplier and push consumer ETCL event filter mechanisms. +The supplier sends a number of events specified by the consumer. The consumer +can filter or not filter the events and can use multiple consumers. +The consumer may specify 'and' and/or 'or' relations on the filterable data +contained within an event. + + +Usage +----- + +The test consists of a Supplier and Consumer. The usage for each as is +follows: + +$ ./Sequence_Supplier +usage: ./Sequence_Supplier -o <iorfile> -e <# of events> + +$ ./Sequence_Consumer -\? +usage: ./Sequence_Consumer -k <ior> -l <low expected events> + -h <high expected events> + +To run this test, run the run_test.pl perl script. +This script is designed to test various aspects of the filtering +mechanism. + + +Expected Results +---------------- +The test script will display an error if for any test that fails. +Otherwise, the test passed. diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Seq_Multi_ETCL_Filter.mpc b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Seq_Multi_ETCL_Filter.mpc new file mode 100644 index 00000000000..5b4145b586f --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Seq_Multi_ETCL_Filter.mpc @@ -0,0 +1,38 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + avoids += ace_for_tao + IDL_Files { + go.idl + } + custom_only = 1 +} + +project(*Ntf Seq Supp): notifytest { + avoids += ace_for_tao + exename = Sequence_Supplier + + after += *idl + Source_Files { + Sequence_Supplier.cpp + goS.cpp + goC.cpp + } + IDL_Files { + } +} + +project(*Ntf Seq Cons): notifytest { + avoids += ace_for_tao + exename = Sequence_Consumer + + after += *idl + Source_Files { + goC.cpp + Notify_Sequence_Push_Consumer.cpp + Sequence_Consumer.cpp + } + IDL_Files { + } +} diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Consumer.cpp new file mode 100644 index 00000000000..c59a53095fb --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Consumer.cpp @@ -0,0 +1,203 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNamingC.h" +#include "Notify_Sequence_Push_Consumer.h" +#include "goC.h" + +#include "Notify_Test_Client.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static const char* ior = "file://supplier.ior"; +static unsigned int low = 32; +static unsigned int high = 32; + +// ****************************************************************** +// Subroutine Section +// ****************************************************************** + +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:l:h:d:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + + case 'l': + low = ACE_OS::atoi (get_opts.optarg); + break; + + case 'h': + high = ACE_OS::atoi (get_opts.optarg); + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-l <low expected events> " + "-h <high expected events> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + + +static CosNotifyChannelAdmin::ConsumerAdmin_ptr +create_consumeradmin (CosNotifyChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::AdminID adminid = 0; + CosNotifyChannelAdmin::ConsumerAdmin_var admin = + ec->new_for_consumers (CosNotifyChannelAdmin::AND_OP, + adminid + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK_RETURN (0); + + CosNotifyFilter::FilterFactory_var ffact = + ec->default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::Filter_var filter = + ffact->create_filter ("EXTENDED_TCL" ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if(CORBA::is_nil(filter.in())) + { + ACE_ERROR ((LM_ERROR, + " (%P|%t) Consumer unable to initialize filter.\n")); + return CosNotifyChannelAdmin::ConsumerAdmin::_nil (); + } + + CosNotifyFilter::ConstraintExpSeq constraint_list (1); + constraint_list.length(1); + + constraint_list[0].event_types.length (0); + constraint_list[0].constraint_expr = CORBA::string_dup ( + "$.enum < 0"); + + filter->add_constraints (constraint_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // apply filter + admin->add_filter (filter.in ()); + + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin.in ()); +} + + +static void +create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin, + Notify_Test_Client* client + ACE_ENV_ARG_DECL) +{ + // startup the consumer + Notify_Sequence_Push_Consumer* consumer_1; + ACE_NEW_THROW_EX (consumer_1, + Notify_Sequence_Push_Consumer ("consumer1", + low, + high, + *client), + CORBA::NO_MEMORY ()); + + consumer_1->init (client->root_poa () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + consumer_1->_connect (admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +// ****************************************************************** +// Main Section +// ****************************************************************** + +int main (int argc, char* argv[]) +{ + int status = 0; + ACE_TRY_NEW_ENV + { + Consumer_Client client; + + status = client.init (argc, argv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (status == 0) + { + CosNotifyChannelAdmin::EventChannel_var ec = + client.create_event_channel ("MyEventChannel", 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ORB_ptr orb = client.orb (); + CORBA::Object_var object = + orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + sig_var sig = sig::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (sig.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior), + 1); + } + + CosNotifyChannelAdmin::ConsumerAdmin_var admin = + create_consumeradmin (ec.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (!CORBA::is_nil (admin.in ())) + { + create_consumers (admin.in (), &client ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Tell the supplier to go + sig->go (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + client.ORB_run( ACE_ENV_SINGLE_ARG_PARAMETER ); + ACE_TRY_CHECK; + ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); + + sig->done (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + } + ACE_CATCH (CORBA::Exception, e) + { + ACE_PRINT_EXCEPTION (e, "Error: Consumer exception: "); + status = 1; + } + ACE_ENDTRY; + + return status; +} diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Supplier.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Supplier.cpp new file mode 100644 index 00000000000..483a7446f92 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/Sequence_Supplier.cpp @@ -0,0 +1,284 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" +#include "ace/Auto_Ptr.h" + +#include "tao/ORB_Core.h" + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/TimeBaseC.h" +#include "Notify_SequencePushSupplier.h" +#include "goS.h" + +#include "Notify_Test_Client.h" + +#include "ace/OS_NS_unistd.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** +const int PER_BATCH = 16; +static TAO_Notify_Tests_SequencePushSupplier* supplier_1 = 0; +static int num_batches = 6; // 6 sets of 16 +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 (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + started_ = true; + } + + void done (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + started_ = false; + } + + void wait_for_startup() + { + while (! started_) { + ACE_Time_Value tv(0, 100 * 1000); // 100ms + orb_->run(tv); + } + } + + void wait_for_completion() + { + 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:e:d"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'e': + num_batches = 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 <iorfile> -e <# of events>" + "\n", + argv [0]), + -1); + } + + // Indicates sucessful parsing of the command line + return 0; +} + + +static CosNotifyChannelAdmin::SupplierAdmin_ptr +create_supplieradmin (CosNotifyChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::AdminID adminid = 0; + CosNotifyChannelAdmin::SupplierAdmin_var admin = + ec->new_for_suppliers (CosNotifyChannelAdmin::AND_OP, + adminid + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK_RETURN (0); + + return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (admin.in ()); +} + + +static void +SendEvents (int id ACE_ENV_ARG_DECL) +{ + static const char* types[] = { "good", "bad", "ugly" }; + CosNotification::EventBatch events; + + CosNotification::StructuredEvent event; + + event.header.fixed_header.event_type.domain_name = + CORBA::string_dup ("Orbix 2000 Demos"); + event.header.fixed_header.event_type.type_name = + CORBA::string_dup ("Sequence Notification Push Demo Event"); + + event.header.fixed_header.event_name = CORBA::string_dup ("test event"); + + event.header.variable_header.length (2); + event.header.variable_header[0].name = + CORBA::string_dup (CosNotification::Priority); + event.header.variable_header[1].name = + CORBA::string_dup (CosNotification::Timeout); + + event.filterable_data.length (3); + event.filterable_data[0].name = CORBA::string_dup ("objectId"); + event.filterable_data[1].name = CORBA::string_dup ("type"); + event.filterable_data[2].name = CORBA::string_dup ("enum"); + + events.length (PER_BATCH); + + for (int z = 0; z < PER_BATCH; ++z) + { + event.header.variable_header[0].value <<= (CORBA::Short) + (id > num_batches / 2 ? + -id : id); + + event.filterable_data[0].value <<= (CORBA::Long)z; + event.filterable_data[1].value <<= types[2 - (id % 3)]; + event.filterable_data[2].value <<= (CORBA::Long) + (id > num_batches / 2 ? + -id : id); + + events[z] = event; + } + + ACE_TRY_NEW_ENV + { + supplier_1->send_events (events ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::Exception, e) + { + ACE_PRINT_EXCEPTION (e, "Error: Supplier exception: "); + } + ACE_ENDTRY; +} + +static void +create_suppliers (CosNotifyChannelAdmin::SupplierAdmin_ptr admin, + PortableServer::POA_ptr poa + ACE_ENV_ARG_DECL) +{ + // start up the supplier + ACE_NEW_THROW_EX (supplier_1, + TAO_Notify_Tests_SequencePushSupplier (), + CORBA::NO_MEMORY ()); + + supplier_1->init (poa ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + supplier_1->connect (admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + + +// ****************************************************************** +// Main Section +// ****************************************************************** + +int main (int argc, char* argv[]) +{ + ACE_Auto_Ptr< sig_i > sig_impl; + int status = 0; + ACE_TRY_NEW_ENV + { + Supplier_Client client; + status = client.init (argc, argv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (status == 0) + { + CosNotifyChannelAdmin::EventChannel_var ec = + client.create_event_channel ("MyEventChannel", 0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ORB_ptr orb = client.orb (); + + sig_impl.reset( new sig_i( orb ) ); + sig_var sig = sig_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (sig.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for " + "writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + CosNotifyChannelAdmin::SupplierAdmin_var admin = + create_supplieradmin (ec.in () ACE_ENV_ARG_PARAMETER); + if (!CORBA::is_nil (admin.in ())) + { + create_suppliers (admin.in (), client.root_poa () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + sig_impl->wait_for_startup(); + + ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d batches of %d events...\n", num_batches, PER_BATCH)); + for (int i = 0; i < num_batches; ++i) + { + ACE_DEBUG((LM_DEBUG, "+")); + SendEvents (i ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_DEBUG((LM_DEBUG, "\nSupplier waiting for consumer...\n")); + + sig_impl->wait_for_completion(); + + ACE_DEBUG((LM_DEBUG, "\nSupplier done.\n")); + + ACE_OS::unlink (ior_output_file); + + ec->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + } + ACE_CATCH (CORBA::Exception, e) + { + ACE_PRINT_EXCEPTION (e, "Error: Supplier exception: "); + status = 1; + } + ACE_ENDTRY; + + return status; +} diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/go.idl b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/go.idl new file mode 100644 index 00000000000..e24bfd036c7 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/go.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 (); +}; diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf new file mode 100644 index 00000000000..751ea3700a2 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf @@ -0,0 +1,4 @@ +## $Id$ +# +## Load the static Cos Notification Service +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 1" diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf.xml b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf.xml new file mode 100644 index 00000000000..d03fcf8be90 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf.xml @@ -0,0 +1,6 @@ +<?xml version='1.0'?> +<!-- Converted from ./orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/notify.conf by svcconf-convert.pl --> +<ACE_Svc_Conf> + <!-- # $Id$ --> + <static id="Notify_Default_Event_Manager_Objects_Factory" params="-DispatchingThreads 1"/> +</ACE_Svc_Conf> diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/run_test.pl b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/run_test.pl new file mode 100755 index 00000000000..4cd49864e2f --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/run_test.pl @@ -0,0 +1,76 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$ior = PerlACE::LocalFile ("supplier.ior"); +$notifyior = PerlACE::LocalFile ("notify.ior"); +$notify_conf = PerlACE::LocalFile ("notify$PerlACE::svcconf_ext"); +$status = 0; + +unlink $notifyior; + +$port = PerlACE::uniqueid () + 10001; +$NS = new PerlACE::Process ("../../../Naming_Service/Naming_Service", + "-ORBEndpoint iiop://localhost:$port"); +$TS = new PerlACE::Process ("../../../Notify_Service/Notify_Service", + "-ORBInitRef NameService=iioploc://" . + "localhost:$port/NameService " . + "-IORoutput $notifyior -ORBSvcConf " . + "$notify_conf"); +$SES = new PerlACE::Process ("Sequence_Supplier", + "-ORBInitRef NameService=iioploc://" . + "localhost:$port/NameService"); +$SEC = new PerlACE::Process ("Sequence_Consumer"); + +$client_args = "-ORBInitRef NameService=iioploc://localhost:" . + "$port/NameService"; +$NS->Spawn (); +$TS->Spawn (); + +if (PerlACE::waitforfile_timed ($notifyior, 20) == -1) { + print STDERR "ERROR: waiting for the notify service to start\n"; + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +print "************** Running Sequence Consumer ************\n"; + +unlink $ior; +$SES->Spawn (); + +if (PerlACE::waitforfile_timed ($ior, 20) == -1) { + print STDERR "ERROR: waiting for the supplier to start\n"; + $SES->Kill (); + $TS->Kill (); + $NS->Kill (); + $status = 1; +} + +$SEC->Arguments($client_args); +$client = $SEC->SpawnWaitKill (60); +if ($client != 0) { + print STDERR "ERROR: Sequence_Consumer did not run properly\n"; + $status = 1; +} +$server = $SES->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +$TS->Kill (); +$NS->Kill (); + +unlink $ior; +unlink $notifyior; + + +exit $status; |