diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Notify/performance-tests/Filter')
15 files changed, 1828 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Filter.mpc b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Filter.mpc new file mode 100644 index 00000000000..f2020bde1d3 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Filter.mpc @@ -0,0 +1,57 @@ +// $Id$ + +project(*idl): taoidldefaults, minimum_corba { + IDL_Files { + go.idl + } + custom_only = 1 +} + +project(*Ntf Perf Struct Supp): notifytest, minimum_corba { + after += *idl + exename = Structured_Supplier + Source_Files { + Structured_Supplier.cpp + goS.cpp + goC.cpp + } + IDL_Files { + } +} + +project(*Ntf Perf Struct Cons): notifytest, minimum_corba { + after += *idl + exename = Structured_Consumer + Source_Files { + goC.cpp + Notify_Structured_Push_Consumer.cpp + Structured_Consumer.cpp + } + IDL_Files { + } +} + +project(*Ntf Perf Seq Supp): notifytest, minimum_corba { + after += *idl + exename = Sequence_Supplier + Source_Files { + Sequence_Supplier.cpp + goS.cpp + goC.cpp + } + IDL_Files { + } +} + +project(*notify perf Sequence Consumer): notifytest, minimum_corba { + after += *idl + exename = Sequence_Consumer + Source_Files { + goC.cpp + Notify_Sequence_Push_Consumer.cpp + Sequence_Consumer.cpp + } + IDL_Files { + } +} + diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Makefile.am b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Makefile.am new file mode 100644 index 00000000000..4718b9c9c15 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Makefile.am @@ -0,0 +1,258 @@ +## 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.Filter_Idl.am + +if !BUILD_MINIMUM_CORBA + +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_MINIMUM_CORBA + +## Makefile.Filter_Notify_Perf_Sequence_Consumer.am + +if BUILD_CORBA_MESSAGING +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_CORBA_MESSAGING + +## Makefile.Filter_Ntf_Perf_Seq_Supp.am + +if BUILD_CORBA_MESSAGING +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 \ + Notify_Structured_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_CORBA_MESSAGING + +## Makefile.Filter_Ntf_Perf_Struct_Cons.am + +if BUILD_CORBA_MESSAGING +if !BUILD_MINIMUM_CORBA + +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 \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Structured_Consumer_SOURCES = \ + Notify_Structured_Push_Consumer.cpp \ + Structured_Consumer.cpp \ + goC.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)/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_CORBA_MESSAGING + +## Makefile.Filter_Ntf_Perf_Struct_Supp.am + +if BUILD_CORBA_MESSAGING +if !BUILD_MINIMUM_CORBA + +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 \ + -DTAO_HAS_TYPED_EVENT_CHANNEL + +Structured_Supplier_SOURCES = \ + Structured_Supplier.cpp \ + goC.cpp \ + goS.cpp \ + Notify_Sequence_Push_Consumer.h \ + 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)/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_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/performance-tests/Filter/Notify_Sequence_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Sequence_Push_Consumer.cpp new file mode 100644 index 00000000000..4abebdab3f4 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Sequence_Push_Consumer.cpp @@ -0,0 +1,92 @@ +// $Id$ + +#include "Notify_Sequence_Push_Consumer.h" +#include "Notify_Test_Client.h" +#include "common.h" + +#include "ace/OS_NS_sys_time.h" + +Notify_Sequence_Push_Consumer::Notify_Sequence_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); +} + + +Notify_Sequence_Push_Consumer::~Notify_Sequence_Push_Consumer () +{ +} + +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(1); + properties.length(1); + properties[0].name = CORBA::string_dup(CosNotification::MaximumBatchSize); + properties[0].value <<= (CORBA::Long)10; + + proxy_->set_qos(properties); + 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_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if ( this->count_ == 0 ) + { + this->first_ = ACE_OS::gettimeofday(); + } + + this->count_ += events.length(); + + if (this->count_ > this->expected_) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("\nError: Expected %d events. Received %d\n"), expected_, count_)); + this->client_.consumer_done (this); + return; + } + + if (this->count_ >= this->expected_) + { + this->client_.consumer_done (this); + ACE_Time_Value totaltime = ( ACE_OS::gettimeofday() - this->first_ ); + double events_per_ms = static_cast<double>(this->count_) / + static_cast<double>(totaltime.msec()); + ACE_DEBUG((LM_DEBUG, "\nConsumer %s received %d at %.2f events/ms\n", name_.c_str(), this->count_, events_per_ms )); + } +} diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Sequence_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Sequence_Push_Consumer.h new file mode 100644 index 00000000000..ccd5af92252 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Sequence_Push_Consumer.h @@ -0,0 +1,50 @@ +/* -*- 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 expected, + Notify_Test_Client& client); + + ~Notify_Sequence_Push_Consumer (); + + void _connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + void push_structured_events(const CosNotification::EventBatch& + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + ACE_CString name_; + unsigned int expected_; + unsigned int count_; + Notify_Test_Client& client_; + ACE_Time_Value first_; +}; + +#endif /* TAO_NOTIFY_SEQUENCE_PUSH_CONSUMER_H */ diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.cpp new file mode 100644 index 00000000000..271bf5fbeeb --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.cpp @@ -0,0 +1,86 @@ +// $Id$ + +#include "Notify_Structured_Push_Consumer.h" +#include "Notify_Test_Client.h" +#include "common.h" + +#include "ace/OS_NS_sys_time.h" + +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); +} + + +Notify_Structured_Push_Consumer::~Notify_Structured_Push_Consumer () +{ +} + + +void +Notify_Structured_Push_Consumer::_connect ( + CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CosNotifyComm::StructuredPushConsumer_var objref = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CosNotifyChannelAdmin::ProxySupplier_var proxysupplier = + consumer_admin->obtain_notification_push_supplier ( + CosNotifyChannelAdmin::STRUCTURED_EVENT, + proxy_id_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->proxy_ = + CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow ( + proxysupplier.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + proxy_->connect_structured_push_consumer (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + + +void +Notify_Structured_Push_Consumer::push_structured_event( + const CosNotification::StructuredEvent& /*event*/ + ACE_ENV_ARG_DECL_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if ( this->count_ == 0 ) + { + this->first_ = ACE_OS::gettimeofday(); + } + + if (this->count_ == this->expected_) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: too many events received.\n"))); + } + + //ACE_DEBUG((LM_DEBUG, "-")); + + this->count_++; + + if (this->count_ == this->expected_) + { + this->client_.consumer_done (this); + ACE_Time_Value totaltime = ( ACE_OS::gettimeofday() - this->first_ ); + double events_per_ms = static_cast<double>(this->count_) / + static_cast<double>(totaltime.msec()); + ACE_DEBUG((LM_DEBUG, "Consumer %s received %d at %.2f events/ms\n", name_.c_str(), this->count_, events_per_ms )); + } +} diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.h new file mode 100644 index 00000000000..cd34305133d --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Notify_Structured_Push_Consumer.h @@ -0,0 +1,50 @@ +/* -*- C++ -*- */ +// $Id$ +// ========================================================================== +// +// = LIBRARY +// TAO/orbsvcs/tests/Notify/Discarding +// +// = FILENAME +// Notify_Structured_Push_Consumer.h +// +// = DESCRIPTION +// 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" + +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); + ~Notify_Structured_Push_Consumer (); + + void _connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + void push_structured_event(const CosNotification::StructuredEvent& + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + ACE_CString name_; + unsigned int expected_; + unsigned int count_; + Notify_Test_Client& client_; + ACE_Time_Value first_; +}; + +#endif /* TAO_NOTIFY_STRUCTURED_PUSH_CONSUMER_H */ diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/README b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/README new file mode 100644 index 00000000000..0d326588015 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/README @@ -0,0 +1,34 @@ +Notification Performance Test +================================ + +Description +----------- + +Usage +----- + +The test consists of a Structured_Supplier and Structured_Consumer as well +as a Sequence_Supplier and Sequence_Consumer. The usage for each as is +follows: + +$ Structured_Supplier -\? +usage: Structured_Supplier -o <iorfile> -e <# of events> + +$ Structured_Consumer -\? +usage: Structured_Consumer -k <ior> -c <# of consumers> -e <expected events> + -f + +$ Sequence_Supplier -\? +usage: Sequence_Supplier -o <iorfile> -e <# of events> + +$ Sequence_Consumer -\? +usage: Sequence_Consumer -k <ior> -c <# of consumers> -e <expected events> -f + + +To run this test, just run the run_test.pl perl script. It will run both +structured and sequence tests with each of the implemented discard policies. + + +Expected Results +---------------- +This varies between hardware. diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Sequence_Consumer.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Sequence_Consumer.cpp new file mode 100644 index 00000000000..8d284b588a5 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Sequence_Consumer.cpp @@ -0,0 +1,225 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" + +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNamingC.h" +#include "Notify_Sequence_Push_Consumer.h" +#include "goC.h" +#include "tao/debug.h" +#include "ace/OS_NS_sys_time.h" + +#include "Notify_Test_Client.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static const char* ior = "file://supplier.ior"; +static CORBA::Boolean filter = 0; +static unsigned int consumers = 2; +static unsigned int batch_size = 10; +static unsigned int expected = 100; // 100 sets of 10 + +#define GRAMMAR "TCL" + +// ****************************************************************** +// 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:c:e:f"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + + case 'c': + consumers = ACE_OS::atoi (get_opts.optarg); + break; + + case 'e': + expected = ACE_OS::atoi (get_opts.optarg); + break; + + case 'f': + filter = 1; + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-c <# of consumers> " + "-e <expected events> " + "-f " + "\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); + + if (filter) + { + ACE_DEBUG((LM_DEBUG, "\nConsumer filter enabled.\n")); + + CosNotifyFilter::FilterFactory_var ffact = + ec->default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::Filter_var filter = + ffact->create_filter (GRAMMAR ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::ConstraintExpSeq constraint_list (1); + constraint_list.length (1); + + constraint_list[0].event_types.length (0); + constraint_list[0].constraint_expr = + CORBA::string_dup ("type == 'even'"); + + filter->add_constraints (constraint_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + admin->add_filter (filter.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin.in ()); +} + + +static void +create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin, + Notify_Test_Client* client + ACE_ENV_ARG_DECL) +{ + for(unsigned int i = 0; i < consumers; i++) + { + // startup the first consumer + char name[64] = ""; + ACE_OS::sprintf(name, "consumer%u", i); + Notify_Sequence_Push_Consumer* consumer; + ACE_NEW_THROW_EX (consumer, + Notify_Sequence_Push_Consumer ( + name, + expected * batch_size, + *client), + CORBA::NO_MEMORY ()); + + consumer->init (client->root_poa () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + consumer->_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) + { + // If we are filtering, we will get half as many as originally + // expected + if (filter) + { + expected /= 2; + } + + 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/performance-tests/Filter/Sequence_Supplier.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Sequence_Supplier.cpp new file mode 100644 index 00000000000..7b7df800ca5 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Sequence_Supplier.cpp @@ -0,0 +1,263 @@ +// $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 "Notify_SequencePushSupplier.h" +#include "goS.h" + +#include "Notify_Test_Client.h" + +#include "ace/OS_NS_unistd.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static TAO_Notify_Tests_SequencePushSupplier* supplier_1 = 0; +static int max_events = 100; // 100 sets of 10 +static const CORBA::ULong amount = 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 (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:"); + 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 <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) +{ + ACE_UNUSED_ARG(id); + CosNotification::EventBatch events (amount); + + events.length (amount); + + for(CORBA::ULong z = 0; z < amount; z++) + { + const char* type = ( (z & 1) == 1 ? "odd" : "even" ); + events[z].header.fixed_header.event_type.domain_name = + CORBA::string_dup("Orbix 2000 Demos"); + events[z].header.fixed_header.event_type.type_name = + CORBA::string_dup("Sequence Notification Push Demo Event"); + + events[z].header.fixed_header.event_name = CORBA::string_dup("test event"); + + events[z].filterable_data.length (1); + events[z].filterable_data[0].name = CORBA::string_dup("type"); + events[z].filterable_data[0].value <<= type; + } + + 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) +{ + // startup the first 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 events...\n", (max_events*amount))); + for (int i = 0; i < max_events; ++i) + { + SendEvents (i ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", (max_events*amount))); + + sig_impl->wait_for_completion(); + + 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/performance-tests/Filter/Structured_Consumer.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Structured_Consumer.cpp new file mode 100644 index 00000000000..a45be86190f --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Structured_Consumer.cpp @@ -0,0 +1,223 @@ +// $Id$ + +// ****************************************************************** +// Include Section +// ****************************************************************** + +#include "ace/Get_Opt.h" + +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNamingC.h" +#include "Notify_Structured_Push_Consumer.h" +#include "goC.h" +#include "tao/debug.h" +#include "Notify_Test_Client.h" +#include "ace/OS_NS_sys_time.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static const char* ior = "file://supplier.ior"; +static CORBA::Boolean filter = 0; +static unsigned int consumers = 2; +static unsigned int expected = 1000; + +#define GRAMMAR "TCL" + +// ****************************************************************** +// 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:e:c:f"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + + case 'c': + consumers = ACE_OS::atoi (get_opts.optarg); + break; + + case 'e': + expected = ACE_OS::atoi (get_opts.optarg); + break; + + case 'f': + filter = 1; + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-c <# of consumers> " + "-e <expected events> " + "-f " + "\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); + + if (filter) + { + // Filter Section + CosNotifyFilter::FilterFactory_var ffact = + ec->default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // One Filter + CosNotifyFilter::Filter_var filter = + ffact->create_filter (GRAMMAR ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CosNotifyFilter::ConstraintExpSeq constraint_list (1); + constraint_list.length (1); + + constraint_list[0].event_types.length (0); + constraint_list[0].constraint_expr = + CORBA::string_dup ("type == 'even'"); + + filter->add_constraints (constraint_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + admin->add_filter (filter.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + // End One Filter + } + + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin.in ()); +} + + +static void +create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin, + Notify_Test_Client* client + ACE_ENV_ARG_DECL) +{ + for(unsigned int i = 0; i < consumers; i++) + { + // startup the first consumer + char name[64] = ""; + ACE_OS::sprintf(name, "consumer%u", i); + Notify_Structured_Push_Consumer* consumer; + ACE_NEW_THROW_EX (consumer, + Notify_Structured_Push_Consumer ( + name, + expected, + *client), + CORBA::NO_MEMORY ()); + + consumer->init (client->root_poa () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + consumer->_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) + { + // If we are filtering, we will get half as many as originally + // expected + if (filter) + { + expected /= 2; + } + + 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/performance-tests/Filter/Structured_Supplier.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Structured_Supplier.cpp new file mode 100644 index 00000000000..f89028a58c1 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/Structured_Supplier.cpp @@ -0,0 +1,257 @@ +// $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 "Notify_StructuredPushSupplier.h" +#include "goS.h" + +#include "Notify_Test_Client.h" + +#include "ace/OS_NS_unistd.h" + +// ****************************************************************** +// Data Section +// ****************************************************************** + +static TAO_Notify_Tests_StructuredPushSupplier* supplier_1 = 0; +static int max_events = 1000; +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:"); + 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 <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 +SendEvent (int id ACE_ENV_ARG_DECL_NOT_USED) +{ + const char* type = ( (id & 1) == 1 ? "odd" : "even" ); + 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.filterable_data.length (1); + event.filterable_data[0].name = CORBA::string_dup("type"); + event.filterable_data[0].value <<= type; + + ACE_TRY_NEW_ENV + { + supplier_1->send_event(event 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) +{ + // startup the first supplier + ACE_NEW_THROW_EX (supplier_1, + TAO_Notify_Tests_StructuredPushSupplier (), + 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 events...\n", max_events)); + for (int i = 0; i < max_events; ++i) + { + SendEvent (i ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events)); + + sig_impl->wait_for_completion(); + + 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/performance-tests/Filter/go.idl b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/go.idl new file mode 100644 index 00000000000..e24bfd036c7 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/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/performance-tests/Filter/notify.conf b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/notify.conf new file mode 100644 index 00000000000..93af5f9d812 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/notify.conf @@ -0,0 +1,6 @@ +## $Id$ +# +## Load the static Cos Notification Service +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 1" + + diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/notify.conf.xml b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/notify.conf.xml new file mode 100644 index 00000000000..f398f140957 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/notify.conf.xml @@ -0,0 +1,6 @@ +<?xml version='1.0'?> +<!-- Converted from ./orbsvcs/tests/Notify/performance-tests/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/performance-tests/Filter/run_test.pl b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/run_test.pl new file mode 100755 index 00000000000..7d1e4ff85a7 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/run_test.pl @@ -0,0 +1,211 @@ +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"); +$namingior = PerlACE::LocalFile ("naming.ior"); +$notifyior = PerlACE::LocalFile ("notify.ior"); +$notify_conf = PerlACE::LocalFile ("notify$PerlACE::svcconf_ext"); +$status = 0; + +$port = PerlACE::uniqueid () + 10001; +$NS = new PerlACE::Process ("../../../../Naming_Service/Naming_Service", + "-ORBEndpoint iiop://localhost:$port " . + "-o $namingior"); +$TS = new PerlACE::Process ("../../../../Notify_Service/Notify_Service", + "-ORBInitRef NameService=iioploc://" . + "localhost:$port/NameService " . + "-IORoutput $notifyior -ORBSvcConf " . + "$notify_conf"); +$STS = new PerlACE::Process ("Structured_Supplier", + "-ORBInitRef NameService=iioploc://" . + "localhost:$port/NameService"); +$STC = new PerlACE::Process ("Structured_Consumer"); + +$SES = new PerlACE::Process ("Sequence_Supplier", + "-ORBInitRef NameService=iioploc://" . + "localhost:$port/NameService"); +$SEC = new PerlACE::Process ("Sequence_Consumer"); + +unlink $ior; +unlink $notifyior; +unlink $namingior; + +$client_args = "-ORBInitRef NameService=iioploc://localhost:" . + "$port/NameService"; + +$NS->Spawn (); +if (PerlACE::waitforfile_timed ($namingior, 20) == -1) { + print STDERR "ERROR: waiting for the naming service to start\n"; + $NS->Kill (); + exit 1; +} + +$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 "**** Structured Supplier -> 2 Structured Consumers ****\n"; +$STS->Spawn (); +if (PerlACE::waitforfile_timed ($ior, 20) == -1) { + print STDERR "ERROR: waiting for the supplier to start\n"; + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +$STC->Arguments($client_args); +print $STC->CommandLine ()."\n"; +$client = $STC->SpawnWaitKill (300); +print "\n"; +if ($client != 0) { + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} +$server = $STS->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + + +###################################################################### +print "**** Structured Supplier -> Structured Consumer (filtered) ****\n"; + +unlink $ior; +$STS->Spawn (); +if (PerlACE::waitforfile_timed ($ior, 20) == -1) { + print STDERR "ERROR: waiting for the supplier to start\n"; + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +$STC->Arguments($client_args . " -f -c 1"); +$client = $STC->SpawnWaitKill (60); +print "\n"; +if ($client != 0) { + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} +$server = $STS->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +###################################################################### +print "**** Structured Supplier -> Sequence Consumer (filtered) ****\n"; + +unlink $ior; +$STS->Spawn (); +if (PerlACE::waitforfile_timed ($ior, 20) == -1) { + print STDERR "ERROR: waiting for the supplier to start\n"; + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +$SEC->Arguments($client_args . " -f -c 1"); +$client = $SEC->SpawnWaitKill (60); +print "\n"; +if ($client != 0) { + $STS->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} +$server = $STS->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +###################################################################### +print "**** Sequence Supplier -> 2 Sequence Consumers ****\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 (); + exit 1; +} + +$SEC->Arguments($client_args); +$client = $SEC->SpawnWaitKill (60); +print "\n"; +if ($client != 0) { + $SES->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} +$server = $SES->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +###################################################################### +print "**** Sequence Supplier -> Sequence Consumer (filtered) ****\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 (); + exit 1; +} + +$SEC->Arguments($client_args . " -f -c 1"); +$client = $SEC->SpawnWaitKill (60); +print "\n"; +if ($client != 0) { + $SES->Kill (); + $TS->Kill (); + $NS->Kill (); + exit 1; +} +$server = $SES->WaitKill(5); +if ($server != 0) { + $TS->Kill (); + $NS->Kill (); + exit 1; +} + +$TS->Kill (); +$NS->Kill (); + +unlink $ior; +unlink $notifyior; +unlink $namingior; + + +exit $status; |