summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-03-05 18:03:40 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-03-05 18:03:40 +0000
commit3f4839e0d136b5ce59886eafb84a8cc662f7530f (patch)
tree5c47e1ec8253420ab553ebabc13d2fb9dc5a1e2b
parent4a5e90e672eeaddd81f8f39b6c2c4299bf091295 (diff)
downloadATCD-3f4839e0d136b5ce59886eafb84a8cc662f7530f.tar.gz
ChangeLogTag: Thu Mar 5 17:21:14 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog21
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/AppOptions.cpp7
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/AppOptions.h7
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp13
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h1
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/LWFT.mpc2
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp2
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp207
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h21
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp4
-rw-r--r--TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h10
11 files changed, 168 insertions, 127 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 61090d4c4bd..d33aefb8c8e 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,24 @@
+Thu Mar 5 17:21:14 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h:
+ * orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp:
+ * orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp:
+ * orbsvcs/orbsvcs/LWFT/LWFT.mpc:
+ * orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h:
+ * orbsvcs/orbsvcs/LWFT/AppOptions.cpp:
+ * orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h:
+ * orbsvcs/orbsvcs/LWFT/AppOptions.h:
+ * orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp:
+ * orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp:
+
+ - Made StateSyncAgentTask into an ACE singleton, which
+ now creates the StateSynchronizationAgent servant
+ internally instead of getting it passed in.
+
+ - Moved AppOptions to the LWFT_Common library to avoid
+ a circular dependence between LWFT_Server and
+ LWFT_StateSyncAgent.
+
Thu Mar 5 15:02:30 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
* orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h:
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.cpp b/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.cpp
index 1ebc601afad..c10a15d6e67 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.cpp
+++ b/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.cpp
@@ -48,7 +48,6 @@ AppOptions::instance (void)
AppOptions::~AppOptions (void)
{
- monitor_->stop ();
}
bool
@@ -206,12 +205,6 @@ AppOptions::process_id (const std::string & id)
}
void
-AppOptions::monitor (AppSideMonitor_Thread *mon)
-{
- monitor_.reset (mon);
-}
-
-void
AppOptions::orb (CORBA::ORB_ptr the_orb)
{
orb_ = the_orb;
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.h b/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.h
index 4a9ac958165..361b4f87a7e 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.h
+++ b/TAO/orbsvcs/orbsvcs/LWFT/AppOptions.h
@@ -18,8 +18,7 @@
#include "tao/ORB.h"
-#include "AppSideMonitor_Thread.h"
-#include "lwft_server_export.h"
+#include "lwft_common_export.h"
/**
* @class AppOptions
@@ -27,7 +26,7 @@
* @brief Declares AppOptions singleton to hold the command line options.
*/
-class LWFT_Server_Export AppOptions
+class LWFT_Common_Export AppOptions
/// TITLE
/// Singleton class for the program options.
{
@@ -62,7 +61,6 @@ public:
long debug_level (void) const;
void process_id (const std::string & id);
- void monitor (AppSideMonitor_Thread *mon);
// Neither storage nor access creates a duplicate.
void orb (CORBA::ORB_ptr the_orb);
@@ -84,7 +82,6 @@ protected:
double load_;
bool use_dds_;
long debug_level_;
- std::auto_ptr <AppSideMonitor_Thread> monitor_;
CORBA::ORB_ptr orb_;
/// Singleton-related stuff.
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp b/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp
index 7379e4b920a..01342589ab5 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp
+++ b/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.cpp
@@ -17,7 +17,7 @@
#include "AppSideMonitor_Thread.h"
#include "AppOptions.h"
-AppSideMonitor_Thread*
+AppSideMonitor_Thread *
AppSideMonitor_Thread::instance (void)
{
return
@@ -32,6 +32,12 @@ AppSideMonitor_Thread::AppSideMonitor_Thread (void)
{
}
+AppSideMonitor_Thread::~AppSideMonitor_Thread (void)
+{
+ this->stop ();
+ this->wait ();
+}
+
void
AppSideMonitor_Thread::stop (void)
{
@@ -48,8 +54,6 @@ AppSideMonitor_Thread::svc (void)
{
Barrier_Guard barrier_guard (sync_);
- HostMonitor_var hmvar;
-
try
{
try
@@ -182,9 +186,6 @@ AppSideMonitor_Thread::activate (long /* flags */,
AppOptions *app_opts = AppOptions::instance ();
- // Keep a reference to the monitor singleton.
- app_opts->monitor (this);
-
try
{
CORBA::Boolean good_register =
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h b/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h
index 20efdc2519c..f31e53f313f 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h
+++ b/TAO/orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h
@@ -57,6 +57,7 @@ public:
private:
// Prevent instance creation outside of ACE_Singleton.
AppSideMonitor_Thread (void);
+ ~AppSideMonitor_Thread (void);
private:
u_short port_;
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/LWFT.mpc b/TAO/orbsvcs/orbsvcs/LWFT/LWFT.mpc
index fefa7919a30..8d4cb2d3768 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/LWFT.mpc
+++ b/TAO/orbsvcs/orbsvcs/LWFT/LWFT.mpc
@@ -12,6 +12,7 @@ project(*Common) : pi_server, interceptors, iorinterceptor, orbsvcs_output {
}
Source_Files {
+ AppOptions.cpp
Barrier_Guard.cpp
LWFTDataStructuresC.cpp
LWFTDataStructuresS.cpp
@@ -87,7 +88,6 @@ project(*Server) : iorinterceptor, orbsvcs_output {
}
Source_Files {
- AppOptions.cpp
AppSideMonitor_Thread.cpp
AppSideMonitor_Handler.cpp
HostMonitorC.cpp
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp b/TAO/orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp
index 1dc845e8fd1..175ecae0687 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/LWFT/ReplicationManager.cpp
@@ -9,6 +9,8 @@
#include "ace/OS_NS_unistd.h"
+#include "AppSideMonitor_Thread.h"
+
#include "ForwardingAgentC.h"
#include "AppInfoC.h"
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp b/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp
index f24e9900f16..10045e319d3 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp
+++ b/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.cpp
@@ -1,89 +1,118 @@
-// -*- C++ -*-
-// $Id$
-
-#include "tao/PortableServer/POAC.h"
-
-#include "Barrier_Guard.h"
-
-#include "StateSyncAgentTask.h"
-#include "StateSynchronizationAgent_i.h"
-
-StateSyncAgentTask::StateSyncAgentTask (
- CORBA::ORB_ptr orb,
- StateSynchronizationAgent_i * agent)
- : orb_ (CORBA::ORB::_duplicate (orb)),
- agent_ (agent),
- sync_ (2),
- agent_ref_ (StateSynchronizationAgent::_nil ())
-{
-}
-
-int
-StateSyncAgentTask::svc (void)
-{
- try
- {
- {
- Barrier_Guard barrier_guard (sync_);
-
- CORBA::Object_var object =
- this->orb_->resolve_initial_references ("RootPOA");
-
- PortableServer::POA_var root_poa =
- PortableServer::POA::_narrow (object.in ());
-
- PortableServer::POAManager_var poa_manager =
- root_poa->the_POAManager ();
-
- // ***************************************************
- // activate state synchronzation agent
-
- PortableServer::ObjectId_var ssa_oid =
- root_poa->activate_object (agent_);
-
- CORBA::Object_var ssa_object =
- root_poa->id_to_reference (ssa_oid.in ());
-
- agent_ref_ =
- StateSynchronizationAgent::_narrow (ssa_object.in ());
-
- poa_manager->activate ();
- }
-
- this->orb_->run ();
- }
- catch (const CORBA::Exception& ex)
- {
- ex._tao_print_exception ("SSA task thread: exception caught:");
- return 1;
- }
-
- return 0;
-}
-
-int
-StateSyncAgentTask::activate (long /* flags */,
- int /* n_threads */,
- int /* force_active */,
- long /* priority */,
- int /* grp_id */,
- ACE_Task_Base* /* task */,
- ACE_hthread_t /* thread_handles */ [],
- void* /* stack */ [],
- size_t /* stack_size */ [],
- ACE_thread_t /* thread_ids */ [],
- const char* /* thr_name */ [])
-{
- // This will end up back in our overridden svc() method. We
- // want to wait for it to execute the statements in its body
- // before returning control to the calling application.
- int retval = this->ACE_Task_Base::activate ();
- sync_.wait ();
- return retval;
-}
-
-StateSynchronizationAgent_ptr
-StateSyncAgentTask::agent_ref (void)
-{
- return agent_ref_.in ();
-}
+// -*- C++ -*-
+// $Id$
+
+#include "tao/PortableServer/POAC.h"
+
+#include "Barrier_Guard.h"
+
+#include "AppOptions.h"
+
+#include "StateSyncAgentTask.h"
+#include "StateSynchronizationAgent_i.h"
+
+StateSyncAgentTask *
+StateSyncAgentTask::instance (void)
+{
+ return
+ ACE_Singleton<StateSyncAgentTask, ACE_SYNCH_MUTEX>::instance ();
+}
+
+StateSyncAgentTask::StateSyncAgentTask (void)
+ : orb_ (AppOptions::instance ()->orb ()),
+ sync_ (2),
+ agent_ref_ (StateSynchronizationAgent::_nil ()),
+ activated_ (false)
+{
+}
+
+int
+StateSyncAgentTask::svc (void)
+{
+ try
+ {
+ {
+ Barrier_Guard barrier_guard (sync_);
+
+ CORBA::Object_var object =
+ this->orb_->resolve_initial_references ("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ // ***************************************************
+ // Create state synchronzation agent.
+
+ AppOptions *app_opts = AppOptions::instance ();
+
+ agent_ =
+ new StateSynchronizationAgent_i (
+ app_opts->host_id (),
+ app_opts->process_id (),
+ ! app_opts->use_dds ());
+
+ PortableServer::ServantBase_var owner_transfer (agent_);
+
+ // ***************************************************
+ // Activate state synchronzation agent.
+
+ PortableServer::ObjectId_var ssa_oid =
+ root_poa->activate_object (agent_);
+
+ CORBA::Object_var ssa_object =
+ root_poa->id_to_reference (ssa_oid.in ());
+
+ agent_ref_ =
+ StateSynchronizationAgent::_narrow (ssa_object.in ());
+
+ poa_manager->activate ();
+ }
+
+ this->orb_->run ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("SSA task thread: exception caught:");
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+StateSyncAgentTask::activate (long /* flags */,
+ int /* n_threads */,
+ int /* force_active */,
+ long /* priority */,
+ int /* grp_id */,
+ ACE_Task_Base* /* task */,
+ ACE_hthread_t /* thread_handles */ [],
+ void* /* stack */ [],
+ size_t /* stack_size */ [],
+ ACE_thread_t /* thread_ids */ [],
+ const char* /* thr_name */ [])
+{
+ if (activated_)
+ {
+ return 0;
+ }
+ else
+ {
+ activated_ = true;
+ }
+
+ // This will end up back in our overridden svc() method. We
+ // want to wait for it to execute the statements in its body
+ // before returning control to the calling application.
+ int retval = this->ACE_Task_Base::activate ();
+ sync_.wait ();
+ return retval;
+}
+
+StateSynchronizationAgent_ptr
+StateSyncAgentTask::agent_ref (void)
+{
+ return agent_ref_.in ();
+}
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h b/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h
index 06e60e14548..29631f864f1 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h
+++ b/TAO/orbsvcs/orbsvcs/LWFT/StateSyncAgentTask.h
@@ -15,14 +15,19 @@
#include "ace/Task.h"
#include "ace/Barrier.h"
+#include "ace/Singleton.h"
+
#include "StateSynchronizationAgent_i.h"
#include "ssa_export.h"
class SSA_Export StateSyncAgentTask : public ACE_Task_Base
{
public:
- StateSyncAgentTask (CORBA::ORB_ptr orb,
- StateSynchronizationAgent_i * agent);
+ friend class ACE_Singleton<StateSyncAgentTask, ACE_SYNCH_MUTEX>;
+
+ /// Used to help ensure that there is only a single instance
+ /// per process of AppSideMonitor_Thread.
+ static StateSyncAgentTask* instance (void);
virtual int svc (void);
@@ -40,15 +45,17 @@ public:
const char* thr_name[] = 0);
StateSynchronizationAgent_ptr agent_ref (void);
+
+private:
+ // Prevent instance creation outside of ACE_Singleton.
+ StateSyncAgentTask (void);
- private:
- CORBA::ORB_var orb_;
-
+private:
+ CORBA::ORB_ptr orb_;
StateSynchronizationAgent_i * agent_;
-
ACE_Barrier sync_;
-
StateSynchronizationAgent_var agent_ref_;
+ bool activated_;
};
#endif /* _STATE_SYNC_AGENT_TASK_H_ */
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp b/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp
index 76634ae1217..821c4736a7c 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp
+++ b/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.cpp
@@ -20,12 +20,10 @@
#endif
StateSynchronizationAgent_i::StateSynchronizationAgent_i (
- CORBA::ORB_ptr orb,
const std::string & host_id,
const std::string & process_id,
bool use_corba)
- : orb_ (CORBA::ORB::_duplicate (orb)),
- host_id_ (host_id),
+ : host_id_ (host_id),
process_id_ (process_id),
#if defined (FLARE_USES_DDS)
domain_id_ (0),//"FLAREDomain"),
diff --git a/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h b/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h
index e333910a25e..08d1365cceb 100644
--- a/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h
+++ b/TAO/orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h
@@ -32,15 +32,10 @@ class SSA_Export StateSynchronizationAgent_i
: public POA_StateSynchronizationAgent
{
public:
- /// ctor
- /// @param reference to a simple long value representing
- /// the state of the application
- StateSynchronizationAgent_i (CORBA::ORB_ptr orb,
- const std::string & host_id,
+ StateSynchronizationAgent_i (const std::string & host_id,
const std::string & process_id,
bool use_corba = true);
- /// dtor
~StateSynchronizationAgent_i (void);
/// Implementation of the StateSynchronizationAgent interface.
@@ -101,9 +96,6 @@ class SSA_Export StateSynchronizationAgent_i
std::string get_unique_id (const std::string & app_name);
private:
- /// orb reference
- CORBA::ORB_var orb_;
-
/// host on which the agent is running
std::string host_id_;