summaryrefslogtreecommitdiff
path: root/modules/CIAO/connectors/dds4ccm/examples/Quoter
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/connectors/dds4ccm/examples/Quoter')
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.idl29
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.mpc26
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.idl21
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.mpc139
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.cpp352
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.h134
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.idl29
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.mpc145
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.idl34
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.mpc140
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.cpp306
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.h166
-rw-r--r--modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/Plan.cdp425
-rwxr-xr-xmodules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/run_test.pl244
14 files changed, 2190 insertions, 0 deletions
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.idl b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.idl
new file mode 100644
index 00000000000..1b0dc464d6d
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.idl
@@ -0,0 +1,29 @@
+// $Id$
+
+/**
+ * @file Quoter_Base.idl
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ */
+
+#ifndef QUOTER_BASE_IDL
+#define QUOTER_BASE_IDL
+
+#pragma ndds typesupport "Base/Quoter_BaseSupport.h"
+#pragma opendds typesupport "Base/Quoter_BaseTypeSupportC.h"
+
+#pragma DCPS_DATA_TYPE "Quoter::Stock_Info"
+#pragma DCPS_DATA_KEY "Quoter::Stock_Info symbol"
+
+module Quoter
+{
+ struct Stock_Info
+ {
+ unsigned long low;
+ unsigned long high;
+ unsigned long current;
+ string symbol; //@key
+ };
+ typedef sequence<Stock_Info> Stock_InfoSeq;
+};
+
+#endif
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.mpc b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.mpc
new file mode 100644
index 00000000000..d3e88495282
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Base/Quoter_Base.mpc
@@ -0,0 +1,26 @@
+// $Id$
+
+project (DDS_Quoter_Base_stub) : taoidldefaults, anytypecode, dds4ccm_ts_default {
+ sharedname = DDS_Quoter_Base_stub
+ dynamicflags += QUOTER_BASE_STUB_BUILD_DLL
+ libout = ../lib
+
+ idlflags += -SS -Sci \
+ -Wb,stub_export_macro=QUOTER_BASE_STUB_Export \
+ -Wb,stub_export_include=Quoter_Base_stub_export.h
+
+ IDL_Files {
+ idlflags += -Gxhst
+ Quoter_Base.idl
+ }
+
+ opendds_ts_flags += --export=QUOTER_BASE_STUB_Export
+
+ DDSGenerator_Files {
+ Quoter_Base.idl
+ }
+
+ Source_Files {
+ }
+}
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.idl b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.idl
new file mode 100644
index 00000000000..905e7154a13
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.idl
@@ -0,0 +1,21 @@
+// $Id$
+
+/**
+ * @file Broker.idl
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ */
+
+#ifndef BROKER_IDL
+#define BROKER_IDL
+
+#include "Connector/Quoter_Connector.idl"
+
+module Quoter
+{
+ component Broker
+ {
+ port CCM_DDS::Quoter::DDS_Listen info_out;
+ };
+};
+
+#endif
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.mpc b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.mpc
new file mode 100644
index 00000000000..b51d8a49482
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker.mpc
@@ -0,0 +1,139 @@
+// $Id$
+// This file is generated with "generate_component_mpc.pl -l ../lib -o ../lib -u DDS -b dds4ccm_base Broker"
+
+project(DDS_Broker_idl_gen) : componentidldefaults, dds4ccm {
+ custom_only = 1
+ after += DDS_Quoter_Connector_idl_gen
+ idlflags += -Wb,stub_export_macro=BROKER_STUB_Export \
+ -Wb,stub_export_include=Broker_stub_export.h \
+ -Wb,skel_export_macro=BROKER_SVNT_Export \
+ -Wb,skel_export_include=Broker_svnt_export.h \
+ -Wb,svnt_export_macro=BROKER_SVNT_Export \
+ -Wb,svnt_export_include=Broker_svnt_export.h \
+ -Wb,exec_export_macro=BROKER_EXEC_Export \
+ -Wb,exec_export_include=Broker_exec_export.h -I..
+
+ IDL_Files {
+ Broker.idl
+ }
+}
+
+project(DDS_Broker_lem_gen) : ciaoidldefaults, dds4ccm {
+ after += DDS_Broker_idl_gen
+ custom_only = 1
+ idlflags += -Wb,stub_export_macro=BROKER_LEM_STUB_Export \
+ -Wb,stub_export_include=Broker_lem_stub_export.h \
+ -SS -Gxhst -I..
+
+ IDL_Files {
+ BrokerE.idl
+ }
+}
+
+project(DDS_Broker_lem_stub) : ccm_svnt, dds4ccm_base {
+ after += DDS_Broker_lem_gen DDS_Broker_stub DDS_Quoter_Connector_stub DDS_Quoter_Base_stub
+ libs += Broker_stub DDS_Quoter_Connector_stub DDS_Quoter_Base_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ sharedname = Broker_lem_stub
+ dynamicflags = BROKER_LEM_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ BrokerEC.cpp
+ }
+
+ Header_Files {
+ BrokerEC.h
+ Broker_lem_stub_export.h
+ }
+
+ Inline_Files {
+ BrokerEC.inl
+ }
+}
+
+project(DDS_Broker_stub) : ccm_stub, dds4ccm_base {
+ after += DDS_Broker_idl_gen DDS_Quoter_Connector_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_lem_gen
+ libs += DDS_Quoter_Connector_stub DDS_Quoter_Base_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ sharedname = Broker_stub
+ dynamicflags = BROKER_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ BrokerC.cpp
+ }
+
+ Header_Files {
+ BrokerC.h
+ Broker_stub_export.h
+ }
+
+ Inline_Files {
+ BrokerC.inl
+ }
+}
+
+project(DDS_Broker_exec) : ciao_executor, dds4ccm_base {
+ after += DDS_Broker_lem_stub DDS_Broker_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_stub DDS_Quoter_Connector_lem_stub DDS4CCM_lem_stub
+ sharedname = Broker_exec
+ libs += Broker_stub Broker_lem_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_stub DDS_Quoter_Connector_lem_stub DDS4CCM_lem_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ dynamicflags = BROKER_EXEC_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Broker_exec.cpp
+ }
+
+ Header_Files {
+ Broker_exec.h
+ Broker_exec_export.h
+ }
+
+ Inline_Files {
+ }
+}
+
+
+project(DDS_Broker_svnt) : ciao_servant, dds4ccm_base {
+ after += DDS_Broker_lem_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_stub DDS_Quoter_Connector_svnt DDS_Broker_exec DDS_Quoter_Connector_lem_stub DDS4CCM_lem_stub DDS4CCM_skel
+ sharedname = Broker_svnt
+ libs += Broker_stub Broker_lem_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_stub DDS_Quoter_Connector_svnt Broker_exec DDS_Quoter_Connector_lem_stub DDS4CCM_lem_stub DDS4CCM_skel
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ dynamicflags = BROKER_SVNT_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ BrokerS.cpp
+ Broker_svnt.cpp
+ }
+
+ Header_Files {
+ BrokerS.h
+ Broker_svnt.h
+ Broker_svnt_export.h
+ }
+
+ Inline_Files {
+ BrokerS.inl
+ }
+}
+
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.cpp b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.cpp
new file mode 100644
index 00000000000..3436cb80cd1
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.cpp
@@ -0,0 +1,352 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "Broker_exec.h"
+#include "ace/Reactor.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_unistd.h"
+#include "tao/ORB_Core.h"
+
+namespace CIAO_Quoter_Broker_Impl
+{
+
+ read_action_Generator::read_action_Generator (Broker_exec_i &callback)
+ : pulse_callback_ (callback)
+ {
+ }
+
+ read_action_Generator::~read_action_Generator ()
+ {
+ }
+
+ int
+ read_action_Generator::handle_timeout (const ACE_Time_Value &,
+ const void *)
+ {
+ // Notify the subscribers
+ // this->pulse_callback_.read_one();
+ // this->pulse_callback_.read_one_history();
+ // this->pulse_callback_.read_all();
+ // this->pulse_callback_.read_all_history();
+ return 0;
+ }
+
+ void
+ Broker_exec_i::read_one (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "read_one\n"));
+ ::Quoter::Stock_Info stock_info;
+ stock_info.symbol= "IBM";
+ ::CCM_DDS::ReadInfo readinfo;
+
+ try
+ {
+ this->reader_->read_one_last (stock_info, readinfo, ::DDS::HANDLE_NIL);
+ time_t tim = readinfo.source_timestamp.sec;
+ ACE_DEBUG ((LM_DEBUG, "Read_Info. -> date = %C\n", ctime (&tim)));
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_One: received a stock_info for <%C> at %u:%u:%u\n",
+ stock_info.symbol.in (),
+ stock_info.low,
+ stock_info.current,
+ stock_info.high));
+ }
+ catch(CCM_DDS::NonExistent& )
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_One: no stock_info received\n"));
+ }
+ }
+
+ void
+ Broker_exec_i::read_all (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "read_all\n"));
+
+ ::Quoter::Stock_InfoSeq_var stock_infos;
+ ::CCM_DDS::ReadInfoSeq_var readinfoseq;
+ this->reader_->read_all(stock_infos.out (), readinfoseq.out ());
+ if(readinfoseq->length()!= 0)
+ {
+ int nr_of_infos = readinfoseq->length();
+ for(int i = 0; i < nr_of_infos; i ++)
+ {
+ time_t tim = readinfoseq[i].source_timestamp.sec;
+ ACE_DEBUG ((LM_DEBUG, "Read_Info.source_timestamp -> date = %C\n",ctime (&tim)));
+ }
+ }
+ if(stock_infos->length()!= 0)
+ {
+ for(CORBA::ULong i = 0; i < stock_infos->length(); i ++)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_All: Number %d : received a stock_info for <%C> at %u:%u:%u\n",
+ i,
+ stock_infos[i].symbol.in (),
+ stock_infos[i].low,
+ stock_infos[i].current,
+ stock_infos[i].high));
+ }
+ }
+ }
+ void
+ Broker_exec_i::read_all_history (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "read_all_history\n"));
+
+ ::Quoter::Stock_InfoSeq_var stock_infos;
+ ::CCM_DDS::ReadInfoSeq_var readinfoseq;
+ this->reader_->read_all(stock_infos.out (), readinfoseq.out ());
+ if(readinfoseq->length()!= 0)
+ {
+ int nr_of_infos = readinfoseq->length();
+ for(int i = 0; i < nr_of_infos; i ++)
+ {
+ time_t tim = readinfoseq[i].source_timestamp.sec;
+ ACE_DEBUG ((LM_DEBUG, "Read_Info.source_timestamp -> date = %C\n", ctime (&tim)));
+ }
+ }
+ if(stock_infos->length()!= 0)
+ {
+ int nr_of_stock_infos = stock_infos->length();
+ for(CORBA::ULong i = 0; i < (CORBA::ULong)nr_of_stock_infos; i ++)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_All_History: Number %d : received a stock_info for <%C> at %u:%u:%u\n",
+ i,
+ stock_infos[i].symbol.in (),
+ stock_infos[i].low,
+ stock_infos[i].current,
+ stock_infos[i].high));
+ }
+ }
+ }
+ // read all samples of an given instance
+ void
+ Broker_exec_i::read_one_history (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "read_one_history\n"));
+ ::Quoter::Stock_Info stock_info;
+ stock_info.symbol= "IBM"; //key of instance to read
+
+ ::Quoter::Stock_InfoSeq_var stock_infos;
+ ::CCM_DDS::ReadInfoSeq_var readinfoseq;
+ try
+ {
+ this->reader_->read_one_all(stock_info,stock_infos.out (), readinfoseq.out (), ::DDS::HANDLE_NIL);
+ if(readinfoseq->length()!= 0)
+ {
+ int nr_of_infos = readinfoseq->length();
+ for(int i = 0; i < nr_of_infos; i ++)
+ {
+ time_t tim = readinfoseq[i].source_timestamp.sec;
+ ACE_DEBUG ((LM_DEBUG, "Read_Info.source_timestamp -> date = %C\n", ctime (&tim)));
+ }
+ }
+ if(stock_infos->length()!= 0)
+ {
+ int nr_of_stock_infos = stock_infos->length();
+ for(CORBA::ULong i = 0; i < (CORBA::ULong)nr_of_stock_infos; i ++)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_One_History: Number %d : received a stock_info for <%C> at %u:%u:%u\n",
+ i,
+ stock_infos[i].symbol.in (),
+ stock_infos[i].low,
+ stock_infos[i].current,
+ stock_infos[i].high));
+ }
+ }
+ }
+ catch(CCM_DDS::NonExistent& )
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Read_One_History: no stock_info's received\n"));
+ }
+ }
+ //============================================================
+ // Facet Executor Implementation Class: Stock_Info_Listener_exec_i
+ //============================================================
+
+ Stock_Info_Listener_exec_i::Stock_Info_Listener_exec_i (void)
+ {
+ }
+
+ Stock_Info_Listener_exec_i::~Stock_Info_Listener_exec_i (void)
+ {
+ }
+
+ void
+ Stock_Info_Listener_exec_i::on_many_data (
+ const ::Quoter::Stock_InfoSeq & /* an_instance */,
+ const ::CCM_DDS::ReadInfoSeq & /* info */)
+ {
+ }
+
+ void
+ Stock_Info_Listener_exec_i::on_one_data (
+ const ::Quoter::Stock_Info & an_instance,
+ const ::CCM_DDS::ReadInfo & /* info */)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Stock_Info_Listener: received a stock_info for <%C> at %u:%u:%u\n",
+ an_instance.symbol.in (),
+ an_instance.low,
+ an_instance.current,
+ an_instance.high));
+ }
+ //============================================================
+ // Facet Executor Implementation Class: PortStatusListener_exec_i
+ //============================================================
+
+ PortStatusListener_exec_i::PortStatusListener_exec_i (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "####### construct PortStatusListener ######\n"));
+ }
+
+ PortStatusListener_exec_i::~PortStatusListener_exec_i (void)
+ {
+ }
+
+ // Operations from ::CCM_DDS::PortStatusListener
+
+ void
+ PortStatusListener_exec_i::on_requested_deadline_missed (
+ ::DDS::DataReader_ptr /* the_reader */,
+ const ::DDS::RequestedDeadlineMissedStatus & /* status */)
+ {
+ ACE_DEBUG ((LM_DEBUG, "####### deadline missed ######\n"));
+ }
+
+ void
+ PortStatusListener_exec_i::on_sample_lost (
+ ::DDS::DataReader_ptr /*the_reader*/ ,
+ const ::DDS::SampleLostStatus & status )
+ {
+ ACE_DEBUG ((LM_DEBUG, "####### sample lost ######\n"));
+ ACE_DEBUG ((LM_DEBUG, " status.total_count = %d\n", status.total_count));
+ ACE_DEBUG ((LM_DEBUG, " status.total_count_change = %d\n", status.total_count_change));
+ }
+
+ //============================================================
+ // Component Executor Implementation Class: Broker_exec_i
+ //============================================================
+
+ Broker_exec_i::Broker_exec_i (void)
+ {
+ ACE_OS::srand (static_cast <u_int> (ACE_OS::time ()));
+ this->ticker_ = new read_action_Generator (*this);
+ }
+
+ Broker_exec_i::~Broker_exec_i (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Broker_exec_i::~Broker_exec_i\n"));
+ }
+
+ // Supported operations and attributes.
+
+ // Component attributes.
+
+ // Port operations.
+
+ ::CCM_DDS::Quoter::CCM_Listener_ptr
+ Broker_exec_i::get_info_out_data_listener (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "*************** out listener\n"));
+ return new Stock_Info_Listener_exec_i ();
+ }
+
+ ::CCM_DDS::CCM_PortStatusListener_ptr
+ Broker_exec_i::get_info_out_status (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "*************** out status************************\n"));
+ return new PortStatusListener_exec_i ();
+ }
+
+ // Operations from Components::SessionComponent.
+
+ void
+ Broker_exec_i::set_session_context (
+ ::Components::SessionContext_ptr ctx)
+ {
+ ::Quoter::CCM_Broker_Context_var lctx =
+ ::Quoter::CCM_Broker_Context::_narrow (ctx);
+
+ if ( ::CORBA::is_nil (lctx.in ()))
+ {
+ throw ::CORBA::INTERNAL ();
+ }
+
+ this->context_ = lctx;
+ }
+
+ void
+ Broker_exec_i::configuration_complete (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::configuration_complete\n"));
+ this->reader_ = this->context_->get_connection_info_out_data();
+ }
+
+ void
+ Broker_exec_i::start (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::start\n"));
+ // calculate the interval time
+ if (this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->schedule_timer (
+ this->ticker_,
+ 0,
+ ACE_Time_Value (0, 2000),
+ ACE_Time_Value (0, 2000)) == -1)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::start : error scheduling timer\n"));
+ }
+ }
+
+ void
+ Broker_exec_i::stop (void)
+ {
+ this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_);
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::stop\n"));
+ delete this->ticker_;
+ }
+
+ void
+ Broker_exec_i::ccm_activate (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::ccm_activate\n"));
+ ::CCM_DDS::DataListenerControl_var lc =
+ this->context_->get_connection_info_out_data_control ();
+
+ if (::CORBA::is_nil (lc.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "Error: Listener control receptacle is null!\n"));
+ throw CORBA::INTERNAL ();
+ }
+ //in case of testing Listener set lc-> enabled true
+ lc->mode ( ::CCM_DDS::ONE_BY_ONE);
+ //in case of testing Reader set lc-> enabled false, so the Listener doesn't consume all the messages
+ //lc->enabled (false);
+ this->start();
+ }
+
+ void
+ Broker_exec_i::ccm_passivate (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::ccm_passivate\n"));
+ this->stop ();
+ }
+
+ void
+ Broker_exec_i::ccm_remove (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, ">>> Broker_exec_i::ccm_remove\n"));
+ }
+
+ extern "C" BROKER_EXEC_Export ::Components::EnterpriseComponent_ptr
+ create_Quoter_Broker_Impl (void)
+ {
+ ::Components::EnterpriseComponent_ptr retval =
+ ::Components::EnterpriseComponent::_nil ();
+ ACE_DEBUG ((LM_DEBUG, "in create Broker\n"));
+ ACE_NEW_NORETURN (
+ retval,
+ Broker_exec_i);
+
+ return retval;
+ }
+}
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.h b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.h
new file mode 100644
index 00000000000..487d058c5cd
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Broker/Broker_exec.h
@@ -0,0 +1,134 @@
+// -*- C++ -*-
+// $Id$
+
+#ifndef CIAO_BROKER_EXEC_H_
+#define CIAO_BROKER_EXEC_H_
+
+#include /**/ "ace/pre.h"
+
+#include "BrokerEC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include /**/ "Broker_exec_export.h"
+#include "tao/LocalObject.h"
+#include "ace/Reactor.h"
+
+namespace CIAO_Quoter_Broker_Impl
+{
+
+ class Broker_exec_i;
+ /**
+ * @class reader activity generator
+ *
+ * @brief an active object used by StockBroker to perform a periodical read action
+ *
+ */
+ class read_action_Generator : public ACE_Event_Handler
+ {
+ public:
+ read_action_Generator (Broker_exec_i &callback);
+
+ ~read_action_Generator ();
+
+ /// Handle the timeout.
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg);
+
+ private:
+ /// Maintains a handle that actually process the event
+ Broker_exec_i &pulse_callback_;
+ };
+
+ class BROKER_EXEC_Export Stock_Info_Listener_exec_i
+ : public virtual ::CCM_DDS::Quoter::CCM_Listener,
+ public virtual ::CORBA::LocalObject
+ {
+ public:
+ Stock_Info_Listener_exec_i (void);
+ virtual ~Stock_Info_Listener_exec_i (void);
+
+ virtual void
+ on_one_data (
+ const ::Quoter::Stock_Info & an_instance,
+ const ::CCM_DDS::ReadInfo & info);
+ virtual void
+ on_many_data (
+ const ::Quoter::Stock_InfoSeq & an_instance,
+ const ::CCM_DDS::ReadInfoSeq & info);
+ };
+
+ class BROKER_EXEC_Export PortStatusListener_exec_i
+ : public virtual ::CCM_DDS::CCM_PortStatusListener,
+ public virtual ::CORBA::LocalObject
+ {
+ public:
+ PortStatusListener_exec_i (void);
+ virtual ~PortStatusListener_exec_i (void);
+
+ virtual void
+ on_requested_deadline_missed (
+ ::DDS::DataReader_ptr the_reader,
+ const ::DDS::RequestedDeadlineMissedStatus & status);
+
+ virtual void
+ on_sample_lost (
+ ::DDS::DataReader_ptr the_reader,
+ const ::DDS::SampleLostStatus & status);
+ };
+
+
+ class BROKER_EXEC_Export Broker_exec_i
+ : public virtual Broker_Exec,
+ public virtual ::CORBA::LocalObject
+ {
+ public:
+ Broker_exec_i (void);
+ virtual ~Broker_exec_i (void);
+
+ // Supported operations and attributes.
+
+ // Component attributes.
+
+ // Port operations.
+
+ virtual ::CCM_DDS::Quoter::CCM_Listener_ptr
+ get_info_out_data_listener (void);
+
+ virtual ::CCM_DDS::CCM_PortStatusListener_ptr
+ get_info_out_status (void);
+ void read_one (void);
+ void read_one_history (void);
+ void read_all(void);
+ void read_all_history(void);
+
+ // 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);
+ virtual void start (void);
+ virtual void stop (void);
+
+ private:
+ ::Quoter::CCM_Broker_Context_var context_;
+ read_action_Generator * ticker_;
+ ::CCM_DDS::Quoter::Reader_var reader_;
+ ::CCM_DDS::Quoter::Getter_var getter_;
+ };
+
+ extern "C" BROKER_EXEC_Export ::Components::EnterpriseComponent_ptr
+ create_Quoter_Broker_Impl (void);
+}
+
+#include /**/ "ace/post.h"
+
+#endif /* ifndef */
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.idl b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.idl
new file mode 100644
index 00000000000..be88f9381fe
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.idl
@@ -0,0 +1,29 @@
+// $Id$
+
+/**
+ * @file Quoter_Connector.idl
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ */
+
+#ifndef QUOTER_CONNECTOR_IDL_
+#define QUOTER_CONNECTOR_IDL_
+
+#include <Components.idl>
+#include "Base/Quoter_Base.idl"
+#include "connectors/dds4ccm/idl/ccm_dds.idl"
+
+#pragma ciao lem "Connector/Quoter_ConnectorE.idl"
+
+module CCM_DDS
+{
+ module ::CCM_DDS::Typed < ::Quoter::Stock_Info, ::Quoter::Stock_InfoSeq> Quoter;
+};
+
+module Quoter
+{
+ connector Quoter_Connector : ::CCM_DDS::Quoter::DDS_Event
+ {
+ };
+};
+
+#endif /* QUOTER_CONNECTOR_IDL_ */
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.mpc b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.mpc
new file mode 100644
index 00000000000..d6cfea2cde1
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Connector/Quoter_Connector.mpc
@@ -0,0 +1,145 @@
+// $Id$
+// This file is generated with "generate_component_mpc.pl -p DDS_Quoter_Base -l .. -o ../lib -u DDS Quoter_Connector"
+
+project(DDS_Quoter_Connector_idl_gen) : connectoridldefaults, dds4ccm {
+ after += DDS4CCM_idl_gen
+ custom_only = 1
+ idlflags += -Wb,stub_export_macro=QUOTER_CONNECTOR_STUB_Export \
+ -Wb,stub_export_include=Quoter_Connector_stub_export.h \
+ -Wb,skel_export_macro=QUOTER_CONNECTOR_SVNT_Export \
+ -Wb,skel_export_include=Quoter_Connector_svnt_export.h \
+ -Wb,svnt_export_macro=QUOTER_CONNECTOR_SVNT_Export \
+ -Wb,svnt_export_include=Quoter_Connector_svnt_export.h \
+ -Wb,conn_export_macro=QUOTER_CONNECTOR_CONN_Export \
+ -Wb,conn_export_include=Quoter_Connector_conn_export.h \
+ -I ..
+
+ IDL_Files {
+ Quoter_Connector.idl
+ }
+}
+
+project(DDS_Quoter_Connector_lem_gen) : ciaoidldefaults, dds4ccm {
+ custom_only = 1
+ after += DDS_Quoter_Connector_idl_gen
+ idlflags += -Wb,stub_export_macro=QUOTER_CONNECTOR_LEM_STUB_Export \
+ -Wb,stub_export_include=Quoter_Connector_lem_stub_export.h \
+ -SS -Gxhst \
+ -I ..
+
+ IDL_Files {
+ Quoter_ConnectorE.idl
+ }
+}
+
+project(DDS_Quoter_Connector_lem_stub) : ccm_svnt, dds4ccm_base {
+ after += DDS_Quoter_Connector_lem_gen DDS_Quoter_Connector_stub DDS_Quoter_Base_stub DDS4CCM_lem_stub
+ libs += DDS_Quoter_Base_stub DDS_Quoter_Connector_stub DDS4CCM_lem_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ sharedname = DDS_Quoter_Connector_lem_stub
+ dynamicflags = QUOTER_CONNECTOR_LEM_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Quoter_ConnectorEC.cpp
+ }
+
+ Header_Files {
+ Quoter_ConnectorEC.h
+ Quoter_Connector_lem_stub_export.h
+ }
+
+ Inline_Files {
+ Quoter_ConnectorEC.inl
+ }
+}
+
+project(DDS_Quoter_Connector_stub) : ccm_stub, dds4ccm_base {
+ after += DDS_Quoter_Connector_idl_gen DDS_Quoter_Base_stub
+ libs += DDS_Quoter_Base_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ sharedname = DDS_Quoter_Connector_stub
+ dynamicflags = QUOTER_CONNECTOR_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Quoter_ConnectorC.cpp
+ }
+
+ Header_Files {
+ Quoter_ConnectorC.h
+ Quoter_Connector_stub_export.h
+ }
+
+ Inline_Files {
+ Quoter_ConnectorC.inl
+ }
+}
+
+project(DDS_Quoter_Connector_exec) : ciao_executor, dds4ccm_impl {
+ after += DDS_Quoter_Connector_lem_stub DDS_Quoter_Connector_stub DDS4CCM_lem_stub
+ sharedname = DDS_Quoter_Connector_exec
+ libs += DDS_Quoter_Connector_stub DDS_Quoter_Connector_lem_stub DDS_Quoter_Base_stub DDS4CCM_lem_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ dynamicflags = QUOTER_CONNECTOR_CONN_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Quoter_Connector_conn.cpp
+ }
+
+ Header_Files {
+ Quoter_Connector_conn.h
+ Quoter_Connector_conn_export.h
+ }
+
+ Inline_Files {
+ }
+}
+
+
+project(DDS_Quoter_Connector_svnt) : ciao_servant, dds4ccm_impl {
+ after += DDS_Quoter_Connector_lem_stub DDS_Quoter_Connector_exec DDS_Quoter_Connector_stub DDS4CCM_lem_stub
+ sharedname = DDS_Quoter_Connector_svnt
+ libs += DDS_Quoter_Connector_stub \
+ DDS_Quoter_Connector_lem_stub \
+ DDS_Quoter_Base_stub \
+ DDS_Quoter_Connector_exec \
+ DDS4CCM_lem_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ dynamicflags = QUOTER_CONNECTOR_SVNT_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Quoter_ConnectorS.cpp
+ Quoter_Connector_svnt.cpp
+ }
+
+ Header_Files {
+ Quoter_ConnectorS.h
+ Quoter_Connector_svnt.h
+ Quoter_Connector_svnt_export.h
+ }
+
+ Inline_Files {
+ Quoter_ConnectorS.inl
+ }
+}
+
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.idl b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.idl
new file mode 100644
index 00000000000..57dd4bd9e8e
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.idl
@@ -0,0 +1,34 @@
+// $Id$
+
+/**
+ * @file Distributor.idl
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * by-hand idl3 translation of distributor components.
+ */
+
+#ifndef DDS_DISTRIBUTOR_IDL
+#define DDS_DISTRIBUTOR_IDL
+
+#include "Connector/Quoter_Connector.idl"
+
+module Quoter
+{
+ interface Trigger
+ {
+ void add_stock (in string stock);
+ void del_stock (in string stock);
+ void start ();
+ void stop ();
+ };
+
+ component Distributor supports Trigger
+ {
+ port CCM_DDS::Quoter::DDS_Write info_in;
+ provides CCM_DDS::ConnectorStatusListener info_out_connector_status;
+ attribute unsigned long rate;
+ };
+};
+
+#endif
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.mpc b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.mpc
new file mode 100644
index 00000000000..6fcead8c9f9
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor.mpc
@@ -0,0 +1,140 @@
+// $Id$
+// This file is generated with "generate_component_mpc.pl -p DDS_Quoter_Base -l ../lib -o ../lib -c controller -u DDS Distributor"
+
+project(DDS_Distributor_idl_gen) : componentidldefaults, dds4ccm {
+ after += DDS_Quoter_Connector_idl_gen
+ custom_only = 1
+ idlflags += -Wb,stub_export_macro=DISTRIBUTOR_STUB_Export \
+ -Wb,stub_export_include=Distributor_stub_export.h \
+ -Wb,skel_export_macro=DISTRIBUTOR_SVNT_Export \
+ -Wb,skel_export_include=Distributor_svnt_export.h \
+ -Wb,svnt_export_macro=DISTRIBUTOR_SVNT_Export \
+ -Wb,svnt_export_include=Distributor_svnt_export.h \
+ -Wb,exec_export_macro=DISTRIBUTOR_EXEC_Export \
+ -Wb,exec_export_include=Distributor_exec_export.h \
+ -I ..
+
+ IDL_Files {
+ Distributor.idl
+ }
+}
+
+project(DDS_Distributor_lem_gen) : ciaoidldefaults, dds4ccm {
+ after += DDS_Distributor_idl_gen
+ custom_only = 1
+ idlflags += -Wb,stub_export_macro=DISTRIBUTOR_LEM_STUB_Export \
+ -Wb,stub_export_include=Distributor_lem_stub_export.h \
+ -SS -Gxhst -I $CIAO_ROOT/connectors -I ..
+
+ IDL_Files {
+ DistributorE.idl
+ }
+}
+
+project(DDS_Distributor_lem_stub) : ccm_svnt, dds4ccm_base {
+ after += DDS_Distributor_lem_gen DDS_Distributor_stub DDS_Quoter_Base_stub
+ libs += DDS_Quoter_Base_stub Distributor_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ sharedname = Distributor_lem_stub
+ dynamicflags = DISTRIBUTOR_LEM_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ DistributorEC.cpp
+ }
+
+ Header_Files {
+ DistributorEC.h
+ Distributor_lem_stub_export.h
+ }
+
+ Inline_Files {
+ DistributorEC.inl
+ }
+}
+
+project(DDS_Distributor_stub) : ccm_stub, dds4ccm_base {
+ after += DDS_Distributor_idl_gen DDS_Quoter_Base_stub DDS_Quoter_Connector_stub
+ libs += DDS_Quoter_Base_stub DDS_Quoter_Connector_stub
+ includes += ..
+ libpaths += ../lib
+ libout = ../lib
+ sharedname = Distributor_stub
+ dynamicflags = DISTRIBUTOR_STUB_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ DistributorC.cpp
+ }
+
+ Header_Files {
+ DistributorC.h
+ Distributor_stub_export.h
+ }
+
+ Inline_Files {
+ DistributorC.inl
+ }
+}
+
+project(DDS_Distributor_exec) : ciao_executor, dds4ccm_base {
+ after += DDS_Distributor_lem_stub DDS_Distributor_stub DDS_Quoter_Connector_lem_stub DDS_Quoter_Connector_stub DDS4CCM_lem_stub
+ sharedname = Distributor_exec
+ libs += Distributor_stub Distributor_lem_stub DDS_Quoter_Base_stub DDS_Quoter_Connector_lem_stub DDS_Quoter_Connector_stub DDS4CCM_lem_stub
+ libpaths += ../lib
+ includes += ..
+ libout = ../lib
+ dynamicflags = DISTRIBUTOR_EXEC_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ Distributor_exec.cpp
+ }
+
+ Header_Files {
+ Distributor_exec.h
+ Distributor_exec_export.h
+ }
+
+ Inline_Files {
+ }
+}
+
+
+project(DDS_Distributor_svnt) : ciao_servant, dds4ccm_base {
+ after += DDS_Quoter_Base_stub DDS_Distributor_lem_stub DDS4CCM_lem_stub DDS4CCM_skel DDS_Quoter_Connector_stub DDS_Quoter_Connector_svnt DDS_Quoter_Connector_lem_stub
+ sharedname = Distributor_svnt
+ libs += Distributor_stub Distributor_lem_stub \
+ DDS_Quoter_Base_stub DDS4CCM_lem_stub DDS4CCM_skel DDS_Quoter_Connector_stub DDS_Quoter_Connector_svnt DDS_Quoter_Connector_lem_stub
+ libpaths += ../lib
+ libout = ../lib
+ includes += ..
+ dynamicflags = DISTRIBUTOR_SVNT_BUILD_DLL
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ DistributorS.cpp
+ Distributor_svnt.cpp
+ }
+
+ Header_Files {
+ DistributorS.h
+ Distributor_svnt.h
+ Distributor_svnt_export.h
+ }
+
+ Inline_Files {
+ DistributorS.inl
+ }
+}
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.cpp b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.cpp
new file mode 100644
index 00000000000..5fd9c63fed7
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.cpp
@@ -0,0 +1,306 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "Distributor_exec.h"
+#include "ace/Reactor.h"
+#include "ace/Guard_T.h"
+#include "ace/CORBA_macros.h"
+#include "ace/OS_NS_time.h"
+#include "tao/ORB_Core.h"
+#include <iostream>
+
+namespace CIAO_Quoter_Distributor_Impl
+{
+ //============================================================
+ // Component Executor Implementation Class: Distributor_exec_i
+ //============================================================
+
+ pulse_Generator::pulse_Generator (Distributor_exec_i &callback)
+ : pulse_callback_ (callback)
+ {
+ }
+
+ pulse_Generator::~pulse_Generator ()
+ {
+ }
+
+ int
+ pulse_Generator::handle_timeout (const ACE_Time_Value &,
+ const void *)
+ {
+ // Notify the subscribers
+ try
+ {
+ this->pulse_callback_.tick ();
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, "Distributor pulse_Generator::handle_timeout: Caught exception\n"));
+ }
+
+ return 0;
+ }
+
+
+ ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (void)
+ {
+ }
+
+ ConnectorStatusListener_exec_i::~ConnectorStatusListener_exec_i (void)
+ {
+
+ }
+
+ // Operations from ::CCM_DDS::ConnectorStatusListener
+ void ConnectorStatusListener_exec_i::on_inconsistent_topic(
+ ::DDS::Topic_ptr /*the_topic*/,
+ const DDS::InconsistentTopicStatus & /*status*/)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_inconsistent_topic\n"));
+ }
+
+ void ConnectorStatusListener_exec_i::on_requested_incompatible_qos(
+ ::DDS::DataReader_ptr /*the_reader*/,
+ const DDS::RequestedIncompatibleQosStatus & /*status*/)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_requested_incompatible_qos\n"));
+ }
+
+ void ConnectorStatusListener_exec_i::on_sample_rejected(
+ ::DDS::DataReader_ptr /*the_reader*/,
+ const DDS::SampleRejectedStatus & /*status*/)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_sample_rejected\n"));
+ }
+
+ void ConnectorStatusListener_exec_i::on_offered_deadline_missed(
+ ::DDS::DataWriter_ptr /*the_writer*/,
+ const DDS::OfferedDeadlineMissedStatus & /*status*/)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_offered_deadline_missed\n"));
+ }
+
+ void ConnectorStatusListener_exec_i::on_offered_incompatible_qos(
+ ::DDS::DataWriter_ptr /*the_writer*/,
+ const DDS::OfferedIncompatibleQosStatus & /*status*/)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_offered_incompatible_qos\n"));
+ }
+
+ void ConnectorStatusListener_exec_i::on_unexpected_status(
+ ::DDS::Entity_ptr /*the_entity*/,
+ ::DDS::StatusKind status_kind)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ConnectorStatusListener_exec_i::on_unexpected_status: %d\n"),
+ status_kind));
+ }
+
+ void ConnectorStatusListener_exec_i::on_publication_matched ( ::DDS::DataWriter_ptr ,
+ const DDS::PublicationMatchedStatus &)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ConnectorStatusListener_exec_i::on_publication_matched\n"));
+ }
+
+ Distributor_exec_i::Distributor_exec_i (void)
+ : rate_ (1)
+ {
+ ACE_OS::srand (static_cast <u_int> (ACE_OS::time ()));
+ this->ticker_ = new pulse_Generator (*this);
+ }
+
+ Distributor_exec_i::~Distributor_exec_i (void)
+ {
+ }
+
+ // Supported operations and attributes.
+
+ void
+ Distributor_exec_i::tick (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Ticking\n"));
+
+ for (Stock_Table::iterator i = this->stocks_.begin ();
+ i != this->stocks_.end ();
+ ++i)
+ {
+ if (ACE_OS::rand () % 2)
+ {
+ int delta = (ACE_OS::rand () % 10) - 2;
+
+ i->second->current += delta;
+
+ if (i->second->current > i->second->high)
+ i->second->high = i->second->current;
+
+ if (i->second->current < i->second->low)
+ i->second->low = i->second->current;
+
+ if (! ::CORBA::is_nil (this->writer_)) {
+ ACE_DEBUG ((LM_DEBUG, "WRITE AND CREATE stock_info for <%C> %u:%u:%u\n",
+ i->first.c_str (),
+ i->second->low,
+ i->second->current,
+ i->second->high));
+ try
+ {
+ this->writer_->write_one (i->second, ::DDS::HANDLE_NIL);
+ }
+ catch (const CCM_DDS::InternalError& )
+ {
+ ACE_ERROR ((LM_ERROR, "Internal Error while writing Stock_info for <%C>.\n",
+ i->first.c_str ()));
+ }
+ }
+ else
+ ACE_ERROR ((LM_ERROR, "Writer reference is nil!\n"));
+ }
+ }
+ }
+
+ void
+ Distributor_exec_i::add_stock (
+ const char * stock)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Distributor_exec_i::add_stock - Adding stock: %C\n", stock));
+
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
+ this->mutex_, CORBA::INTERNAL ());
+
+ Quoter::Stock_Info *new_stock = new Quoter::Stock_Info;
+
+ new_stock->low = 50;
+ new_stock->high = 50;
+ new_stock->current = 50;
+ new_stock->symbol = stock;
+
+ this->stocks_[stock] = new_stock;
+ }
+
+ void
+ Distributor_exec_i::del_stock (const char * stock)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Distributor_exec_i::del_stock - Removing stock: %C\n", stock));
+
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
+ this->mutex_, CORBA::INTERNAL ());
+
+ Stock_Table::iterator pos = this->stocks_.find (stock);
+
+ if (pos != this->stocks_.end ())
+ {
+ this->stocks_.erase (pos);
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "Distributor_exec_i::del_stock - Stock not present: %C\n", stock));
+ }
+ }
+
+ void
+ Distributor_exec_i::start (void)
+ {
+ // calculate the interval time
+ long usec = 1000000 / this->rate_;
+ if (this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->schedule_timer (
+ this->ticker_,
+ 0,
+ ACE_Time_Value (0, usec),
+ ACE_Time_Value (0, usec)) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "Distributor_exec_i::start : error scheduling timer\n"));
+ }
+ }
+
+ void
+ Distributor_exec_i::stop (void)
+ {
+ this->context_->get_CCM_object()->_get_orb ()->orb_core ()->reactor ()->cancel_timer (this->ticker_);
+ ACE_DEBUG ((LM_DEBUG, "Distributor_exec_i::stop\n"));
+ delete this->ticker_;
+ }
+
+ // Component attributes.
+
+ ::CORBA::ULong
+ Distributor_exec_i::rate (void)
+ {
+ return this->rate_;
+ }
+
+ void
+ Distributor_exec_i::rate (
+ ::CORBA::ULong rate )
+ {
+ this->rate_ = rate;
+ }
+
+ // Port operations.
+
+ // Operations from Components::SessionComponent.
+ ::CCM_DDS::CCM_ConnectorStatusListener_ptr
+ Distributor_exec_i::get_info_out_connector_status (void)
+ {
+ ACE_DEBUG ((LM_DEBUG, "*************** DIST out connector status************************\n"));
+ return new ConnectorStatusListener_exec_i ();
+ }
+
+ void
+ Distributor_exec_i::set_session_context (
+ ::Components::SessionContext_ptr ctx)
+ {
+ ::Quoter::CCM_Distributor_Context_var lctx =
+ ::Quoter::CCM_Distributor_Context::_narrow (ctx);
+
+ if ( ::CORBA::is_nil (lctx.in ()))
+ {
+ throw ::CORBA::INTERNAL ();
+ }
+
+ this->context_ = lctx;
+ }
+
+ void
+ Distributor_exec_i::configuration_complete (void)
+ {
+ this->writer_ = this->context_->get_connection_info_in_data ();
+ }
+
+ void
+ Distributor_exec_i::ccm_activate (void)
+ {
+ this->start ();
+ this->add_stock ("MSFT");
+ this->add_stock ("IBM");
+ this->add_stock ("HP");
+ this->add_stock ("DELL");
+ this->add_stock ("ACER");
+ this->add_stock ("ASUS");
+ }
+
+ void
+ Distributor_exec_i::ccm_passivate (void)
+ {
+ this->stop ();
+ }
+
+ void
+ Distributor_exec_i::ccm_remove (void)
+ {
+ }
+
+ extern "C" DISTRIBUTOR_EXEC_Export ::Components::EnterpriseComponent_ptr
+ create_Quoter_Distributor_Impl (void)
+ {
+ ::Components::EnterpriseComponent_ptr retval =
+ ::Components::EnterpriseComponent::_nil ();
+
+ ACE_NEW_NORETURN (
+ retval,
+ Distributor_exec_i);
+
+ return retval;
+ }
+}
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.h b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.h
new file mode 100644
index 00000000000..1ab67b20547
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/Distributor/Distributor_exec.h
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#ifndef CIAO_DISTRIBUTOR_EXEC_H_
+#define CIAO_DISTRIBUTOR_EXEC_H_
+
+#include /**/ "ace/pre.h"
+
+#include "DistributorEC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include /**/ "Distributor_exec_export.h"
+#include "tao/LocalObject.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Reactor.h"
+
+#include <map>
+
+namespace CIAO_Quoter_Distributor_Impl
+{
+ class Distributor_exec_i;
+
+ /**
+ * @class pulse generator
+ *
+ * @brief an active object used by StockDistributor to perform periodical pulse generation
+ *
+ */
+ class pulse_Generator : public ACE_Event_Handler
+ {
+ public:
+ pulse_Generator (Distributor_exec_i &callback);
+
+ ~pulse_Generator ();
+
+ /// Handle the timeout.
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg);
+ private:
+ /// Maintains a handle that actually process the event
+ Distributor_exec_i &pulse_callback_;
+
+ };
+
+class DISTRIBUTOR_EXEC_Export ConnectorStatusListener_exec_i
+ : public virtual ::CCM_DDS::CCM_ConnectorStatusListener,
+ public virtual ::CORBA::LocalObject
+ {
+ public:
+ ConnectorStatusListener_exec_i (void);
+ virtual ~ConnectorStatusListener_exec_i (void);
+
+ virtual
+ void on_inconsistent_topic( ::DDS::Topic_ptr the_topic,
+ const DDS::InconsistentTopicStatus & status);
+ virtual
+ void on_requested_incompatible_qos( ::DDS::DataReader_ptr the_reader,
+ const DDS::RequestedIncompatibleQosStatus & status);
+ virtual
+ void on_sample_rejected( ::DDS::DataReader_ptr the_reader,
+ const DDS::SampleRejectedStatus & status);
+ virtual
+ void on_offered_deadline_missed( ::DDS::DataWriter_ptr the_writer,
+ const DDS::OfferedDeadlineMissedStatus & status);
+ virtual
+ void on_offered_incompatible_qos( ::DDS::DataWriter_ptr the_writer,
+ const DDS::OfferedIncompatibleQosStatus & status);
+ virtual
+ void on_unexpected_status( ::DDS::Entity_ptr the_entity,
+ ::DDS::StatusKind status_kind);
+ virtual
+ void on_publication_matched ( ::DDS::DataWriter_ptr the_writer,
+ const DDS::PublicationMatchedStatus & status);
+
+ };
+ class DISTRIBUTOR_EXEC_Export Distributor_exec_i
+ : public virtual Distributor_Exec,
+ public virtual ::CORBA::LocalObject
+ {
+ public:
+ Distributor_exec_i (void);
+ virtual ~Distributor_exec_i (void);
+
+ void tick (void);
+
+ // Supported operations and attributes.
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void
+ add_stock (
+ const char * stock);
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void
+ del_stock (
+ const char * stock);
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void
+ start (void);
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void
+ stop (void);
+
+ // Component attributes.
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual ::CORBA::ULong
+ rate (void);
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void
+ rate (
+ ::CORBA::ULong rate);
+
+ // Port operations.
+ virtual ::CCM_DDS::CCM_ConnectorStatusListener_ptr
+ get_info_out_connector_status (void);
+
+ // 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:
+ pulse_Generator * ticker_;
+ ::Quoter::CCM_Distributor_Context_var context_;
+ TAO_SYNCH_MUTEX mutex_;
+ typedef std::map<ACE_CString, Quoter::Stock_Info_var> Stock_Table;
+ Stock_Table stocks_;
+ CORBA::ULong rate_;
+ CCM_DDS::Quoter::Writer_var writer_;
+ };
+
+ extern "C" DISTRIBUTOR_EXEC_Export ::Components::EnterpriseComponent_ptr
+ create_Quoter_Distributor_Impl (void);
+}
+
+#include /**/ "ace/post.h"
+
+#endif /* ifndef */
+
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/Plan.cdp b/modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/Plan.cdp
new file mode 100644
index 00000000000..942fd32a0ca
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/Plan.cdp
@@ -0,0 +1,425 @@
+<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>Quoter_Depl_1</label>
+ <UUID>Quoter_Depl_1</UUID>
+
+ <implementation xmi:id="BrokerComponentImplementation">
+ <name>BrokerComponentImplementation</name>
+ <source/>
+ <artifact xmi:idref="Broker_ExecArtifact" />
+ <artifact xmi:idref="Broker_SvntArtifact" />
+ <execParameter>
+ <!-- entrypoint as exec parameter (see 10.6.1) -->
+ <name>component factory</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>create_Quoter_Broker_Impl</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>create_Quoter_Broker_Servant</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Broker_svnt</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Broker_exec</string>
+ </value>
+ </value>
+ </execParameter>
+ </implementation>
+
+ <implementation xmi:id="Quoter_ConnectorComponentImplementation">
+ <name>Quoter_ConnectorComponentImplementation</name>
+ <source/>
+ <artifact xmi:idref="Quoter_Connector_ExecArtifact" />
+ <artifact xmi:idref="Quoter_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_Quoter_Quoter_Connector_Impl</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>create_Quoter_Quoter_Connector_Servant</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Quoter_Connector_svnt</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Quoter_Connector_exec</string>
+ </value>
+ </value>
+ </execParameter>
+ </implementation>
+ <implementation xmi:id="DistributorComponentImplementation">
+ <name>DistributorComponentImplementation</name>
+ <source/>
+ <artifact xmi:idref="Distributor_ExecArtifact" />
+ <artifact xmi:idref="Distributor_SvntArtifact" />
+ <execParameter>
+ <!-- entrypoint as exec parameter (see 10.6.1) -->
+ <name>component factory</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>create_Quoter_Distributor_Impl</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>create_Quoter_Distributor_Servant</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Distributor_svnt</string>
+ </value>
+ </value>
+ </execParameter>
+ <execParameter>
+ <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Distributor_exec</string>
+ </value>
+ </value>
+ </execParameter>
+ </implementation>
+ <instance xmi:id="BrokerComponentInstance">
+ <name>BrokerComponent</name>
+ <node>BrokerNode</node>
+ <!-- hostname -->
+ <source/>
+ <implementation xmi:idref="BrokerComponentImplementation" />
+ </instance>
+ <instance xmi:id="Quoter_ConnectorComponentInstance">
+ <name>Quoter_ConnectorComponent</name>
+ <node>DistributorNode</node>
+ <!-- hostname -->
+ <source/>
+ <implementation xmi:idref="Quoter_ConnectorComponentImplementation" />
+ <configProperty>
+ <name>topic_name</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Quoter</string>
+ </value>
+ </value>
+ </configProperty>
+ </instance>
+ <instance xmi:id="Quoter_ConnectorComponentInstance2">
+ <name>Quoter_ConnectorComponent2</name>
+ <node>BrokerNode</node>
+ <!-- hostname -->
+ <source/>
+ <implementation xmi:idref="Quoter_ConnectorComponentImplementation" />
+ <configProperty>
+ <name>topic_name</name>
+ <value>
+ <type>
+ <kind>tk_string</kind>
+ </type>
+ <value>
+ <string>Quoter</string>
+ </value>
+ </value>
+ </configProperty>
+ </instance>
+ <instance xmi:id="DistributorComponentInstance">
+ <name>DistributorComponent</name>
+ <node>DistributorNode</node>
+ <!-- hostname -->
+ <source/>
+ <implementation xmi:idref="DistributorComponentImplementation" />
+ </instance>
+
+
+ <connection>
+ <name>info_out_data</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_data</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="BrokerComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>push_consumer_data</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance2" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>_listenercontrol</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_data_control</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="BrokerComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>push_consumer_data_control</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance2" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>_listener</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_data_listener</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="BrokerComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>push_consumer_data_listener</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance2" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>_datareader</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_dds_entity</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="BrokerComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>push_consumer_dds_entity</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance2" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>_portstatuslistener</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_status</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="BrokerComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>push_consumer_status</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance2" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>_connectorstatuslistener_distributor</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_out_connector_status</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="DistributorComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>error_listener</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance" />
+ </internalEndpoint>
+ </connection>
+
+ <connection>
+ <name>writer_connection</name>
+ <deployRequirement>
+ <name>edu.dre.vanderbilt.DAnCE.ConnectionType</name>
+ <resourceType>Local_Interface</resourceType>
+ </deployRequirement>
+ <internalEndpoint>
+ <portName>info_in_data</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="DistributorComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>supplier_data</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance" />
+ </internalEndpoint>
+ </connection>
+
+ <!--connection>
+ <name>updater_connection</name>
+ <internalEndpoint>
+ <portName>info_update_data</portName>
+ <provider>false</provider>
+ <kind>SimplexReceptacle</kind>
+ <instance xmi:idref="DistributorComponentInstance" />
+ </internalEndpoint>
+ <internalEndpoint>
+ <portName>info_update_data</portName>
+ <provider>true</provider>
+ <kind>Facet</kind>
+ <instance xmi:idref="Quoter_ConnectorComponentInstance" />
+ </internalEndpoint>
+ </connection-->
+
+ <artifact xmi:id="Distributor_ExecArtifact">
+ <name>Distributor_exec</name>
+ <source/>
+ <node/>
+ <location>Distributor_exec</location>
+ </artifact>
+ <artifact xmi:id="Distributor_SvntArtifact">
+ <name>Distributor_svnt</name>
+ <source/>
+ <node/>
+ <location>Distributor_svnt</location>
+ </artifact>
+ <artifact xmi:id="Distributor_StubArtifact">
+ <name>Distributor_stub</name>
+ <source/>
+ <node/>
+ <location>Distributor_stub</location>
+ </artifact>
+ <artifact xmi:id="Quoter_Connector_ExecArtifact">
+ <name>Quoter_Connector_exec</name>
+ <source/>
+ <node/>
+ <location>DDS_Quoter_Connector_exec</location>
+ </artifact>
+ <artifact xmi:id="Quoter_Connector_SvntArtifact">
+ <name>Quoter_Connector_svnt</name>
+ <source/>
+ <node/>
+ <location>DDS_Quoter_Connector_svnt</location>
+ </artifact>
+ <artifact xmi:id="Quoter_Connector_StubArtifact">
+ <name>Quoter_Connector_stub</name>
+ <source/>
+ <node/>
+ <location>DDS_Quoter_Connector_stub</location>
+ </artifact>
+ <artifact xmi:id="Broker_ExecArtifact">
+ <name>Broker_exec</name>
+ <source/>
+ <node/>
+ <location>Broker_exec</location>
+ </artifact>
+ <artifact xmi:id="Broker_SvntArtifact">
+ <name>Broker_svnt</name>
+ <source/>
+ <node/>
+ <location>Broker_svnt</location>
+ </artifact>
+ <artifact xmi:id="Broker_StubArtifact">
+ <name>Broker_stub</name>
+ <source/>
+ <node/>
+ <location>Broker_stub</location>
+ </artifact>
+</Deployment:DeploymentPlan>
diff --git a/modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/run_test.pl b/modules/CIAO/connectors/dds4ccm/examples/Quoter/descriptors/run_test.pl
new file mode 100755
index 00000000000..44cd3fa00c0
--- /dev/null
+++ b/modules/CIAO/connectors/dds4ccm/examples/Quoter/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 = ( "DistributorNode", "BrokerNode" );
+
+# 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 -q\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;