summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2005-06-02 17:26:25 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2005-06-02 17:26:25 +0000
commitdb97c0df52ce7c781cc734a6cd57dedf7ce11557 (patch)
tree6166b7b11a1b382c5db2083b483d8f7d21299f37
parent54004a88806c2d71bdb36942e94c2799ab34f723 (diff)
downloadATCD-db97c0df52ce7c781cc734a6cd57dedf7ce11557.tar.gz
*** empty log message ***
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/NAM_Map.cpp56
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/NAM_Map.h69
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp77
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h2
4 files changed, 177 insertions, 27 deletions
diff --git a/TAO/CIAO/DAnCE/NodeManager/NAM_Map.cpp b/TAO/CIAO/DAnCE/NodeManager/NAM_Map.cpp
new file mode 100644
index 00000000000..788676c2a0f
--- /dev/null
+++ b/TAO/CIAO/DAnCE/NodeManager/NAM_Map.cpp
@@ -0,0 +1,56 @@
+// $Id$
+#include "NAM_Map.h"
+#include "ciao/CIAO_Config.h"
+#include "ciao/CIAO_common.h"
+
+namespace CIAO
+{
+ NAM_Map::NAM_Map (void)
+ : map_ (CIAO_DEFAULT_MAP_SIZE)
+ {
+ }
+
+ bool
+ NAM_Map::is_available (const ACE_CString &str)
+ {
+ if (this->map_.find (str) == 0)
+ return true;
+
+ return false;
+ }
+
+ bool
+ NAM_Map::insert_nam (const ACE_CString &str,
+ ::PortableServer::ObjectId_ptr oid)
+ {
+ return (this->map_.bind (str, oid) == 0)
+ }
+
+ ::PortableServer::ObjectId_ptr
+ NAM_Map::get_nam (const ACE_CString &str)
+ {
+ MAP::ENTRY entry;
+
+ if (this->map_.find (str, entry) != 0)
+ return ::PortableServer::ObjectId::_nil ();
+
+ return ::PortableServer::ObjectId::duplicate (entry.int_id.in ());
+ }
+
+ bool
+ NAM_Map::remove_nam (const PortableServer::ObjectId_ptr oid)
+ {
+ for (Iterator i = this->map_.begin ();
+ i != this->map_.end ();
+ ++i)
+ {
+ //if ( (*iter).int_id_ == oid
+ }
+ return false;
+ }
+
+}
+
+
+
+
diff --git a/TAO/CIAO/DAnCE/NodeManager/NAM_Map.h b/TAO/CIAO/DAnCE/NodeManager/NAM_Map.h
new file mode 100644
index 00000000000..5af6d33b8f4
--- /dev/null
+++ b/TAO/CIAO/DAnCE/NodeManager/NAM_Map.h
@@ -0,0 +1,69 @@
+/**
+ * @file NAM_Map.h
+ * @author Will Otte <wotte@dre.vanderbilt.edu>
+ *
+ * Map of NodeApplicationManagers
+ *
+ * $Id$
+ */
+
+#ifndef CIAO_NAM_MAP_H
+#define CIAO_NAM_MAP_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Null_Mutex.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ciao/DeploymentC.h"
+#include "ace/SString.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace CIAO
+{
+ /**
+ * @class NAM_Map
+ * @brief Implementation of a map of NodeApplicationManagers.
+ *
+ * This table is used by the Node_Daemon to keep track of
+ * NAMs started for multiple assemblies.
+ */
+ class NAM_Map
+ {
+ public:
+ /// Constructor
+ NAM_Map (void);
+
+ /// Determine if there is a NAM associated with a UUID
+ bool is_available (const ACE_CString &str);
+
+ /// Insert a NAM OID into the collection
+ bool insert_nam (const ACE_CString &str,
+ ::PortableServer::ObjectId_ptr oid);
+
+ /// Get a specified NAM.
+ ::PortableServer::ObjectId_ptr
+ get_nam (const ACE_CString &str);
+
+ /// Remove a nam from the map, given its oid.
+ bool remove_nam (const PortableServer::ObjectId_ptr oid);
+
+ private:
+ typedef
+ ACE_Hash_Map_Manager_Ex <ACE_CString,
+ ::PortableServer::ObjectId_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> MAP;
+
+ typedef MAP::iterator Iterator;
+
+ MAP map_;
+ };
+}
+
+
+
+#endif /*CIAO_NAM_MAP_H*/
diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp
index 8d6fe855713..af5eab30a9e 100644
--- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp
+++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp
@@ -98,33 +98,35 @@ CIAO::NodeDaemon_Impl::preparePlan (const Deployment::DeploymentPlan &plan
Deployment::StartError,
Deployment::PlanError))
{
- // Return cached manager
ACE_TRY
{
- if (CORBA::is_nil (this->manager_.in ()))
+ if (!this->map_.is_available (plan.uuid.in ()))
{
+
//Implementation undefined.
CIAO::NodeApplicationManager_Impl *app_mgr;
ACE_NEW_THROW_EX (app_mgr,
- CIAO::NodeApplicationManager_Impl (
- this->orb_.in (),
- this->poa_.in ()),
+ CIAO::NodeApplicationManager_Impl (this->orb_.in (),
+ this->poa_.in ()),
CORBA::NO_MEMORY ());
ACE_TRY_CHECK;
-
+
PortableServer::ServantBase_var safe (app_mgr);
-
+
//@@ Note: after the init call the servant ref count would
// become 2. so we can leave the safeservant along and be
// dead. Also note that I added
- this->manager_ =
+ CORBA::ObjectId_var oid =
app_mgr->init (this->nodeapp_location_,
this->spawn_delay_,
plan,
this->callback_poa_.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
+
+ this->map_.insert_nam (plan.uuid.in (), oid.in ());
+
+ /*
if (CORBA::is_nil (this->manager_.in ()))
{
ACE_ERROR ((LM_ERROR,
@@ -133,43 +135,66 @@ CIAO::NodeDaemon_Impl::preparePlan (const Deployment::DeploymentPlan &plan
"is nil\n"));
ACE_TRY_THROW (Deployment::StartError ());
}
+ */
}
+
+ CORBA::Object_var obj =
+ this->poa_->id_to_reference (this->map_.get_nam (plan.uuid.in ()));
+
+ // narrow should return a nil reference if it fails.
+ return
+ Deployment::NodeApplicationManager::_narrow (obj.in ());
+ }
+ ACE_CATCH (PortableServer::ObjectNotActive)
+ {
+ ACE_THROW (Deployment::StartError ());
}
ACE_CATCHANY
- {
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "NodeDaemon_Impl::preparePlan\t\n");
- ACE_RE_THROW;
- }
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "NodeDaemon_Impl::preparePlan\t\n");
+ ACE_RE_THROW;
+ }
ACE_ENDTRY;
ACE_CHECK_RETURN (Deployment::NodeApplicationManager::_nil ());
-
- // Duplicate this reference to the caller
- return
- Deployment::NodeApplicationManager::_duplicate (this->manager_.in ());
}
void
-CIAO::NodeDaemon_Impl::destroyManager (Deployment::NodeApplicationManager_ptr
- ACE_ENV_ARG_DECL)
+CIAO::NodeDaemon_Impl::destroyManager
+ (Deployment::NodeApplicationManager_ptr manager
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
- Deployment::StopError))
+ Deployment::StopError,
+ Deployment::InvalidReference))
{
ACE_TRY
{
- // @@TODO: Find out why below code throw Object_Not_Active exception.
// Deactivate this object
PortableServer::ObjectId_var id =
- this->poa_->reference_to_id (this->manager_.in ()
+ this->poa_->reference_to_id (manager
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->poa_->deactivate_object (id.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
- this->manager_ =
- Deployment::NodeApplicationManager::_nil ();
+
+ this->map_.remove_nam (id);
+ }
+ ACE_CATCH (PortableServer::WrongAdapter)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "NodeDaemon_Impl::destroyManager: EXCEPTION - "
+ "Invalid reference passed to destroyManager\n"));
+
+ ACE_THROW (Deployment::InvalidReference);
+ }
+ ACE_CATCH (PortableServer::ObjectNotActive)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "NodeDaemon_Impl::destroyManager: EXCEPTION - "
+ " asked to destroy an already inactive object.\n"));
+ ACE_THROW (Deployment::InvalidReference);
}
ACE_CATCHANY
{
diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h
index 404f0aefcba..2c936a56979 100644
--- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h
+++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h
@@ -118,7 +118,7 @@ namespace CIAO
int spawn_delay_;
// Cache reference of last NodeAppManager
- Deployment::NodeApplicationManager_var manager_;
+ // Deployment::NodeApplicationManager_var manager_;
};
}