diff options
Diffstat (limited to 'modules/CIAO/connectors/dds4ccm/tests/QueryFilter')
18 files changed, 2393 insertions, 0 deletions
diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.idl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.idl new file mode 100644 index 00000000000..be30edc9ae6 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.idl @@ -0,0 +1,25 @@ +// $Id$ + +/** + * @file QueryFilter_Starter.idl + * @author Marcel Smit <msmit@remedy.nl> + */ + +#ifndef QUERYFILTER_STARTER_IDL +#define QUERYFILTER_STARTER_IDL + +#pragma ciao lem "Base/QueryFilter_StarterE.idl" + +interface QueryFilterStarter +{ + void set_reader_properties (in unsigned short nr_keys, + in unsigned short nr_iterations); + void start_read (in unsigned short run); +}; + +interface QueryFilterRestarter +{ + void restart_write (); +}; + +#endif /* QUERYFILTER_STARTER_IDL */ diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.mpc b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.mpc new file mode 100755 index 00000000000..1dacde89666 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Starter.mpc @@ -0,0 +1,114 @@ +// $Id$ + +project(DDS_QueryFilter_Starter_idl_gen) : componentidldefaults, dds4ccm { + custom_only = 1 + idlflags += -Wb,stub_export_macro=READER_STARTER_STUB_Export \ + -Wb,stub_export_include=QueryFilter_Starter_stub_export.h \ + -Wb,skel_export_macro=READER_STARTER_SVNT_Export \ + -Wb,skel_export_include=QueryFilter_Starter_svnt_export.h \ + -Wb,svnt_export_macro=READER_STARTER_SVNT_Export \ + -Wb,svnt_export_include=QueryFilter_Starter_svnt_export.h \ + -Wb,exec_export_macro=READER_STARTER_EXEC_Export \ + -Wb,exec_export_include=QueryFilter_Starter_exec_export.h -I.. + + IDL_Files { + QueryFilter_Starter.idl + } +} + +project(DDS_QueryFilter_Starter_lem_gen) : ciaoidldefaults, dds4ccm { + after += DDS_QueryFilter_Starter_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=READER_STARTER_LEM_STUB_Export \ + -Wb,stub_export_include=QueryFilter_Starter_lem_stub_export.h \ + -SS -Gxhst -I.. + + IDL_Files { + QueryFilter_StarterE.idl + } +} + +project(DDS_QueryFilter_Starter_lem_stub) : ccm_svnt, dds4ccm_base { + after += DDS_QueryFilter_Starter_lem_gen DDS_QueryFilter_Starter_stub + libs += QueryFilter_Starter_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = QueryFilter_Starter_lem_stub + dynamicflags = READER_STARTER_LEM_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_StarterEC.cpp + } + + Header_Files { + QueryFilter_StarterEC.h + QueryFilter_Starter_lem_stub_export.h + } + + Inline_Files { + QueryFilter_StarterEC.inl + } +} + +project(DDS_QueryFilter_Starter_stub) : ccm_stub, dds4ccm_base { + after += DDS_QueryFilter_Starter_idl_gen + libs += + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = QueryFilter_Starter_stub + dynamicflags = READER_STARTER_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_StarterC.cpp + } + + Header_Files { + QueryFilter_StarterC.h + QueryFilter_Starter_stub_export.h + } + + Inline_Files { + QueryFilter_StarterC.inl + } +} + + +project(DDS_QueryFilter_Starter_svnt) : ciao_servant, dds4ccm_base { + after += DDS_QueryFilter_Starter_lem_stub DDS_QueryFilter_Starter_stub\ + DDS4CCM_lem_stub DDS4CCM_skel + sharedname = QueryFilter_Starter_svnt + libs += QueryFilter_Starter_stub QueryFilter_Starter_lem_stub \ + DDS4CCM_lem_stub DDS4CCM_skel + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = READER_STARTER_SVNT_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_StarterS.cpp + QueryFilter_Starter_svnt.cpp + } + + Header_Files { + QueryFilter_StarterS.h + QueryFilter_Starter_svnt.h + QueryFilter_Starter_svnt_export.h + } + + Inline_Files { + QueryFilter_StarterS.inl + } +} + + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.idl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.idl new file mode 100644 index 00000000000..dc6d2e6c800 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.idl @@ -0,0 +1,23 @@ +// $Id$ + +/** + * @file QueryFilter_Test_Base.idl + * @author Marcel Smit <msmit@remedy.nl> + */ + +#ifndef QUERY_FILTER_TEST_BASE_IDL +#define QUERY_FILTER_TEST_BASE_IDL + +#pragma ndds typesupport "Base/QueryFilter_Test_BaseSupport.h" + +#pragma DCPS_DATA_TYPE "QueryFilterTest" +#pragma DCPS_DATA_KEY "QueryFilterTest symbol" + +struct QueryFilterTest { + string symbol; //@key + long iteration; +}; + +typedef sequence<QueryFilterTest> QueryFilterTestSeq; + +#endif diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.mpc b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.mpc new file mode 100755 index 00000000000..080d970cb08 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Base/QueryFilter_Test_Base.mpc @@ -0,0 +1,26 @@ +// $Id$ + +project (QueryFilter_Test_Base_stub) : taoidldefaults, anytypecode, dds4ccm_ts_default { + sharedname = QueryFilter_Test_Base_stub + dynamicflags += QUERY_FILTER_TEST_BASE_STUB_BUILD_DLL + libout = ../lib + + idlflags += -SS -Sci \ + -Wb,stub_export_macro=QUERY_FILTER_TEST_BASE_STUB_Export \ + -Wb,stub_export_include=QueryFilter_Test_Base_stub_export.h + + IDL_Files { + idlflags += -Gxhst + QueryFilter_Test_Base.idl + } + + opendds_ts_flags += --export=QUERY_FILTER_TEST_BASE_STUB_Export + + DDSGenerator_Files { + QueryFilter_Test_Base.idl + } + + Source_Files { + } +} + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.idl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.idl new file mode 100644 index 00000000000..593fc21e8aa --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.idl @@ -0,0 +1,25 @@ +// $Id$ + +/** + * @file QueryFilter_Test_Connector.idl + * @author Marcel Smit <msmit@remedy.nl> + */ + +#ifndef QUERY_FILTER_TEST_CONNECTOR_IDL_ +#define QUERY_FILTER_TEST_CONNECTOR_IDL_ + +#include <Components.idl> +#include "Base/QueryFilter_Test_Base.idl" +#include "connectors/dds4ccm/idl/ccm_dds.idl" + +#pragma ciao lem "Connector/QueryFilter_Test_ConnectorE.idl" + +module QueryFilter_Test +{ + module ::CCM_DDS::Typed < ::QueryFilterTest, ::QueryFilterTestSeq> QueryFilterTestConn; + connector QueryFilter_Test_Connector : QueryFilterTestConn::DDS_Event + { + }; +}; + +#endif /* QUERY_FILTER_TEST_CONNECTOR_IDL_ */ diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.mpc b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.mpc new file mode 100755 index 00000000000..babfda6364f --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Connector/QueryFilter_Test_Connector.mpc @@ -0,0 +1,145 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -p QueryFilter_Test_Base -l .. -o ../lib -u DDS QueryFilter_Test_Connector" + +project(QueryFilter_Test_Connector_idl_gen) : connectoridldefaults, dds4ccm { + after += DDS4CCM_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=QUERY_FILTER_TEST_CONNECTOR_STUB_Export \ + -Wb,stub_export_include=QueryFilter_Test_Connector_stub_export.h \ + -Wb,skel_export_macro=QUERY_FILTER_TEST_CONNECTOR_SVNT_Export \ + -Wb,skel_export_include=QueryFilter_Test_Connector_svnt_export.h \ + -Wb,svnt_export_macro=QUERY_FILTER_TEST_CONNECTOR_SVNT_Export \ + -Wb,svnt_export_include=QueryFilter_Test_Connector_svnt_export.h \ + -Wb,conn_export_macro=QUERY_FILTER_TEST_CONNECTOR_CONN_Export \ + -Wb,conn_export_include=QueryFilter_Test_Connector_conn_export.h \ + -I .. + + IDL_Files { + QueryFilter_Test_Connector.idl + } +} + +project(QueryFilter_Test_Connector_lem_gen) : ciaoidldefaults, dds4ccm { + custom_only = 1 + after += QueryFilter_Test_Connector_idl_gen + idlflags += -Wb,stub_export_macro=QUERY_FILTER_TEST_CONNECTOR_LEM_STUB_Export \ + -Wb,stub_export_include=QueryFilter_Test_Connector_lem_stub_export.h \ + -SS -Gxhst \ + -I .. + + IDL_Files { + QueryFilter_Test_ConnectorE.idl + } +} + +project(QueryFilter_Test_Connector_lem_stub) : ccm_svnt, dds4ccm_base { + after += QueryFilter_Test_Connector_lem_gen QueryFilter_Test_Connector_stub QueryFilter_Test_Base_stub DDS4CCM_lem_stub + libs += QueryFilter_Test_Base_stub QueryFilter_Test_Connector_stub DDS4CCM_lem_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = QueryFilter_Test_Connector_lem_stub + dynamicflags = QUERY_FILTER_TEST_CONNECTOR_LEM_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ConnectorEC.cpp + } + + Header_Files { + QueryFilter_Test_ConnectorEC.h + QueryFilter_Test_Connector_lem_stub_export.h + } + + Inline_Files { + QueryFilter_Test_ConnectorEC.inl + } +} + +project(QueryFilter_Test_Connector_stub) : ccm_stub, dds4ccm_base { + after += QueryFilter_Test_Connector_idl_gen QueryFilter_Test_Base_stub + libs += QueryFilter_Test_Base_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = QueryFilter_Test_Connector_stub + dynamicflags = QUERY_FILTER_TEST_CONNECTOR_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ConnectorC.cpp + } + + Header_Files { + QueryFilter_Test_ConnectorC.h + QueryFilter_Test_Connector_stub_export.h + } + + Inline_Files { + QueryFilter_Test_ConnectorC.inl + } +} + +project(QueryFilter_Test_Connector_exec) : ciao_executor, dds4ccm_impl { + after += QueryFilter_Test_Connector_lem_stub QueryFilter_Test_Connector_stub DDS4CCM_lem_stub QueryFilter_Test_Base_stub + sharedname = QueryFilter_Test_Connector_exec + libs += QueryFilter_Test_Connector_stub QueryFilter_Test_Connector_lem_stub QueryFilter_Test_Base_stub DDS4CCM_lem_stub QueryFilter_Test_Base_stub + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = QUERY_FILTER_TEST_CONNECTOR_CONN_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_Connector_conn.cpp + } + + Header_Files { + QueryFilter_Test_Connector_conn.h + QueryFilter_Test_Connector_conn_export.h + } + + Inline_Files { + } +} + + +project(QueryFilter_Test_Connector_svnt) : ciao_servant, dds4ccm_impl { + after += QueryFilter_Test_Connector_lem_stub QueryFilter_Test_Connector_exec QueryFilter_Test_Connector_stub DDS4CCM_lem_stub + sharedname = QueryFilter_Test_Connector_svnt + libs += QueryFilter_Test_Connector_stub \ + QueryFilter_Test_Connector_lem_stub \ + QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_exec \ + DDS4CCM_lem_stub + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = QUERY_FILTER_TEST_CONNECTOR_SVNT_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ConnectorS.cpp + QueryFilter_Test_Connector_svnt.cpp + } + + Header_Files { + QueryFilter_Test_ConnectorS.h + QueryFilter_Test_Connector_svnt.h + QueryFilter_Test_Connector_svnt_export.h + } + + Inline_Files { + QueryFilter_Test_ConnectorS.inl + } +} + + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/README b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/README new file mode 100644 index 00000000000..79dc0f2962d --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/README @@ -0,0 +1,3 @@ +# $Id$ + +This test tests the QueryFilter on the Reader. diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.idl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.idl new file mode 100644 index 00000000000..4f5b973bc6d --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.idl @@ -0,0 +1,25 @@ +// $Id$ + +/** + * @file + * @author Marcel Smit <msmit@remedy.nl> + */ + +#ifndef RECEIVER_IDL +#define RECEIVER_IDL + +#include "Connector/QueryFilter_Test_Connector.idl" +#include "Base/QueryFilter_Starter.idl" + +module QueryFilter_Test +{ + component Receiver + { + port QueryFilterTestConn::DDS_Get get_port; + + provides QueryFilterStarter reader_start; + uses QueryFilterRestarter writer_restart; + }; +}; + +#endif diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.mpc b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.mpc new file mode 100755 index 00000000000..9b80fe796a4 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver.mpc @@ -0,0 +1,157 @@ +// $Id$ + +project(QueryFilter_Test_Receiver_idl_gen) : componentidldefaults, dds4ccm { + custom_only = 1 + after += QueryFilter_Test_Connector_idl_gen + idlflags += -Wb,stub_export_macro=RECEIVER_STUB_Export \ + -Wb,stub_export_include=Receiver_stub_export.h \ + -Wb,skel_export_macro=RECEIVER_SVNT_Export \ + -Wb,skel_export_include=Receiver_svnt_export.h \ + -Wb,svnt_export_macro=RECEIVER_SVNT_Export \ + -Wb,svnt_export_include=Receiver_svnt_export.h \ + -Wb,exec_export_macro=RECEIVER_EXEC_Export \ + -Wb,exec_export_include=Receiver_exec_export.h -I.. + + IDL_Files { + QueryFilter_Test_Receiver.idl + } +} + +project(QueryFilter_Test_Receiver_lem_gen) : ciaoidldefaults, dds4ccm { + after += QueryFilter_Test_Receiver_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=RECEIVER_LEM_STUB_Export \ + -Wb,stub_export_include=Receiver_lem_stub_export.h \ + -SS -Gxhst -I.. + + IDL_Files { + QueryFilter_Test_ReceiverE.idl + } +} + +project(QueryFilter_Test_Receiver_lem_stub) : ccm_svnt, dds4ccm_base { + after += QueryFilter_Test_Receiver_lem_gen QueryFilter_Test_Receiver_stub \ + QueryFilter_Test_Connector_stub QueryFilter_Test_Base_stub \ + DDS_QueryFilter_Starter_stub + libs += Receiver_stub QueryFilter_Test_Connector_stub \ + QueryFilter_Test_Base_stub QueryFilter_Starter_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = Receiver_lem_stub + dynamicflags = RECEIVER_LEM_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ReceiverEC.cpp + } + + Header_Files { + QueryFilter_Test_ReceiverEC.h + Receiver_lem_stub_export.h + } + + Inline_Files { + QueryFilter_Test_ReceiverEC.inl + } +} + +project(QueryFilter_Test_Receiver_stub) : ccm_stub, dds4ccm_base { + after += QueryFilter_Test_Receiver_idl_gen QueryFilter_Test_Connector_stub \ + QueryFilter_Test_Base_stub QueryFilter_Test_Connector_lem_gen \ + DDS_QueryFilter_Starter_stub DDS_QueryFilter_Starter_lem_stub + libs += QueryFilter_Test_Connector_stub QueryFilter_Test_Base_stub \ + QueryFilter_Starter_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = Receiver_stub + dynamicflags = RECEIVER_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ReceiverC.cpp + } + + Header_Files { + QueryFilter_Test_ReceiverC.h + Receiver_stub_export.h + } + + Inline_Files { + QueryFilter_Test_ReceiverC.inl + } +} + +project(QueryFilter_Test_Receiver_exec) : ciao_executor, dds4ccm_base { + after += QueryFilter_Test_Receiver_lem_stub QueryFilter_Test_Receiver_stub \ + QueryFilter_Test_Base_stub QueryFilter_Test_Connector_stub \ + QueryFilter_Test_Connector_lem_stub DDS4CCM_lem_stub \ + DDS_QueryFilter_Starter_lem_stub DDS_QueryFilter_Starter_stub + sharedname = Receiver_exec + libs += Receiver_stub Receiver_lem_stub QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_stub QueryFilter_Test_Connector_lem_stub \ + DDS4CCM_lem_stub QueryFilter_Starter_lem_stub QueryFilter_Starter_stub + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = RECEIVER_EXEC_BUILD_DLL READER_STARTER_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_Receiver_exec.cpp + } + + Header_Files { + QueryFilter_Test_Receiver_exec.h + Receiver_exec_export.h + } + + Inline_Files { + } +} + + +project(QueryFilter_Test_Receiver_svnt) : ciao_servant, dds4ccm_base { + after += QueryFilter_Test_Receiver_lem_stub QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_stub QueryFilter_Test_Connector_svnt \ + QueryFilter_Test_Receiver_exec QueryFilter_Test_Connector_lem_stub \ + DDS4CCM_lem_stub DDS4CCM_skel DDS_QueryFilter_Starter_stub \ + DDS_QueryFilter_Starter_svnt DDS_QueryFilter_Starter_lem_stub + sharedname = Receiver_svnt + libs += Receiver_stub Receiver_lem_stub QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_stub QueryFilter_Test_Connector_svnt \ + Receiver_exec QueryFilter_Test_Connector_lem_stub DDS4CCM_lem_stub \ + DDS4CCM_skel QueryFilter_Starter_stub QueryFilter_Starter_svnt \ + QueryFilter_Starter_lem_stub + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = RECEIVER_SVNT_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_ReceiverS.cpp + QueryFilter_Test_Receiver_svnt.cpp + } + + Header_Files { + QueryFilter_Test_ReceiverS.h + QueryFilter_Test_Receiver_svnt.h + Receiver_svnt_export.h + } + + Inline_Files { + QueryFilter_Test_ReceiverS.inl + } +} + + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.cpp b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.cpp new file mode 100644 index 00000000000..a9992f030fb --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.cpp @@ -0,0 +1,545 @@ +// -*- C++ -*- +// +// $Id$ + +#include "QueryFilter_Test_Receiver_exec.h" + +#include "ace/OS_NS_unistd.h" +#include "tao/ORB_Core.h" +#include "ace/Reactor.h" +#include "ace/Log_Msg.h" + +#include "dds4ccm/impl/dds4ccm_conf.h" + +#define QUERY "( (iteration > %0) AND (iteration < %1) )" + +#define MIN_ITERATION_1 "2" +#define MAX_ITERATION_1 "5" + +#define MIN_ITERATION_2 "12" +#define MAX_ITERATION_2 "25" + + +namespace CIAO_QueryFilter_Test_Receiver_Impl +{ + //============================================================ + // read_action_Generator + //============================================================ + read_action_Generator::read_action_Generator (Receiver_exec_i &callback, int run) + : callback_ (callback), + run_ (run) + { + } + + read_action_Generator::~read_action_Generator () + { + } + + int + read_action_Generator::handle_timeout (const ACE_Time_Value &, const void *) + { + ACE_DEBUG ((LM_DEBUG, "Checking if last sample " + "is available in DDS...\n")); + if (this->run_ == 1 || this->callback_.check_last ()) + { + this->callback_.run (this->run_); + } + return 0; + } + + //============================================================ + // Starter_exec_i + //============================================================ + Starter_exec_i::Starter_exec_i (Receiver_exec_i & callback) + : callback_ (callback) + { + } + + Starter_exec_i::~Starter_exec_i (void) + { + } + + void + Starter_exec_i::set_reader_properties (CORBA::UShort nr_keys, + CORBA::UShort nr_iterations) + { + this->callback_.keys (nr_keys); + this->callback_.iterations (nr_iterations); + } + + void + Starter_exec_i::start_read (CORBA::UShort run) + { + this->callback_.start_read (run); + } + + //============================================================ + // Receiver_exec_i + //============================================================ + Receiver_exec_i::Receiver_exec_i (void) + : iterations_ (10), + keys_ (5), + has_run_ (false), + current_min_iteration_ (ACE_OS::atoi (MIN_ITERATION_1)), + current_max_iteration_ (ACE_OS::atoi (MAX_ITERATION_1)), + ticker_ (0) + { + } + + Receiver_exec_i::~Receiver_exec_i (void) + { + } + + + bool + Receiver_exec_i::check_last () + { + try + { + QueryFilterTest queryfiltertest_info; + ::CCM_DDS::ReadInfo readinfo; + char key[100]; + ACE_OS::sprintf (key, "KEY_%d", this->keys_); + queryfiltertest_info.symbol = CORBA::string_dup (key); + this->reader_->read_one_last ( + queryfiltertest_info, + readinfo, + ::DDS::HANDLE_NIL); + ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::check_last - " + "last iteration <%d> - <%d>\n", + queryfiltertest_info.iteration, + this->current_max_iteration_ - 1)); + return queryfiltertest_info.iteration >= this->current_max_iteration_ - 1; + } + catch (...) + { + // no need to catch. An error is given + // when this example didn't run at all. + } + return false; + } + + // Supported operations and attributes. + void + Receiver_exec_i::check_iter (const QueryFilterTest & sample, + const char * test) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%C ALL : ") + ACE_TEXT ("sample received for <%C>: iteration <%u>\n"), + test, + sample.symbol.in (), + sample.iteration)); + if (sample.iteration <= ACE_OS::atoi (MIN_ITERATION_1)) + { + ACE_ERROR ((LM_ERROR, "ERROR: %C ALL: " + "Didn't expect samples with iterations " + "<= %d\n", + test, + this->current_min_iteration_)); + } + if (sample.iteration > this->current_max_iteration_) + { + ACE_ERROR ((LM_ERROR, "ERROR: %C ALL: " + "Didn't expect samples with iterations " + "> %d\n", + test, + this->current_max_iteration_)); + } + } + + + void + Receiver_exec_i::read_all (void) + { + QueryFilterTestSeq *queryfiltertest_info_seq; + ::CCM_DDS::ReadInfoSeq *readinfo_seq; + this->reader_->read_all ( + queryfiltertest_info_seq, + readinfo_seq); + if (queryfiltertest_info_seq->length () == 0) + { + ACE_ERROR ((LM_ERROR, "ERROR : Receiver_exec_i::read_all : " + "No samples available in Reader!\n")); + } + for (CORBA::ULong it = 0; it < queryfiltertest_info_seq->length (); ++it) + { + this->check_iter ((*queryfiltertest_info_seq)[it], "READ"); + } + } + + void + Receiver_exec_i::get_all (void) + { + if (::CORBA::is_nil (this->getter_)) + { + ACE_ERROR ((LM_ERROR, "ERROR: No Getter\n")); + } + QueryFilterTest * qf_info = new QueryFilterTest; + ::CCM_DDS::ReadInfo readinfo; + bool result = this->getter_->get_one (qf_info, readinfo); + this->check_iter (*qf_info, "GET"); + while (result) + { + result = this->getter_->get_one (qf_info, readinfo); + if (result) + { + this->check_iter (*qf_info, "GET"); + } + } + } + + void + Receiver_exec_i::test_all () + { + const char * test = "GET ALL"; + try + { + get_all (); + test = "READ ALL"; + read_all (); + } + catch (const CCM_DDS::NonExistent& ex) + { + for (CORBA::ULong i = 0; i < ex.indexes.length (); ++i) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ERROR %C: ") + ACE_TEXT ("caught expected exception: index <%u>\n"), + test, + ex.indexes[i])); + } + } + catch (const CCM_DDS::InternalError& ex) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: %C: ") + ACE_TEXT ("caught InternalError exception: retval <%u>\n"), + test, + ex.error_code)); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception (test); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: Receiver_exec_i::test_all : Exception caught\n"))); + } + } + + void + Receiver_exec_i::test_exception () + { + CCM_DDS::QueryFilter * filter = 0; + try + { + filter = this->reader_->filter (); + } + catch (const CCM_DDS::InternalError& ex) + { + ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::test_excep - " + "Expected InternalErr excep caught : retval <%u>\n", + ex.error_code)); + return; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("ERROR: Receiver_exec_i::test_exception: "); + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::test_exception - " + "Unexpected exception caught\n")); + return; + } + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::test_exception - " + "No exception caught while retrieving unset filter.\n")); + } + + void + Receiver_exec_i::check_filter () + { + CCM_DDS::QueryFilter * filter = 0; + try + { + filter = this->reader_->filter (); + } + catch (const CCM_DDS::InternalError& ex) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "caught InternalError exception: retval <%u>\n", + ex.error_code)); + return; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("ERROR: Receiver_exec_i::check_filter: "); + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "Exception caught\n")); + return; + } + + //check query + bool error = false; + if (ACE_OS::strcmp (filter->query, QUERY) != 0) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "Unexpected query when retrieving filter: " + "expected <%C> - received <%C>\n", + QUERY, filter->query.in ())); + error = true; + } + //check current parameters. + if (filter->query_parameters.length () != 2) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "Unexpected number of parameters: " + "expected <%d> - received <%d>\n", + 2, filter->query_parameters.length ())); + error = true; + } + + if (filter->query_parameters.length () >= 1) + { + if (ACE_OS::atoi (filter->query_parameters[0]) != this->current_min_iteration_) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "Unexpected query when retrieving filter: " + "expected <%C> - received <%C>\n", + QUERY, filter->query.in ())); + error = true; + } + } + if (filter->query_parameters.length () >= 2) + { + if (ACE_OS::atoi (filter->query_parameters[1]) != this->current_max_iteration_) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::check_filter - " + "Unexpected query when retrieving filter: " + "expected <%C> - received <%C>\n", + QUERY, filter->query.in ())); + error = true; + } + } + if (!error) + { + ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::check_filter - " + "Passed check_filter test.\n")); + } + } + + void + Receiver_exec_i::test_set_query_parameters () + { + try + { + CCM_DDS::QueryFilter filter; + filter.query = CORBA::string_dup ("na"); + filter.query_parameters.length (2); + filter.query_parameters[0] = CORBA::string_dup (MIN_ITERATION_2); + filter.query_parameters[1] = CORBA::string_dup (MAX_ITERATION_2); + this->reader_->filter (filter); + this->current_min_iteration_ = ACE_OS::atoi (MIN_ITERATION_2); + this->current_max_iteration_ = ACE_OS::atoi (MAX_ITERATION_2); + } + catch (const CCM_DDS::InternalError& ex) + { + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::test_set_query_parameters - " + "caught InternalError exception: retval <%u>\n", + ex.error_code)); + return; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("ERROR: Receiver_exec_i::test_set_query_parameters: "); + ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::test_set_query_parameters - " + "Exception caught\n")); + return; + } + } + + void + Receiver_exec_i::set_filter () + { + ACE_DEBUG ((LM_DEBUG, "Set filter\n")); + CCM_DDS::QueryFilter filter; + filter.query = CORBA::string_dup (QUERY); + filter.query_parameters.length (2); + filter.query_parameters[0] = CORBA::string_dup (MIN_ITERATION_1); + filter.query_parameters[1] = CORBA::string_dup (MAX_ITERATION_1); + this->reader_->filter (filter); + } + + void + Receiver_exec_i::start_read (CORBA::UShort run) + { + this->ticker_ = new read_action_Generator (*this, run); + if (this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->schedule_timer ( + this->ticker_, + 0, + ACE_Time_Value(1, 0), + ACE_Time_Value(1, 0)) == -1) + { + ACE_ERROR ((LM_ERROR, "Unable to schedule Timer\n")); + } + } + + void + Receiver_exec_i::run (CORBA::UShort run) + { + if (this->ticker_) + { + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_); + delete this->ticker_; + this->ticker_ = 0; + } + this->has_run_ = true; + ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::run - " + "Starting run number <%d>\n", + run)); + switch (run) + { + case 1: + { + test_exception (); + set_filter (); + this->restarter_->restart_write (); + } + break; + case 2: + { + test_all (); + check_filter (); + test_set_query_parameters (); + this->restarter_->restart_write (); + } + break; + case 3: + { + test_all (); + check_filter (); + } + break; + } + } + + ::CORBA::UShort + Receiver_exec_i::iterations (void) + { + return this->iterations_; + } + + void + Receiver_exec_i::iterations (::CORBA::UShort iterations) + { + this->iterations_ = iterations; + } + + ::CORBA::UShort + Receiver_exec_i::keys (void) + { + return this->keys_; + } + + void + Receiver_exec_i::keys (::CORBA::UShort keys) + { + this->keys_ = keys; + } + + // Port operations. + ::QueryFilter_Test::QueryFilterTestConn::CCM_Listener_ptr + Receiver_exec_i::get_read_port_data_listener (void) + { + return ::QueryFilter_Test::QueryFilterTestConn::CCM_Listener::_nil (); + } + + ::CCM_DDS::CCM_PortStatusListener_ptr + Receiver_exec_i::get_read_port_status (void) + { + return ::CCM_DDS::CCM_PortStatusListener::_nil (); + } + + ::CCM_DDS::CCM_PortStatusListener_ptr + Receiver_exec_i::get_get_port_status (void) + { + return ::CCM_DDS::CCM_PortStatusListener::_nil (); + } + + ::CCM_QueryFilterStarter_ptr + Receiver_exec_i::get_reader_start () + { + return new Starter_exec_i (*this); + } + + // Operations from Components::SessionComponent. + void + Receiver_exec_i::set_session_context ( + ::Components::SessionContext_ptr ctx) + { + this->context_ = + ::QueryFilter_Test::CCM_Receiver_Context::_narrow (ctx); + if ( ::CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + } + + void + Receiver_exec_i::configuration_complete (void) + { + } + + void + Receiver_exec_i::ccm_activate (void) + { + this->reader_ = this->context_->get_connection_get_port_data (); + this->getter_ = this->context_->get_connection_get_port_fresh_data (); + DDS::Duration_t to; + to.sec = 5; + to.nanosec = 0; + if (! ::CORBA::is_nil (this->getter_)) + { + this->getter_->time_out (to); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR: Unable to set time out.\n")); + } + this->restarter_ = this->context_->get_connection_writer_restart (); +} + + void + Receiver_exec_i::ccm_passivate (void) + { + if (this->ticker_) + { + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_); + delete this->ticker_; + this->ticker_ = 0; + } + } + + void + Receiver_exec_i::ccm_remove (void) + { + if (!this->has_run_) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: ") + ACE_TEXT ("Test did not run: Didn't receive ") + ACE_TEXT ("the expected number of DATA_ON_READER ") + ACE_TEXT ("events.\n"))); + } + else + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished query filter test.\n"))); + } + } + + extern "C" RECEIVER_EXEC_Export ::Components::EnterpriseComponent_ptr + create_QueryFilter_Test_Receiver_Impl (void) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_NORETURN ( + retval, + Receiver_exec_i); + + return retval; + } +} + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.h b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.h new file mode 100644 index 00000000000..91f373abf67 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Receiver/QueryFilter_Test_Receiver_exec.h @@ -0,0 +1,142 @@ +// -*- C++ -*- +// $Id$ + +#ifndef CIAO_RECEIVER_EXEC_H_ +#define CIAO_RECEIVER_EXEC_H_ + +#include "QueryFilter_Test_ReceiverEC.h" + +#include /**/ "Receiver_exec_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" + +#include <map> + +namespace CIAO_QueryFilter_Test_Receiver_Impl +{ + class Receiver_exec_i; + + //============================================================ + // read_action_Generator + //============================================================ + class read_action_Generator + : public ACE_Event_Handler + { + public: + read_action_Generator (Receiver_exec_i &callback, + int run); + + ~read_action_Generator (); + + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *arg); + private: + Receiver_exec_i &callback_; + int run_; + + }; + + //============================================================ + // Starter_exec_i + //============================================================ + class Starter_exec_i + : public virtual ::CCM_QueryFilterStarter, + public virtual ::CORBA::LocalObject + { + public: + Starter_exec_i (Receiver_exec_i & callback); + virtual ~Starter_exec_i (void); + + virtual void set_reader_properties (CORBA::UShort nr_keys, + CORBA::UShort nr_iterations); + virtual void start_read (CORBA::UShort run); + + private: + Receiver_exec_i &callback_; + }; + + //============================================================ + // Receiver_exec_i + //============================================================ + class RECEIVER_EXEC_Export Receiver_exec_i + : public virtual Receiver_Exec, + public virtual ::CORBA::LocalObject + { + public: + Receiver_exec_i (void); + virtual ~Receiver_exec_i (void); + + // Supported operations and attributes. + // Component attributes. + + // Port operations. + virtual ::QueryFilter_Test::QueryFilterTestConn::CCM_Listener_ptr + get_read_port_data_listener (void); + + virtual ::CCM_DDS::CCM_PortStatusListener_ptr + get_read_port_status (void); + + virtual ::CCM_QueryFilterStarter_ptr + get_reader_start (); + + virtual ::CCM_DDS::CCM_PortStatusListener_ptr + get_get_port_status (void); + + bool check_last (); + void start_read (CORBA::UShort run); + void run (CORBA::UShort run); + + ::CORBA::UShort iterations (void); + + void iterations (::CORBA::UShort iterations); + + ::CORBA::UShort keys (void); + + void keys (::CORBA::UShort keys); + + // Operations from Components::SessionComponent. + virtual void + set_session_context ( + ::Components::SessionContext_ptr ctx); + + virtual void configuration_complete (void); + + virtual void ccm_activate (void); + virtual void ccm_passivate (void); + virtual void ccm_remove (void); + + private: + ::QueryFilter_Test::CCM_Receiver_Context_var context_; + ::QueryFilter_Test::QueryFilterTestConn::Reader_var reader_; + ::QueryFilter_Test::QueryFilterTestConn::Getter_var getter_; + QueryFilterRestarter_var restarter_; + CORBA::UShort iterations_; + CORBA::UShort keys_; + bool has_run_; + + int current_min_iteration_; + int current_max_iteration_; + + read_action_Generator *ticker_; + + void test_all (void); + void read_all (void); + void get_all (void); + void check_iter (const QueryFilterTest & sample, + const char * test); + void check_filter (void); + void test_exception (void); + void test_set_query_parameters (void); + void set_filter (void); + }; + + extern "C" RECEIVER_EXEC_Export ::Components::EnterpriseComponent_ptr + create_QueryFilter_Test_Receiver_Impl (void); +} + +#endif /* ifndef */ + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.idl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.idl new file mode 100644 index 00000000000..d30deb7c6b2 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.idl @@ -0,0 +1,29 @@ +// $Id$ + +/** + * @file + * @author Marcel Smit <msmit@remedy.nl> + * + * by-hand idl3 translation of sender components. + */ + +#ifndef DDS_QUERY_FILTER_TEST_SENDER_IDL +#define DDS_QUERY_FILTER_TEST_SENDER_IDL + +#include "Connector/QueryFilter_Test_Connector.idl" +#include "Base/QueryFilter_Starter.idl" + +module QueryFilter_Test +{ + component Sender + { + port QueryFilter_Test::QueryFilterTestConn::DDS_Write info_write; + + uses QueryFilterStarter start_reader; + provides QueryFilterRestarter restart_writer; + + attribute unsigned short keys; + }; +}; + +#endif diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.mpc b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.mpc new file mode 100755 index 00000000000..faa7da39896 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender.mpc @@ -0,0 +1,155 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -p QueryFilter_Test_Base -l ../lib -o ../lib -c controller -u DDS Sender" + +project(QueryFilter_Test_Sender_idl_gen) : componentidldefaults, dds4ccm { + after += QueryFilter_Test_Connector_idl_gen DDS_Starter_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=SENDER_STUB_Export \ + -Wb,stub_export_include=Sender_stub_export.h \ + -Wb,skel_export_macro=SENDER_SVNT_Export \ + -Wb,skel_export_include=Sender_svnt_export.h \ + -Wb,svnt_export_macro=SENDER_SVNT_Export \ + -Wb,svnt_export_include=Sender_svnt_export.h \ + -Wb,exec_export_macro=SENDER_EXEC_Export \ + -Wb,exec_export_include=Sender_exec_export.h \ + -I .. + + IDL_Files { + QueryFilter_Test_Sender.idl + } +} + +project(QueryFilter_Test_Sender_lem_gen) : ciaoidldefaults, dds4ccm { + after += QueryFilter_Test_Sender_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=SENDER_LEM_STUB_Export \ + -Wb,stub_export_include=Sender_lem_stub_export.h \ + -SS -Gxhst -I $CIAO_ROOT/connectors -I .. + + IDL_Files { + QueryFilter_Test_SenderE.idl + } +} + +project(QueryFilter_Test_Sender_lem_stub) : ccm_svnt, dds4ccm_base { + after += QueryFilter_Test_Sender_lem_gen QueryFilter_Test_Sender_stub \ + QueryFilter_Test_Base_stub DDS_QueryFilter_Starter_stub + libs += QueryFilter_Test_Base_stub Sender_stub QueryFilter_Starter_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = Sender_lem_stub + dynamicflags = SENDER_LEM_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_SenderEC.cpp + } + + Header_Files { + QueryFilter_Test_SenderEC.h + Sender_lem_stub_export.h + } + + Inline_Files { + QueryFilter_Test_SenderEC.inl + } +} + +project(QueryFilter_Test_Sender_stub) : ccm_stub, dds4ccm_base { + after += QueryFilter_Test_Sender_idl_gen QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_stub DDS_QueryFilter_Starter_stub \ + DDS_QueryFilter_Starter_lem_stub + libs += QueryFilter_Test_Base_stub QueryFilter_Test_Connector_stub \ + QueryFilter_Starter_stub + includes += .. + libpaths += ../lib + libout = ../lib + sharedname = Sender_stub + dynamicflags = SENDER_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_SenderC.cpp + } + + Header_Files { + QueryFilter_Test_SenderC.h + Sender_stub_export.h + } + + Inline_Files { + QueryFilter_Test_SenderC.inl + } +} + +project(QueryFilter_Test_Sender_exec) : ciao_executor, dds4ccm_base { + after += QueryFilter_Test_Sender_lem_stub QueryFilter_Test_Sender_stub \ + QueryFilter_Test_Connector_lem_stub QueryFilter_Test_Connector_stub \ + DDS4CCM_lem_stub DDS_QueryFilter_Starter_lem_stub + sharedname = Sender_exec + libs += Sender_stub Sender_lem_stub QueryFilter_Test_Base_stub \ + QueryFilter_Test_Connector_lem_stub QueryFilter_Test_Connector_stub \ + QueryFilter_Starter_stub DDS4CCM_lem_stub QueryFilter_Starter_lem_stub \ + QueryFilter_Starter_lem_stub + libpaths += ../lib + includes += .. + libout = ../lib + dynamicflags = SENDER_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_Sender_exec.cpp + } + + Header_Files { + QueryFilter_Test_Sender_exec.h + Sender_exec_export.h + } + + Inline_Files { + } +} + + +project(QueryFilter_Test_Sender_svnt) : ciao_servant, dds4ccm_base { + after += QueryFilter_Test_Base_stub QueryFilter_Test_Sender_lem_stub \ + DDS4CCM_lem_stub DDS4CCM_skel QueryFilter_Test_Connector_stub \ + QueryFilter_Test_Connector_svnt QueryFilter_Test_Connector_lem_stub \ + DDS_QueryFilter_Starter_stub DDS_QueryFilter_Starter_svnt \ + DDS_QueryFilter_Starter_lem_stub + sharedname = Sender_svnt + libs += Sender_stub Sender_lem_stub QueryFilter_Test_Base_stub DDS4CCM_lem_stub \ + DDS4CCM_skel QueryFilter_Test_Connector_stub QueryFilter_Test_Connector_svnt \ + QueryFilter_Test_Connector_lem_stub QueryFilter_Starter_stub \ + QueryFilter_Starter_svnt QueryFilter_Starter_lem_stub + libpaths += ../lib + libout = ../lib + includes += .. + dynamicflags = SENDER_SVNT_BUILD_DLL + + IDL_Files { + } + + Source_Files { + QueryFilter_Test_SenderS.cpp + QueryFilter_Test_Sender_svnt.cpp + } + + Header_Files { + QueryFilter_Test_SenderS.h + QueryFilter_Test_Sender_svnt.h + Sender_svnt_export.h + } + + Inline_Files { + QueryFilter_Test_SenderS.inl + } +} + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.cpp b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.cpp new file mode 100644 index 00000000000..67c33e222d8 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.cpp @@ -0,0 +1,182 @@ +// -*- C++ -*- +// $Id$ + +#include "QueryFilter_Test_Sender_exec.h" +#include "tao/ORB_Core.h" +#include "ace/Reactor.h" +#include "ace/Log_Msg.h" + +#define ITERATIONS 10 + +namespace CIAO_QueryFilter_Test_Sender_Impl +{ + //============================================================ + // WriteHandler + //============================================================ + WriteHandler::WriteHandler (Sender_exec_i &callback) + : callback_ (callback) + { + } + + int + WriteHandler::handle_exception (ACE_HANDLE) + { + this->callback_.start (); + return 0; + } + + //============================================================ + // Restarter_exec_i + //============================================================ + Restarter_exec_i::Restarter_exec_i (Sender_exec_i & callback) + : callback_ (callback) + { + } + + Restarter_exec_i::~Restarter_exec_i (void) + { + } + + void + Restarter_exec_i::restart_write () + { + this->callback_.restart (); + } + + //============================================================ + // Component Executor Implementation Class: Sender_exec_i + //============================================================ + Sender_exec_i::Sender_exec_i (void) + : iterations_ (ITERATIONS), + keys_ (5), + run_ (1) + { + } + + Sender_exec_i::~Sender_exec_i (void) + { + } + + void + Sender_exec_i::restart (void) + { + ++this->run_; + WriteHandler *wh = new WriteHandler (*this); + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->notify (wh); + } + + void + Sender_exec_i::start (void) + { + if (! ::CORBA::is_nil (this->starter_)) + { + this->starter_->set_reader_properties (this->keys_, this->iterations_); + } + else + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Unable to start the reader\n"))); + } + if (this->run_ > 1) + { + for (CORBA::UShort iter_key = 1; iter_key < this->keys_ + 1; ++iter_key) + { + char key[7]; + QueryFilterTest *new_key = new QueryFilterTest; + ACE_OS::sprintf (key, "KEY_%d", iter_key); + new_key->symbol = CORBA::string_dup(key); + for (CORBA::UShort iter = ((this->run_ - 2) * this->iterations_) + 1; + iter < this->run_ * this->iterations_ + 1; + ++iter) + { + new_key->iteration = iter; + this->writer_->write_one (*new_key, ::DDS::HANDLE_NIL); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Written key <%C> with <%d>\n"), + key, iter)); + } + } + ACE_OS::sleep (1); + } + this->starter_->start_read (this->run_); + } + + ::CORBA::UShort + Sender_exec_i::keys (void) + { + return this->keys_; + } + + void + Sender_exec_i::keys (::CORBA::UShort keys) + { + this->keys_ = keys; + } + + ::CCM_QueryFilterRestarter_ptr + Sender_exec_i::get_restart_writer (void) + { + return new Restarter_exec_i (*this); + } + + void + Sender_exec_i::set_session_context (::Components::SessionContext_ptr ctx) + { + this->context_ = + ::QueryFilter_Test::CCM_Sender_Context::_narrow (ctx); + + if ( ::CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + } + + void + Sender_exec_i::configuration_complete (void) + { + } + + void + Sender_exec_i::ccm_activate (void) + { + try + { + this->writer_ = this->context_->get_connection_info_write_data (); + this->starter_ = this->context_->get_connection_start_reader (); + WriteHandler *wh = new WriteHandler (*this); + this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->notify (wh); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: GET_CONNECTION_START_READER : Exception caught\n"))); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: GET_CONNECTION_START_READER : Unknown exception caught\n"))); + } + } + + void + Sender_exec_i::ccm_passivate (void) + { + } + + void + Sender_exec_i::ccm_remove (void) + { + } + + extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr + create_QueryFilter_Test_Sender_Impl (void) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_NORETURN ( + retval, + Sender_exec_i); + + return retval; + } +} diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.h b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.h new file mode 100644 index 00000000000..aaaf8b500f7 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/Sender/QueryFilter_Test_Sender_exec.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +// $Id$ + +#ifndef CIAO_SENDER_EXEC_H_ +#define CIAO_SENDER_EXEC_H_ + + +#include "QueryFilter_Test_SenderEC.h" + +#include /**/ "Sender_exec_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" + +namespace CIAO_QueryFilter_Test_Sender_Impl +{ + class Sender_exec_i; + + //============================================================ + // WriteHandler + //============================================================ + class WriteHandler : + public ACE_Event_Handler + { + public: + WriteHandler (Sender_exec_i &callback); + virtual int handle_exception (ACE_HANDLE fc = ACE_INVALID_HANDLE); + private: + Sender_exec_i &callback_; + }; + + //============================================================ + // Restarter_exec_i + //============================================================ + class Restarter_exec_i + : public virtual ::CCM_QueryFilterRestarter, + public virtual ::CORBA::LocalObject + { + public: + Restarter_exec_i (Sender_exec_i & callback); + virtual ~Restarter_exec_i (void); + + virtual void restart_write (); + + private: + Sender_exec_i &callback_; + }; + + //============================================================ + // Sender_exec_i + //============================================================ + class Sender_exec_i + : public virtual Sender_Exec, + public virtual ::CORBA::LocalObject + { + public: + Sender_exec_i (void); + virtual ~Sender_exec_i (void); + + virtual ::CORBA::UShort keys (void); + + virtual void keys (::CORBA::UShort keys); + + virtual ::CCM_QueryFilterRestarter_ptr + get_restart_writer (void); + + virtual void set_session_context (::Components::SessionContext_ptr ctx); + + virtual void configuration_complete (void); + + virtual void ccm_activate (void); + virtual void ccm_passivate (void); + virtual void ccm_remove (void); + + void start (void); + void restart (void); + + private: + ::QueryFilter_Test::CCM_Sender_Context_var context_; + ::QueryFilter_Test::QueryFilterTestConn::Writer_var writer_; + QueryFilterStarter_var starter_; + + CORBA::UShort iterations_; + CORBA::UShort keys_; + CORBA::UShort run_; + }; + + extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr + create_QueryFilter_Test_Sender_Impl (void); +} + +#endif /* ifndef */ + diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/Plan.cdp b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/Plan.cdp new file mode 100644 index 00000000000..05b925e0fcf --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/Plan.cdp @@ -0,0 +1,393 @@ +<Deployment:DeploymentPlan + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Deployment.xsd"> + <label>QueryFilter_Test_Depl_1</label> + <UUID>QueryFilter_Test_Depl_1</UUID> + + <implementation xmi:id="ReceiverComponentImplementation"> + <name>ReceiverComponentImplementation</name> + <source/> + <artifact xmi:idref="Receiver_ExecArtifact" /> + <artifact xmi:idref="Receiver_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see 10.6.1) --> + <name>component factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_Receiver_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_Receiver_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>Receiver_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>Receiver_exec</string> + </value> + </value> + </execParameter> + </implementation> + + <implementation xmi:id="QueryFilter_Test_ConnectorComponentImplementation"> + <name>QueryFilter_Test_ConnectorComponentImplementation</name> + <source/> + <artifact xmi:idref="QueryFilter_Test_Connector_ExecArtifact" /> + <artifact xmi:idref="QueryFilter_Test_Connector_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see 10.6.1) --> + <name>component factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_QueryFilter_Test_Connector_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_QueryFilter_Test_Connector_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Test_Connector_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Test_Connector_exec</string> + </value> + </value> + </execParameter> + </implementation> + <implementation xmi:id="SenderComponentImplementation"> + <name>SenderComponentImplementation</name> + <source/> + <artifact xmi:idref="Sender_ExecArtifact" /> + <artifact xmi:idref="Sender_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see 10.6.1) --> + <name>component factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_Sender_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_QueryFilter_Test_Sender_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>Sender_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>Sender_exec</string> + </value> + </value> + </execParameter> + </implementation> + <instance xmi:id="ReceiverComponentInstance"> + <name>ReceiverComponent</name> + <node>ReceiverNode</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="ReceiverComponentImplementation" /> + </instance> + <instance xmi:id="QueryFilter_Test_ConnectorComponentInstance"> + <name>QueryFilter_Test_ConnectorComponent</name> + <node>SenderNode</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="QueryFilter_Test_ConnectorComponentImplementation" /> + <configProperty> + <name>qos_profile</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Library#QueryFilter_Profile</string> + </value> + </value> + </configProperty> + <configProperty> + <name>topic_name</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Test</string> + </value> + </value> + </configProperty> + </instance> + <instance xmi:id="QueryFilter_Test_ConnectorComponentInstance2"> + <name>QueryFilter_Test_ConnectorComponent2</name> + <node>ReceiverNode</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="QueryFilter_Test_ConnectorComponentImplementation" /> + <configProperty> + <name>qos_profile</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Library#QueryFilter_Profile</string> + </value> + </value> + </configProperty> + <configProperty> + <name>topic_name</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>QueryFilter_Test</string> + </value> + </value> + </configProperty> + </instance> + <instance xmi:id="SenderComponentInstance"> + <name>SenderComponent</name> + <node>SenderNode</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SenderComponentImplementation" /> + <configProperty> + <name>keys</name> + <value> + <type> + <kind>tk_ulong</kind> + </type> + <value> + <ulong>5</ulong> + </value> + </value> + </configProperty> + </instance> + + <connection> + <name>get_port_data</name> + <deployRequirement> + <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name> + <resourceType>Local_Interface</resourceType> + </deployRequirement> + <internalEndpoint> + <portName>get_port_data</portName> + <provider>false</provider> + <kind>SimplexReceptacle</kind> + <instance xmi:idref="ReceiverComponentInstance" /> + </internalEndpoint> + <internalEndpoint> + <portName>pull_consumer_data</portName> + <provider>true</provider> + <kind>Facet</kind> + <instance xmi:idref="QueryFilter_Test_ConnectorComponentInstance2" /> + </internalEndpoint> + </connection> + + <connection> + <name>get_port_fresh_data</name> + <deployRequirement> + <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name> + <resourceType>Local_Interface</resourceType> + </deployRequirement> + <internalEndpoint> + <portName>get_port_fresh_data</portName> + <provider>false</provider> + <kind>SimplexReceptacle</kind> + <instance xmi:idref="ReceiverComponentInstance" /> + </internalEndpoint> + <internalEndpoint> + <portName>pull_consumer_fresh_data</portName> + <provider>true</provider> + <kind>Facet</kind> + <instance xmi:idref="QueryFilter_Test_ConnectorComponentInstance2" /> + </internalEndpoint> + </connection> + + <connection> + <name>writer_connection</name> + <deployRequirement> + <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name> + <resourceType>Local_Interface</resourceType> + </deployRequirement> + <internalEndpoint> + <portName>info_write_data</portName> + <provider>false</provider> + <kind>SimplexReceptacle</kind> + <instance xmi:idref="SenderComponentInstance" /> + </internalEndpoint> + <internalEndpoint> + <portName>supplier_data</portName> + <provider>true</provider> + <kind>Facet</kind> + <instance xmi:idref="QueryFilter_Test_ConnectorComponentInstance" /> + </internalEndpoint> + </connection> + + <connection> + <name>reader_starter</name> + <internalEndpoint> + <portName>start_reader</portName> + <provider>false</provider> + <kind>SimplexReceptacle</kind> + <instance xmi:idref="SenderComponentInstance" /> + </internalEndpoint> + <internalEndpoint> + <portName>reader_start</portName> + <provider>true</provider> + <kind>Facet</kind> + <instance xmi:idref="ReceiverComponentInstance" /> + </internalEndpoint> + </connection> + + <connection> + <name>restart_writer</name> + <internalEndpoint> + <portName>writer_restart</portName> + <provider>false</provider> + <kind>SimplexReceptacle</kind> + <instance xmi:idref="ReceiverComponentInstance" /> + </internalEndpoint> + <internalEndpoint> + <portName>restart_writer</portName> + <provider>true</provider> + <kind>Facet</kind> + <instance xmi:idref="SenderComponentInstance" /> + </internalEndpoint> + </connection> + + <artifact xmi:id="Sender_ExecArtifact"> + <name>Sender_exec</name> + <source/> + <node/> + <location>Sender_exec</location> + </artifact> + <artifact xmi:id="Sender_SvntArtifact"> + <name>Sender_svnt</name> + <source/> + <node/> + <location>Sender_svnt</location> + </artifact> + <artifact xmi:id="Sender_StubArtifact"> + <name>Sender_stub</name> + <source/> + <node/> + <location>Sender_stub</location> + </artifact> + <artifact xmi:id="QueryFilter_Test_Connector_ExecArtifact"> + <name>QueryFilter_Test_Connector_exec</name> + <source/> + <node/> + <location>QueryFilter_Test_Connector_exec</location> + </artifact> + <artifact xmi:id="QueryFilter_Test_Connector_SvntArtifact"> + <name>QueryFilter_Test_Connector_svnt</name> + <source/> + <node/> + <location>QueryFilter_Test_Connector_svnt</location> + </artifact> + <artifact xmi:id="QueryFilter_Test_Connector_StubArtifact"> + <name>QueryFilter_Test_Connector_stub</name> + <source/> + <node/> + <location>QueryFilter_Test_Connector_stub</location> + </artifact> + <artifact xmi:id="Receiver_ExecArtifact"> + <name>Receiver_exec</name> + <source/> + <node/> + <location>Receiver_exec</location> + </artifact> + <artifact xmi:id="Receiver_SvntArtifact"> + <name>Receiver_svnt</name> + <source/> + <node/> + <location>Receiver_svnt</location> + </artifact> + <artifact xmi:id="Receiver_StubArtifact"> + <name>Receiver_stub</name> + <source/> + <node/> + <location>Receiver_stub</location> + </artifact> +</Deployment:DeploymentPlan> diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/USER_QOS_PROFILES.xml b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/USER_QOS_PROFILES.xml new file mode 100644 index 00000000000..571930e854d --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/USER_QOS_PROFILES.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Description +XML QoS Profile + +The QoS configuration of the DDS entities in the generated example is +loaded from this file. + +This file is used only when it is in the current working directory +or when the enviroment variable +NDDS_QOS_PROFILES is defined and points to this file. + +For more information about XML QoS Profiles see Chapter 15 in the +RTI Data Distribution Service user manual. +--> +<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="c:/ndds/ndds.4.4d/scripts/../resource/rtiddsgen/../qos_profiles_4.4d/schema/rti_dds_qos_profiles.xsd" version="4.4d"> + <!-- QoS Library containing the QoS profile used in the generated example. + + A QoS library is a named set of QoS profiles. + --> + <qos_library name="QueryFilter_Library"> + <!-- QoS profile used to configure reliable communication between the DataWriter + and DataReader created in the example code. + + A QoS profile groups a set of related QoS. + --> + <qos_profile name="QueryFilter_Profile" is_default_qos="true"> + <!-- QoS used to configure the data writer created in the example code --> + <datawriter_qos> + <reliability> + <kind>RELIABLE_RELIABILITY_QOS</kind> + <max_blocking_time> + <sec>10</sec> + <nanosec>0</nanosec> + </max_blocking_time> + </reliability> + <durability> + <kind>TRANSIENT_DURABILITY_QOS</kind> + </durability> + <history> + <kind>KEEP_ALL_HISTORY_QOS</kind> + </history> + <protocol> + <rtps_reliable_writer> + <max_heartbeat_retries>10</max_heartbeat_retries> + </rtps_reliable_writer> + </protocol> + </datawriter_qos> + <!-- QoS used to configure the data reader created in the example code --> + <datareader_qos> + <reliability> + <kind>RELIABLE_RELIABILITY_QOS</kind> + </reliability> + <history> + <kind>KEEP_ALL_HISTORY_QOS</kind> + </history> + <durability> + <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind> + </durability> + </datareader_qos> + </qos_profile> + </qos_library> +</dds>
\ No newline at end of file diff --git a/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/run_test.pl b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/run_test.pl new file mode 100755 index 00000000000..708c17b2051 --- /dev/null +++ b/modules/CIAO/connectors/dds4ccm/tests/QueryFilter/descriptors/run_test.pl @@ -0,0 +1,244 @@ +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::TestTarget; + +$CIAO_ROOT = "$ENV{'CIAO_ROOT'}"; +$TAO_ROOT = "$ENV{'TAO_ROOT'}"; +$DANCE_ROOT = "$ENV{'DANCE_ROOT'}"; + +$daemons_running = 0; +$em_running = 0; +$ns_running = 0; + +$nr_daemon = 2; +@ports = ( 60001, 60002 ); +@iorbases = ( "NodeApp1.ior", "NodeApp2.ior" ); +@iorfiles = 0; +@nodenames = ( "SenderNode", "ReceiverNode" ); + +# ior files other than daemon +# ior files other than daemon +$ior_nsbase = "ns.ior"; +$ior_nsfile = 0; +$ior_embase = "EM.ior"; +$ior_emfile = 0; + +# Processes +$E = 0; +$EM = 0; +$NS = 0; +@DEAMONS = 0; + +# targets +@tg_daemons = 0; +$tg_naming = 0; +$tg_exe_man = 0; +$tg_executor = 0; + +$status = 0; +$cdp_file = "Plan.cdp"; + +sub create_targets { + # naming service + $tg_naming = PerlACE::TestTarget::create_target (1) || die "Create target for ns failed\n"; + $tg_naming->AddLibPath ('../lib'); + # daemon + for ($i = 0; $i < $nr_daemon; ++$i) { + $tg_daemons[$i] = PerlACE::TestTarget::create_target ($i+1) || die "Create target for deamon $i failed\n"; + $tg_daemons[$i]->AddLibPath ('../lib'); + } + # execution manager + $tg_exe_man = PerlACE::TestTarget::create_target (1) || die "Create target for EM failed\n"; + $tg_exe_man->AddLibPath ('../lib'); + # executor (plan_launcher) + $tg_executor = PerlACE::TestTarget::create_target (1) || die "Create target for executor failed\n"; + $tg_executor->AddLibPath ('../lib'); +} + +sub init_ior_files { + $ior_nsfile = $tg_naming->LocalFile ($ior_nsbase); + $ior_emfile = $tg_exe_man->LocalFile ($ior_embase); + for ($i = 0; $i < $nr_daemon; ++$i) { + $iorfiles[$i] = $tg_daemons[$i]->LocalFile ($iorbases[$i]); + } + delete_ior_files (); +} + +# Delete if there are any .ior files. +sub delete_ior_files { + for ($i = 0; $i < $nr_daemon; ++$i) { + $tg_daemons[$i]->DeleteFile ($iorbases[$i]); + } + $tg_naming->DeleteFile ($ior_nsbase); + $tg_exe_man->DeleteFile ($ior_embase); + for ($i = 0; $i < $nr_daemon; ++$i) { + $iorfiles[$i] = $tg_daemons[$i]->LocalFile ($iorbases[$i]); + } +} + +sub kill_node_daemon { + for ($i = 0; $i < $nr_daemon; ++$i) { + $DEAMONS[$i]->Kill (); $DEAMONS[$i]->TimedWait (1); + } +} + +sub kill_open_processes { + if ($daemons_running == 1) { + kill_node_daemon (); + } + + if ($em_running == 1) { + $EM->Kill (); $EM->TimedWait (1); + } + + if ($ns_running == 1) { + $NS->Kill (); $NS->TimedWait (1); + } + # in case shutdown did not perform as expected + $tg_executor->KillAll ('ciao_componentserver'); +} + +sub run_node_daemons { + for ($i = 0; $i < $nr_daemon; ++$i) { + $iorbase = $iorbases[$i]; + $iorfile = $iorfiles[$i]; + $port = $ports[$i]; + $nodename = $nodenames[$i]; + $iiop = "iiop://localhost:$port"; + $node_app = "$CIAO_ROOT/bin/ciao_componentserver"; + + $d_cmd = "$DANCE_ROOT/bin/dance_node_manager"; + $d_param = "-ORBEndpoint $iiop -s $node_app -n $nodename=$iorfile -t 30 --domain-nc corbaloc:rir:/NameService"; + + print "Run dance_node_manager with $d_param\n"; + + $DEAMONS[$i] = $tg_daemons[$i]->CreateProcess ($d_cmd, $d_param); + $DEAMONS[$i]->Spawn (); + + if ($tg_daemons[$i]->WaitForFileTimed($iorbase, + $tg_daemons[$i]->ProcessStartWaitInterval ()) == -1) { + print STDERR + "ERROR: The ior $iorfile file of node daemon $i could not be found\n"; + for (; $i >= 0; --$i) { + $DEAMONS[$i]->Kill (); $DEAMONS[$i]->TimedWait (1); + } + return -1; + } + } + return 0; +} + +create_targets (); +init_ior_files (); + +# Invoke naming service + +$NS = $tg_naming->CreateProcess ("$TAO_ROOT/orbsvcs/Naming_Service/Naming_Service", "-m 1 -ORBEndpoint iiop://localhost:60003 -o $ior_nsfile"); + +$ns_status = $NS->Spawn (); + +if ($ns_status != 0) { + print STDERR "ERROR: Unable to execute the naming service\n"; + kill_open_processes (); + exit 1; +} + +print STDERR "Starting Naming Service with -m 1 -ORBEndpoint iiop://localhost:60003 -o ns.ior\n"; + +if ($tg_naming->WaitForFileTimed ($ior_nsbase, + $tg_naming->ProcessStartWaitInterval ()) == -1) { + print STDERR "ERROR: cannot find naming service IOR file\n"; + $NS->Kill (); $NS->TimedWait (1); + exit 1; +} + +$ns_running = 1; +# Set up NamingService environment +$ENV{"NameServiceIOR"} = "corbaloc:iiop:localhost:60003/NameService"; + +# Invoke node daemon. +print "Invoking node daemon\n"; +$status = run_node_daemons (); + +if ($status != 0) { + print STDERR "ERROR: Unable to execute the node daemon\n"; + kill_open_processes (); + exit 1; +} + +$daemons_running = 1; + +# Invoke execution manager. +print "Invoking execution manager (dance_execution_manager.exe) with -e$ior_emfile\n"; +$EM = $tg_exe_man->CreateProcess ("$DANCE_ROOT/bin/dance_execution_manager", + "-e$ior_emfile --domain-nc corbaloc:rir:/NameService"); +$em_status = $EM->Spawn (); + +if ($em_status != 0) { + print STDERR "ERROR: dance_execution_manager returned $em_status"; + exit 1; +} + +if ($tg_exe_man->WaitForFileTimed ($ior_embase, + $tg_exe_man->ProcessStartWaitInterval ()) == -1) { + print STDERR + "ERROR: The ior file of execution manager could not be found\n"; + kill_open_processes (); + exit 1; +} + +$em_running = 1; + +# Invoke executor - start the application -. +print "Invoking executor - launch the application -\n"; + +print "Start dance_plan_launcher.exe with -x $cdp_file -k file://$ior_emfile\n"; +$E = $tg_executor->CreateProcess ("$DANCE_ROOT/bin/dance_plan_launcher", + "-x $cdp_file -k file://$ior_emfile"); +$pl_status = $E->SpawnWaitKill (2 * $tg_executor->ProcessStartWaitInterval ()); + +if ($pl_status != 0) { + print STDERR "ERROR: dance_plan_launcher returned $pl_status\n"; + kill_open_processes (); + exit 1; +} + +for ($i = 0; $i < $nr_daemon; ++$i) { + if ($tg_daemons[$i]->WaitForFileTimed ($iorbases[$i], + $tg_daemons[$i]->ProcessStopWaitInterval ()) == -1) { + print STDERR "ERROR: The ior file of daemon $i could not be found\n"; + kill_open_processes (); + exit 1; + } +} + +print "Sleeping 30 seconds to allow task to complete\n"; +sleep (30); + +# Invoke executor - stop the application -. +print "Invoking executor - stop the application -\n"; +print "by running dance_plan_launcher.exe with -k file://$ior_emfile -x $cdp_file -s\n"; + +$E = $tg_executor->CreateProcess ("$DANCE_ROOT/bin/dance_plan_launcher", + "-k file://$ior_emfile -x $cdp_file -s"); +$pl_status = $E->SpawnWaitKill ($tg_executor->ProcessStartWaitInterval ()); + +if ($pl_status != 0) { + print STDERR "ERROR: dance_plan_launcher returned $pl_status\n"; + kill_open_processes (); + exit 1; +} + +print "Executor returned.\n"; +print "Shutting down rest of the processes.\n"; + +delete_ior_files (); +kill_open_processes (); + +exit $status; |