summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-06-15 22:44:50 +0000
committermcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-06-15 22:44:50 +0000
commita720509ee72294a71bc6976123fb1343e6429285 (patch)
treecdc540fcf167d57a8dca8efb5f2bccb8b143386c
parent62451e562358d916b6a712c83b9b233f436eb953 (diff)
downloadATCD-a720509ee72294a71bc6976123fb1343e6429285.tar.gz
Tue Jun 15 22:36:10 UTC 2010 Martin Corino <mcorino@remedy.nl>
Finishing integration of artifact installation. * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp: * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl: * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h: Fixed problems with multiple installations of single artifacts (i.e. reuse of artifacts in multiple instances). * DAnCE/DAnCE/DAnCE_Properties.idl: Added some Locality Manager properties. * DAnCE/DAnCE/DAnCE_Utility.tpp: * DAnCE/DAnCE/DAnCE_Utility.h: * DAnCE/DAnCE/DAnCE_Utility.cpp: Added update_property_value template methods. * DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp: Added handling of search path properties. * DAnCE/NodeManager/NodeManager.mpc: * DAnCE/NodeManager/NodeManager_Impl.cpp: * DAnCE/NodeManager/NodeManager_Impl.h: * DAnCE/NodeManager/Node_Manager_Module.h: * DAnCE/NodeManager/Node_Manager_Module.cpp: * DAnCE/NodeApplicationManager/NodeApplicationManager.mpc: * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp: * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h: * DAnCE/NodeApplication/NodeApplication_Impl.h: * DAnCE/NodeApplication/NodeApplication_Impl.cpp: Integrated Artifact Installation.
-rw-r--r--CIAO/ChangeLog33
-rw-r--r--CIAO/DAnCE/DAnCE/DAnCE_Properties.idl23
-rw-r--r--CIAO/DAnCE/DAnCE/DAnCE_Utility.cpp61
-rw-r--r--CIAO/DAnCE/DAnCE/DAnCE_Utility.h12
-rw-r--r--CIAO/DAnCE/DAnCE/DAnCE_Utility.tpp31
-rw-r--r--CIAO/DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp55
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp55
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h11
-rw-r--r--CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager.mpc6
-rw-r--r--CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp185
-rw-r--r--CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h6
-rw-r--r--CIAO/DAnCE/NodeManager/NodeManager.mpc4
-rw-r--r--CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp3
-rw-r--r--CIAO/DAnCE/NodeManager/NodeManager_Impl.h3
-rw-r--r--CIAO/DAnCE/NodeManager/Node_Manager_Module.cpp83
-rw-r--r--CIAO/DAnCE/NodeManager/Node_Manager_Module.h4
-rw-r--r--CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp396
-rw-r--r--CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h61
-rw-r--r--CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl65
19 files changed, 809 insertions, 288 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog
index d823dc2ff52..c4a87757d81 100644
--- a/CIAO/ChangeLog
+++ b/CIAO/ChangeLog
@@ -1,3 +1,36 @@
+Tue Jun 15 22:36:10 UTC 2010 Martin Corino <mcorino@remedy.nl>
+
+ Finishing integration of artifact installation.
+
+ * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp:
+ * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl:
+ * DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h:
+ Fixed problems with multiple installations of single artifacts
+ (i.e. reuse of artifacts in multiple instances).
+
+ * DAnCE/DAnCE/DAnCE_Properties.idl:
+ Added some Locality Manager properties.
+
+ * DAnCE/DAnCE/DAnCE_Utility.tpp:
+ * DAnCE/DAnCE/DAnCE_Utility.h:
+ * DAnCE/DAnCE/DAnCE_Utility.cpp:
+ Added update_property_value template methods.
+
+ * DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp:
+ Added handling of search path properties.
+
+ * DAnCE/NodeManager/NodeManager.mpc:
+ * DAnCE/NodeManager/NodeManager_Impl.cpp:
+ * DAnCE/NodeManager/NodeManager_Impl.h:
+ * DAnCE/NodeManager/Node_Manager_Module.h:
+ * DAnCE/NodeManager/Node_Manager_Module.cpp:
+ * DAnCE/NodeApplicationManager/NodeApplicationManager.mpc:
+ * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp:
+ * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h:
+ * DAnCE/NodeApplication/NodeApplication_Impl.h:
+ * DAnCE/NodeApplication/NodeApplication_Impl.cpp:
+ Integrated Artifact Installation.
+
Tue Jun 15 18:55:51 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* tutorials/Quoter/Simple/03.html:
diff --git a/CIAO/DAnCE/DAnCE/DAnCE_Properties.idl b/CIAO/DAnCE/DAnCE/DAnCE_Properties.idl
index 1c17c7d1a82..b1973433595 100644
--- a/CIAO/DAnCE/DAnCE/DAnCE_Properties.idl
+++ b/CIAO/DAnCE/DAnCE/DAnCE_Properties.idl
@@ -1,6 +1,6 @@
-/**
+/**
* $Id$
- *
+ *
* @file DAnCE_Properties.idl
* @author William R. Otte <wotte@dre.vanderbilt.edu>
*
@@ -12,7 +12,7 @@ module DAnCE
// Home Configuration Properties
/// Describes the entrypoint for the home executor. Property value is string.
const string HOME_FACTORY = "home factory";
-
+
// Component Configuration Properties
/// Describes the entrypoint for the component executor. Property value is string.
const string COMPONENT_FACTORY = "component factory";
@@ -21,7 +21,7 @@ module DAnCE
const string EXPLICIT_HOME = "edu.vanderbilt.dre.DAnCE.ExplicitHome";
// Instance (i.e., Home or Component) Properties
- /// Indicates that the instance object reference should be registered in the
+ /// Indicates that the instance object reference should be registered in the
/// Instance naming context using a specified name. Property value is string.
const string REGISTER_NAMING = "edu.vanderbilt.dre.DAnCE.RegisterNaming";
/// Indicates that the instance object reference should be printed to a specifid
@@ -30,14 +30,14 @@ module DAnCE
// const string REGISTER_PORT_NAMING = "edu.vanderbilt.dre.DAnCE.RegisterPortNaming";
// Node Infrastructure Configuration
- /// Indicates that the NodeManager is running as a standalone entity.
+ /// Indicates that the NodeManager is running as a standalone entity.
const string STANDALONE_NM = "edu.vanderbilt.dre.DAnCE.StandaloneNM";
/// Indicates the naming context for domain objects, which includes infrastructure
- /// and redirection.
+ /// and redirection.
const string DOMAIN_NC = "edu.vanderbilt.dre.DAnCE.DomainNC";
- /// Indicates the naming context used for instance objects.
+ /// Indicates the naming context used for instance objects.
const string INSTANCE_NC = "edu.vanderbilt.dre.DAnCE.InstanceNC";
-
+
const string LOCALITY_TIMEOUT = "edu.vanderbilt.dre.DAnCE.LocalityTimeout";
const string LOCALITY_UUID = "edu.vanderbilt.dre.DAnCE.LocalityUUID";
const string LOCALITY_ARGUMENTS = "edu.vanderbilt.dre.DAnCE.LocalityArguments";
@@ -46,12 +46,17 @@ module DAnCE
const string LOCALITY_NAMINGCONTEXT = "edu.vanderbilt.dre.DAnCE.LocalityNamingContext";
// Implementation Types
- const string IMPL_TYPE = "edu.vanderbilt.dre.DAnCE.ImplementationType";
+ const string IMPL_TYPE = "edu.vanderbilt.dre.DAnCE.ImplementationType";
const string SERVER_EXECUTABLE = "edu.vanderbilt.dre.DAnCE.ServerExecutable";
const string CCM_CONTAINER = "edu.dre.vanderbilt.dre.CCM.Container";
const string CCM_HOME = "edu.dre.vanderbilt.dre.CCM.Home";
const string CCM_COMPONENT = "edu.dre.vanderbilt.dre.CCM.Component";
const string CCM_HOMEDCOMPONENT = "edu.dre.vanderbilt.dre.CCM.HomedComponent";
const string DANCE_LOCALITYMANAGER = "edu.vanderbilt.dre.DAnCE.LocalityManager";
+
+ // Locality Manager execParameter properties
+ const string DANCE_LM_PATH = "edu.vanderbilt.dre.DAnCE.LocalityManager.path";
+ const string DANCE_LM_LIBPATH = "edu.vanderbilt.dre.DAnCE.LocalityManager.libpath";
+ const string DANCE_LM_INSTALLER = "edu.vanderbilt.dre.DAnCE.LocalityManager.installer";
};
diff --git a/CIAO/DAnCE/DAnCE/DAnCE_Utility.cpp b/CIAO/DAnCE/DAnCE/DAnCE_Utility.cpp
index e4afce5ab2b..6e928721747 100644
--- a/CIAO/DAnCE/DAnCE/DAnCE_Utility.cpp
+++ b/CIAO/DAnCE/DAnCE/DAnCE_Utility.cpp
@@ -15,7 +15,7 @@ namespace DAnCE
const ::Deployment::Properties &prop)
{
DANCE_TRACE("DAnCE::Utility::build_config_values_map");
-
+
for (CORBA::ULong i = 0; i < prop.length (); ++i)
{
int const retval = map.rebind (prop[i].name.in (), prop[i].value);
@@ -71,7 +71,7 @@ namespace DAnCE
{
CORBA::ULong pos = dest.length ();
dest.length (pos + src.length ());
-
+
for (CORBA::ULong i = 0; i < src.length (); ++i)
{
dest[pos].name = CORBA::string_dup (src[i].name.in ());
@@ -82,12 +82,12 @@ namespace DAnCE
template<>
bool get_property_value (const char *name,
- const PROPERTY_MAP &properties,
+ const PROPERTY_MAP &properties,
bool &val)
{
DANCE_TRACE ("DAnCE::Utility::get_property_value<bool>");
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<bool> - ")
ACE_TEXT("Finding property value for name '%C'\n"),
name));
@@ -101,14 +101,14 @@ namespace DAnCE
}
else
{
- DANCE_ERROR (1, (LM_WARNING, DLINFO
+ DANCE_ERROR (1, (LM_WARNING, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<T> - ")
ACE_TEXT("Failed to extract property value for %C\n"), name));
return false;
}
}
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<bool> - ")
ACE_TEXT("Property value for name '%C' has no value\n"),
name));
@@ -118,13 +118,13 @@ namespace DAnCE
template<>
bool get_property_value (const char *name,
- const PROPERTY_MAP &properties,
+ const PROPERTY_MAP &properties,
const char *&val)
{
DANCE_TRACE ("DAnCE::Utility::get_property_value<const char *>");
CORBA::Any any;
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<bool> - ")
ACE_TEXT("Finding property value for name '%C'\n"),
name));
@@ -137,14 +137,14 @@ namespace DAnCE
}
else
{
- DANCE_ERROR (1, (LM_WARNING, DLINFO
+ DANCE_ERROR (1, (LM_WARNING, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<const char *> - ")
ACE_TEXT("Failed to extract property value for %C\n"), name));
return false;
}
}
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<bool> - ")
ACE_TEXT("Property value for name '%C' has no value\n"), name));
@@ -152,13 +152,13 @@ namespace DAnCE
}
template<>
- bool get_property_value (const char *name,
+ bool get_property_value (const char *name,
const ::Deployment::Properties &properties,
const char * &val)
{
DANCE_TRACE ("DAnCE::Utility::get_property_value<const char *>");
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<T> - ")
ACE_TEXT("Finding property value for name '%C'\n"),
name));
@@ -167,7 +167,7 @@ namespace DAnCE
{
if (ACE_OS::strcmp (properties[i].name.in (), name) == 0)
{
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<T> - ")
ACE_TEXT("Found property '%C'\n"), name));
if (properties[i].value >>= CORBA::Any::to_string (val, 0))
@@ -179,7 +179,7 @@ namespace DAnCE
}
else
{
- DANCE_ERROR (1, (LM_WARNING, DLINFO
+ DANCE_ERROR (1, (LM_WARNING, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<T> - ")
ACE_TEXT("Failed to extract property value for %C\n"),
name));
@@ -189,13 +189,44 @@ namespace DAnCE
}
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT("DAnCE::Utility::get_property_value<T> - ")
ACE_TEXT("Unable to find property named %C\n"), name));
return false;
}
+ template<char*>
+ void update_property_value (const char *name,
+ ::Deployment::Properties &properties,
+ const char* &val)
+ {
+ DANCE_TRACE ("DAnCE::Utility::update_property_value<char*>");
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<char*> - ")
+ ACE_TEXT("Finding property value for name '%C'\n"),
+ name));
+
+ for (CORBA::ULong i = 0; i < properties.length (); ++i)
+ {
+ if (ACE_OS::strcmp (properties[i].name.in (), name) == 0)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<char*> - ")
+ ACE_TEXT("Found property '%C'\n"), name));
+ properties[i].value <<= val;
+ return;
+ }
+ }
+
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<char*> - ")
+ ACE_TEXT("Property for name '%C' not found; adding property\n"), name));
+
+ properties.length (properties.length () + 1);
+ properties[properties.length () - 1].name = CORBA::string_dup (name);
+ properties[properties.length () - 1].value <<= val;
+ }
+
const char *
get_instance_type (const ::Deployment::Properties& prop)
{
diff --git a/CIAO/DAnCE/DAnCE/DAnCE_Utility.h b/CIAO/DAnCE/DAnCE/DAnCE_Utility.h
index b211094200a..73fa4cf19e6 100644
--- a/CIAO/DAnCE/DAnCE/DAnCE_Utility.h
+++ b/CIAO/DAnCE/DAnCE/DAnCE_Utility.h
@@ -50,6 +50,12 @@ namespace DAnCE
const ::Deployment::Properties &properties,
T &val);
+ template<class T>
+ void
+ update_property_value (const char *name,
+ ::Deployment::Properties &properties,
+ const T &val);
+
template <typename EXCEPTION>
void test_and_set_exception (bool &flag, EXCEPTION &exception,
const char *name, const char *reason);
@@ -89,6 +95,12 @@ namespace DAnCE
get_property_value (const char *name,
const ::Deployment::Properties &properties,
const char * &val);
+
+ template<char*>
+ DANCE_STUB_Export void
+ update_property_value (const char *name,
+ ::Deployment::Properties &properties,
+ const char * &val);
}
}
diff --git a/CIAO/DAnCE/DAnCE/DAnCE_Utility.tpp b/CIAO/DAnCE/DAnCE/DAnCE_Utility.tpp
index ed9ca40a9d8..5adf5798d35 100644
--- a/CIAO/DAnCE/DAnCE/DAnCE_Utility.tpp
+++ b/CIAO/DAnCE/DAnCE/DAnCE_Utility.tpp
@@ -74,6 +74,35 @@ namespace DAnCE
return false;
}
+ template<class T>
+ void update_property_value (const char *name, ::Deployment::Properties &properties, const T &val)
+ {
+ DANCE_TRACE ("DAnCE::Utility::update_property_value<T>");
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<T> - ")
+ ACE_TEXT("Finding property value for name '%C'\n"),
+ name));
+
+ for (CORBA::ULong i = 0; i < properties.length (); ++i)
+ {
+ if (ACE_OS::strcmp (properties[i].name.in (), name) == 0)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<T> - ")
+ ACE_TEXT("Found property '%C'\n"), name));
+ properties[i].value <<= val;
+ return;
+ }
+ }
+
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DAnCE::Utility::update_property_value<T> - ")
+ ACE_TEXT("Property for name '%C' not found; adding property\n"), name));
+
+ properties.length (properties.length () + 1);
+ properties[properties.length () - 1].name = CORBA::string_dup (name);
+ properties[properties.length () - 1].value <<= val;
+ }
+
/// Tests flag, if false, sets it to true and replaces the name and
/// reason flags of the exception.
template <typename EXCEPTION>
@@ -86,7 +115,7 @@ namespace DAnCE
exception.name = name;
exception.reason = reason;
}
- }
+ }
}
}
diff --git a/CIAO/DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp b/CIAO/DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp
index 3cfb1d8e339..5dd463fe5df 100644
--- a/CIAO/DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp
+++ b/CIAO/DAnCE/LocalityManager/Handler/LocalityActivator_Impl.cpp
@@ -172,7 +172,7 @@ namespace DAnCE
DANCE_TRACE("DAnCE_LocalityActivator_i::create_locality_manager");
Safe_Server_Info server (new Server_Info (config.length () + 1));
-
+
DANCE_DEBUG (6, (LM_DEBUG, DLINFO
ACE_TEXT ("DAnCE_LocalityActivator_i::create_locality_manager - ")
ACE_TEXT ("Received %u config properties\n"),
@@ -207,14 +207,14 @@ namespace DAnCE
CORBA::ULong t;
if (val >>= t)
{
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
ACE_TEXT ("DAnCE_LocalityActivator_i::create_locality_manager - ")
ACE_TEXT ("Using provided non-default server timeout of %u\n"), t));
timeout = ACE_Time_Value (t);
}
else
{
- DANCE_ERROR (1, (LM_WARNING, DLINFO
+ DANCE_ERROR (1, (LM_WARNING, DLINFO
ACE_TEXT ("DAnCE_LocalityActivator_i::create_locality_manager - ")
ACE_TEXT ("Failed to extract provided non-default server timeout ")
ACE_TEXT ("from property '%C', ")
@@ -334,6 +334,45 @@ namespace DAnCE
options.avoid_zombies (0);
+ // check for customized PATH addition
+ if (si.cmap_->find (DANCE_LM_PATH, val) == 0)
+ {
+ path = 0;
+ val >>= path;
+ if (path)
+ {
+ ACE_CString newpath (ACE_OS::getenv ("PATH"));
+ newpath += ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+ newpath += path;
+ options.setenv (ACE_TEXT("PATH"), ACE_TEXT_CHAR_TO_TCHAR (newpath.c_str ()));
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT ("DAnCE_LocalityActivator_i::spawn_locality_manager - ")
+ ACE_TEXT ("configured customized PATH environment: %C\n"),
+ newpath.c_str ()));
+ }
+ }
+
+ // check for customized LD search path addition
+ if (si.cmap_->find (DANCE_LM_LIBPATH, val) == 0)
+ {
+ path = 0;
+ val >>= path;
+ if (path)
+ {
+ ACE_CString newpath (ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH)));
+ newpath += ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+ newpath += path;
+ options.setenv (ACE_LD_SEARCH_PATH, ACE_TEXT_CHAR_TO_TCHAR (newpath.c_str ()));
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT ("DAnCE_LocalityActivator_i::spawn_locality_manager - ")
+ ACE_TEXT ("configured customized %s environment: %C\n"),
+ ACE_LD_SEARCH_PATH,
+ newpath.c_str ()));
+ }
+ }
+
DANCE_DEBUG (9, (LM_TRACE, DLINFO
ACE_TEXT ("DAnCE_LocalityActivator_i::spawn_locality_manager - ")
ACE_TEXT ("Spawning process, command line is %s\n"),
@@ -415,7 +454,7 @@ namespace DAnCE
"timed out waiting for callback");
}
}
-
+
void
DAnCE_LocalityActivator_i::remove_locality_manager (::DAnCE::LocalityManager_ptr server)
{
@@ -474,18 +513,18 @@ namespace DAnCE
ACE_TEXT ("length %u\n"),
info.uuid_.c_str (),
info.cmap_->current_size ()));
-
+
if (info.cmap_->current_size () == 0) return;
ACE_NEW_THROW_EX (config,
Deployment::Properties (info.cmap_->current_size ()),
CORBA::NO_MEMORY ());
-
+
config->length (info.cmap_->current_size ());
-
+
CORBA::ULong pos = 0;
Utility::PROPERTY_MAP::iterator i = info.cmap_->begin ();
-
+
do {
config[pos].name = i->ext_id_.c_str ();
config[pos].value = i->int_id_;
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp
index e042bf76335..7222c85673b 100644
--- a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp
@@ -31,10 +31,12 @@ using namespace DAnCE::Utility;
NodeApplication_Impl::NodeApplication_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const ACE_CString& node_name,
const PROPERTY_MAP &properties)
: orb_ (CORBA::ORB::_duplicate (orb)),
poa_ (PortableServer::POA::_duplicate (poa)),
+ installer_ (DAnCE::ArtifactInstallation::_duplicate (installer)),
node_name_ (node_name),
properties_ (),
handler_ (properties,
@@ -50,7 +52,6 @@ NodeApplication_Impl::NodeApplication_Impl (CORBA::ORB_ptr orb,
this->properties_.bind (i->key (), i->item ());
i.advance ();
}
- this->init ();
}
NodeApplication_Impl::~NodeApplication_Impl()
@@ -59,38 +60,6 @@ NodeApplication_Impl::~NodeApplication_Impl()
}
void
-NodeApplication_Impl::init()
-{
- DANCE_TRACE( "NodeApplication_Impl::init()");
-
- /* TODO: Lets move this stuff to the constructor, shall we?!? */
- /* TODO: Might be nice to use a component configurator here to load the proper versions
- of the serveractivator. */
-
- const ACE_TCHAR *ior = 0;
-
- if (get_property_value (DAnCE::INSTANCE_NC, this->properties_, ior) ||
- get_property_value (DAnCE::DOMAIN_NC, this->properties_, ior))
- {
- try
- {
- CORBA::Object_var obj = this->orb_->string_to_object (ior);
- this->instance_nc_ = CosNaming::NamingContext::_narrow (obj);
- }
- catch (const CORBA::Exception &e)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("NodeApplication_Impl::init - ")
- ACE_TEXT("Unable to resolve the instance naming context:%C\n"),
- e._info ().c_str ()));
- }
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("NodeApplication_Impl::init - ")
- ACE_TEXT("Successfully resolved the instance naming context.\n")));
- }
- else DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("NodeApplication_Impl::init - ")
- ACE_TEXT("No instance NC was provided\n")));
-}
-
-void
NodeApplication_Impl::prepare_instances (const LocalitySplitter::TSubPlans& plans)
{
DANCE_TRACE ("NodeApplication_Impl::prepare_instances");
@@ -129,25 +98,9 @@ NodeApplication_Impl::prepare_instances (const LocalitySplitter::TSubPlans& plan
lm_idd.name.in ()
));
- // TODO: MCO - this is definitely not nice; what else can we do here?
-
- // Need to make a temp copy since we're modifying properties
- ::Deployment::DeploymentPlan lm_plan;
- lm_plan.instance.length (1);
- lm_plan.implementation.length (1);
- lm_plan.instance[0] = lm_idd;
- lm_plan.instance[0].implementationRef = 0;
- lm_plan.implementation[0] = sub_plan.implementation[lm_idd.implementationRef];
-
- // Need to add naming service reference to properties.
- CORBA::ULong pos = lm_plan.instance[0].configProperty.length ();
- lm_plan.instance[0].configProperty.length (pos + 1);
- lm_plan.instance[0].configProperty[pos].name = DAnCE::LOCALITY_NAMINGCONTEXT;
- lm_plan.instance[0].configProperty[pos].value <<= this->instance_nc_;
-
CORBA::Any_var reference;
- this->handler_.install_instance (lm_plan,
- 0,
+ this->handler_.install_instance (sub_plan,
+ loc_manager_instance,
reference.out ());
::DAnCE::LocalityManager_var lm_ref;
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h
index 86b8ffc7f6d..8c2de19ef10 100644
--- a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h
@@ -21,17 +21,15 @@
#include "ace/Containers_T.h"
#include "tao/AnyTypeCode/AnyTypeCode_methods.h"
-#include "tao/ORB.h"
-#include "tao/Object.h"
#include "ccm/CCM_KeylessCCMHomeC.h"
#include "ciao/ComponentServer/CIAO_ServerActivator_Impl.h"
-#include "orbsvcs/orbsvcs/CosNamingC.h"
#include "ccm/ComponentServer/CCM_ComponentServerC.h"
#include "Deployment/Deployment_NodeApplicationS.h"
#include "Deployment/Deployment_DeploymentPlanC.h"
#include "Deployment/DeploymentC.h"
#include "DAnCE/DAnCE_Utility.h"
+#include "DAnCE/DAnCE_ArtifactInstallationC.h"
#include "LocalityManager/Handler/Locality_Manager_Handler_Impl.h"
#include "Split_Plan/Locality_Splitter.h"
#include "Split_Plan/Split_Plan.h"
@@ -54,6 +52,7 @@ namespace DAnCE
public:
NodeApplication_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const ACE_CString& node_name,
const PROPERTY_MAP &properties);
@@ -72,8 +71,6 @@ namespace DAnCE
void remove_instances (void);
protected:
- void init(void);
-
void prepare_instance (const char *name,
const ::Deployment::DeploymentPlan &plan);
@@ -81,12 +78,12 @@ namespace DAnCE
PortableServer::POA_var poa_;
+ DAnCE::ArtifactInstallation_var installer_;
+
ACE_CString node_name_;
PROPERTY_MAP properties_;
- CosNaming::NamingContext_var instance_nc_;
-
DAnCE::Locality_Handler_i handler_;
typedef std::map <ACE_CString, ::DAnCE::LocalityManager_var>
diff --git a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager.mpc b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager.mpc
index 098ca4815f9..3a3f4f10399 100644
--- a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager.mpc
+++ b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager.mpc
@@ -1,9 +1,9 @@
// -*- MPC -*-
// $Id$
-project (DAnCE_NodeApplicationManager) : install, dance_lib, naming, dance_nodeapplicationmanager_skel, \
- dynamicinterface, \
- dance_nodeapplication, avoids_ace_for_tao {
+project (DAnCE_NodeApplicationManager) : install, dance_lib, naming, \
+ dance_nodeapplicationmanager_skel,dynamicinterface, \
+ dance_nodeapplication, dance_stub, avoids_ace_for_tao {
sharedname = DAnCE_NodeApplicationManager
dynamicflags = NODEAPPLICATIONMANAGER_BUILD_DLL
diff --git a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp
index 891b2e61cf7..6e69c38bfa6 100644
--- a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp
+++ b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp
@@ -6,17 +6,23 @@
#include "NodeApplicationManager_Impl.h"
#include "NodeApplication/NodeApplication_Impl.h"
-
#include "DAnCE/DAnCE/DAnCE_PropertiesC.h"
+#include "DAnCE/DAnCE/DAnCE_Utility.h"
+#include "ace/Unbounded_Set.h"
+#include "tao/ORB.h"
+#include "tao/Object.h"
using namespace DAnCE;
+using namespace DAnCE::Utility;
NodeApplicationManager_Impl::NodeApplicationManager_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const ACE_CString& node_name,
const PROPERTY_MAP &properties)
: orb_ (CORBA::ORB::_duplicate (orb)),
poa_ (PortableServer::POA::_duplicate (poa)),
+ installer_ (DAnCE::ArtifactInstallation::_duplicate (installer)),
application_ (0),
node_name_ (node_name),
properties_ ()
@@ -37,6 +43,31 @@ NodeApplicationManager_Impl::NodeApplicationManager_Impl (CORBA::ORB_ptr orb,
this->properties_.bind (i->key (), i->item ());
i.advance ();
}
+
+ const ACE_TCHAR *ior = 0;
+
+ if (get_property_value (DAnCE::INSTANCE_NC, this->properties_, ior) ||
+ get_property_value (DAnCE::DOMAIN_NC, this->properties_, ior))
+ {
+ try
+ {
+ CORBA::Object_var obj = this->orb_->string_to_object (ior);
+ this->instance_nc_ = CosNaming::NamingContext::_narrow (obj);
+ }
+ catch (const CORBA::Exception &e)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO
+ ACE_TEXT("NodeApplicationManager_Impl::NodeApplicationManager_Impl - ")
+ ACE_TEXT("Unable to resolve the instance naming context:%C\n"),
+ e._info ().c_str ()));
+ }
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT("NodeApplicationManager_Impl::NodeApplicationManager_Impl - ")
+ ACE_TEXT("Successfully resolved the instance naming context.\n")));
+ }
+ else DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT("NodeApplicationManager_Impl::NodeApplicationManager_Impl - ")
+ ACE_TEXT("No instance NC was provided\n")));
}
NodeApplicationManager_Impl::~NodeApplicationManager_Impl()
@@ -45,6 +76,23 @@ NodeApplicationManager_Impl::~NodeApplicationManager_Impl()
try
{
+ // initialize installer
+ this->installer_->initialize ();
+
+ // install artifacts for each sub plan and update path and libpath
+ // properties for the locality manager instance of each sub plan
+ // also pass the installer reference in a property
+ for (LocalitySplitter::TSubPlanIterator itplan = this->split_plan_.plans ().begin ();
+ itplan != this->split_plan_.plans ().end ();
+ ++itplan)
+ {
+ // remove all artifacts for this sub plan
+ this->installer_->remove_all ((*itplan).int_id_.UUID. in ());
+ }
+
+ // cleanup installer resources
+ this->installer_->clear ();
+
if (this->application_ != 0)
{
CORBA::Object_var app =
@@ -69,18 +117,148 @@ NodeApplicationManager_Impl::preparePlan (const Deployment::DeploymentPlan& plan
{
DANCE_TRACE ("NodeApplicationManager_Impl::preparePlan");
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (4, (LM_TRACE, DLINFO
ACE_TEXT("NodeApplicationManager_impl::preparePlan - ")
ACE_TEXT("Performing locality split on plan %C.\n"),
plan.UUID.in ()));
this->split_plan_.split_plan (plan);
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ DANCE_DEBUG (4, (LM_TRACE, DLINFO
ACE_TEXT("NodeApplicationManager_impl::preparePlan - ")
ACE_TEXT("Plan %C successfully split into %u localities.\n"),
plan.UUID.in (),
this->split_plan_.plans ().current_size ()));
+
+ // initialize installer
+ this->installer_->initialize ();
+
+ // install artifacts for each sub plan and update path and libpath
+ // properties for the locality manager instance of each sub plan
+ // also pass the installer reference in a property
+ for (LocalitySplitter::TSubPlanIterator itplan = this->split_plan_.plans ().begin ();
+ itplan != this->split_plan_.plans ().end ();
+ ++itplan)
+ {
+ ACE_Unbounded_Set<ACE_CString> artifact_paths;
+
+ ::Deployment::DeploymentPlan &sub_plan = (*itplan).int_id_;
+ LocalitySplitter::TSubPlanKey &sub_plan_key = (*itplan).ext_id_;
+
+ DANCE_DEBUG (4, (LM_TRACE, DLINFO
+ ACE_TEXT("NodeApplicationManager_impl::preparePlan - ")
+ ACE_TEXT("Installing %u artifacts for locality %C.\n"),
+ sub_plan.artifact.length (),
+ sub_plan.UUID.in ()));
+
+ // install artifacts
+ for (CORBA::ULong i=0;
+ i < sub_plan.artifact.length ();
+ ++i)
+ {
+ this->installer_->install(sub_plan.UUID.in (),
+ sub_plan.artifact[i]);
+
+ CORBA::String_var location =
+ this->installer_->get_artifact_location (sub_plan.UUID.in (),
+ sub_plan.artifact[i].name.in ());
+
+ // modify artifact descriptor location field to reflect the installed
+ // artifact's location
+ sub_plan.artifact[i].location.length (1);
+ sub_plan.artifact[i].location[0] = location._retn ();
+
+ // collect all unique paths
+ ACE_CString path (sub_plan.artifact[i].location[0].in (),
+ 0, false); // avoid copying
+ ACE_CString::size_type pos = path.rfind (ACE_DIRECTORY_SEPARATOR_CHAR_A);
+ if (pos != ACE_CString::npos)
+ {
+ artifact_paths.insert (path.substr (0, pos>0 ? pos : 1));
+ }
+ }
+
+ // get locality manager deployment descriptors
+ ::Deployment::InstanceDeploymentDescription& lm_idd =
+ sub_plan.instance[sub_plan_key.locality_manager_instance ()];
+ ::Deployment::MonolithicDeploymentDescription& lm_mdd =
+ sub_plan.implementation[lm_idd.implementationRef];
+
+ // update path and libpath properties of sub plan locality manager
+ if (artifact_paths.size () > 0)
+ {
+ ACE_CString search_path;
+ for (ACE_Unbounded_Set<ACE_CString>::iterator it = artifact_paths.begin ();
+ it != artifact_paths.end ();
+ ++it)
+ {
+ if (!search_path.empty ())
+ search_path += ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+ search_path += *it;
+ }
+
+ // update PATH
+ ACE_CString new_path;
+ const char* prop_val = 0;
+ if (DAnCE::Utility::get_property_value (DAnCE::DANCE_LM_PATH,
+ lm_mdd.execParameter,
+ prop_val) && prop_val != 0)
+ {
+ new_path += prop_val;
+ new_path += ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+ new_path += search_path;
+ }
+ else
+ {
+ new_path.set (search_path.c_str (), false); // avoid copying
+ }
+ DAnCE::Utility::update_property_value (DAnCE::DANCE_LM_PATH,
+ lm_mdd.execParameter,
+ new_path.c_str ());
+
+ // On windows these two search paths are the same
+#if !defined (ACE_WIN32)
+ // update LIBPATH
+ new_path.clear ();
+ prop_val = 0;
+ if (DAnCE::Utility::get_property_value (DAnCE::DANCE_LM_LIBPATH,
+ lm_mdd.execParameter,
+ prop_val) && prop_val != 0)
+ {
+ new_path += prop_val;
+ new_path += ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH_SEPARATOR_STR);
+ new_path += search_path;
+ }
+ else
+ {
+ new_path.set (search_path.c_str (), false); // avoid copying
+ }
+ DAnCE::Utility::update_property_value (DAnCE::DANCE_LM_LIBPATH,
+ lm_mdd.execParameter,
+ new_path.c_str ());
+ }
+#endif
+ // Need to add naming service reference to config properties.
+ DAnCE::Utility::update_property_value<CosNaming::NamingContext_var> (
+ DAnCE::LOCALITY_NAMINGCONTEXT,
+ lm_idd.configProperty,
+ this->instance_nc_);
+
+ // pass installer reference as an execParameter property
+ DAnCE::Utility::update_property_value<DAnCE::ArtifactInstallation_var> (
+ DAnCE::DANCE_LM_INSTALLER,
+ lm_mdd.execParameter,
+ this->installer_);
+ }
+
+ // cleanup installer resources
+ // (does *not* cleanup install registry; just signals end of install actions)
+ this->installer_->clear ();
+
+ DANCE_DEBUG (4, (LM_TRACE, DLINFO
+ ACE_TEXT("NodeApplicationManager_impl::preparePlan - ")
+ ACE_TEXT("Finished preparing plan %C.\n"),
+ plan.UUID.in ()));
}
Deployment::Application_ptr
@@ -95,6 +273,7 @@ NodeApplicationManager_Impl::startLaunch (const Deployment::Properties &prop,
ACE_NEW_THROW_EX (this->application_,
NodeApplication_Impl (this->orb_.in(),
this->poa_.in(),
+ this->installer_.in (),
this->node_name_,
this->properties_),
CORBA::NO_MEMORY ());
diff --git a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h
index 53dbc5ed5fc..c60bcb701e8 100644
--- a/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h
+++ b/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h
@@ -21,9 +21,12 @@
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "orbsvcs/orbsvcs/CosNamingC.h"
+
#include "Deployment/Deployment_DeploymentPlanC.h"
#include "Deployment/Deployment_NodeApplicationManagerS.h"
#include "NodeApplication/NodeApplication_Impl.h"
+#include "DAnCE/DAnCE_ArtifactInstallationC.h"
namespace DAnCE
{
@@ -35,6 +38,7 @@ namespace DAnCE
NodeApplicationManager_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const ACE_CString& name,
const PROPERTY_MAP &properties);
@@ -52,9 +56,11 @@ namespace DAnCE
LocalitySplitter split_plan_;
CORBA::ORB_var orb_;
PortableServer::POA_var poa_;
+ DAnCE::ArtifactInstallation_var installer_;
NodeApplication_Impl* application_;
ACE_CString node_name_;
PROPERTY_MAP properties_;
+ CosNaming::NamingContext_var instance_nc_;
};
typedef PortableServer::Servant_var<NodeApplicationManager_Impl> Safe_NodeApplicationManager_Impl;
diff --git a/CIAO/DAnCE/NodeManager/NodeManager.mpc b/CIAO/DAnCE/NodeManager/NodeManager.mpc
index 3d414bcde04..81dae1638b5 100644
--- a/CIAO/DAnCE/NodeManager/NodeManager.mpc
+++ b/CIAO/DAnCE/NodeManager/NodeManager.mpc
@@ -2,7 +2,9 @@
// $Id$
project(Node_Manager_Exec) : install, utils, dance_exe, naming, avoids_ace_for_tao, \
- dance_nodeapplicationmanager, dance_nodemanager_skel, ciao_logger {
+ dance_nodeapplicationmanager, dance_nodemanager_skel, dance_skel, \
+ dance_artifact_installation, dance_installation_repository_manager, \
+ dance_installation_handlers, ciao_logger {
exename = dance_node_manager
Source_Files {
diff --git a/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp b/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp
index db0e97f483e..092a65a2668 100644
--- a/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp
+++ b/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp
@@ -14,10 +14,12 @@ namespace DAnCE
{
NodeManager_Impl::NodeManager_Impl(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const char* name,
const PROPERTY_MAP &properties)
: orb_ (CORBA::ORB::_duplicate (orb)),
poa_ (PortableServer::POA::_duplicate (poa)),
+ installer_ (DAnCE::ArtifactInstallation::_duplicate (installer)),
name_ (name),
properties_ (properties.current_size ())
{
@@ -120,6 +122,7 @@ namespace DAnCE
ACE_NEW_THROW_EX (manager,
NodeApplicationManager_Impl (this->orb_.in(),
this->poa_.in(),
+ this->installer_. in (),
this->name_,
this->properties_),
CORBA::NO_MEMORY());
diff --git a/CIAO/DAnCE/NodeManager/NodeManager_Impl.h b/CIAO/DAnCE/NodeManager/NodeManager_Impl.h
index e03b2ded35f..21e84f17540 100644
--- a/CIAO/DAnCE/NodeManager/NodeManager_Impl.h
+++ b/CIAO/DAnCE/NodeManager/NodeManager_Impl.h
@@ -21,6 +21,7 @@
#include "DAnCE/DAnCE_Utility.h"
#include "Deployment/Deployment_NodeManagerS.h"
#include "NodeApplicationManager/NodeApplicationManager_Impl.h"
+#include "DAnCE/DAnCE_ArtifactInstallationC.h"
#include "ace/Map_Manager.h"
namespace DAnCE
@@ -32,6 +33,7 @@ namespace DAnCE
/// The fixed listener port is caused by the usage of CCM Object locator
NodeManager_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
+ DAnCE::ArtifactInstallation_ptr installer,
const char* name,
const PROPERTY_MAP &options);
@@ -55,6 +57,7 @@ namespace DAnCE
private:
CORBA::ORB_var orb_;
PortableServer::POA_var poa_;
+ DAnCE::ArtifactInstallation_var installer_;
ACE_CString name_;
/// @todo, see if we can use a _ptr
typedef ACE_Map_Manager<ACE_CString, NodeApplicationManager_Impl*, ACE_Null_Mutex > TManagers;
diff --git a/CIAO/DAnCE/NodeManager/Node_Manager_Module.cpp b/CIAO/DAnCE/NodeManager/Node_Manager_Module.cpp
index b4e30a4c1fd..a4f057fb9e4 100644
--- a/CIAO/DAnCE/NodeManager/Node_Manager_Module.cpp
+++ b/CIAO/DAnCE/NodeManager/Node_Manager_Module.cpp
@@ -12,6 +12,11 @@
#include "DAnCE/DAnCE/DAnCE_PropertiesC.h"
#include "Node_Manager_Module.h"
#include "NodeManager_Impl.h"
+#include "Artifact_Installation/Artifact_Installation_Impl.h"
+#include "Artifact_Installation/Artifact_Installation_Handler_Svc.h"
+#include "Artifact_Installation/Installation_Repository_Manager_Impl.h"
+#include "Artifact_Installation/File_Installation_Handler.h"
+#include "Artifact_Installation/Http_Installation_Handler.h"
ACE_RCSID (DAnCE,
Node_Manager_Module,
@@ -402,18 +407,6 @@ DAnCE_NodeManager_Module::init (CORBA::ORB_ptr orb,
}
}
- // Make sure that we have only one Node Manager
- if (this->options_.node_managers_.size () != 1)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ")
- ACE_TEXT ("For now only one node manager creation is supported.\n")));
- return CORBA::Object::_nil ();
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ")
- ACE_TEXT ("DAnCE_NodeManager::run_main - creating NodeManager for node %C\n"),
- this->options_.node_managers_[0].c_str()));
-
// Parsing Node name and node manager ior file name
ACE_TString node_name = this->options_.node_managers_[0].c_str ();
ACE_TString node_file;
@@ -429,6 +422,44 @@ DAnCE_NodeManager_Module::init (CORBA::ORB_ptr orb,
node_name.c_str (),
node_file.c_str ()));
+ // load service modules for artifact installation service
+ load_artifact_installation_modules (argc, argv);
+
+ // Creating in process artifact installation service
+ DAnCE::ArtifactInstallation_Impl* installer;
+ ACE_NEW_RETURN (installer,
+ DAnCE::ArtifactInstallation_Impl (),
+ CORBA::Object::_nil ());
+ PortableServer::Servant_var<DAnCE::ArtifactInstallation_Impl> safe_installer (installer);
+
+ ACE_CString installer_oid_str = ACE_TEXT_ALWAYS_CHAR ((node_name + ACE_TEXT (".ArtifactInstaller")).c_str ());
+
+ // Registering servant in poa
+ PortableServer::ObjectId_var installer_oid =
+ PortableServer::string_to_ObjectId (installer_oid_str.c_str());
+ this->nm_poa_->activate_object_with_id (installer_oid, safe_installer._retn ());
+
+ CORBA::Object_var installer_object = this->nm_poa_->id_to_reference (installer_oid.in ());
+ this->installer_ = DAnCE::ArtifactInstallation::_narrow (installer_object.in ());
+
+ // Getting node manager ior
+ CORBA::String_var installer_ior = orb->object_to_string (installer_object.in ());
+
+ // Binding ior to IOR Table
+ adapter->bind (installer_oid_str.c_str (), installer_ior.in ());
+
+ // Make sure that we have only one Node Manager
+ if (this->options_.node_managers_.size () != 1)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ")
+ ACE_TEXT ("For now only one node manager creation is supported.\n")));
+ return CORBA::Object::_nil ();
+ }
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ")
+ ACE_TEXT ("DAnCE_NodeManager::run_main - creating NodeManager for node %C\n"),
+ this->options_.node_managers_[0].c_str()));
+
//Creating node manager servant
DAnCE::NodeManager_Impl * nm = 0;
if (this->nm_map_.find (node_name, nm) == -1)
@@ -442,6 +473,7 @@ DAnCE_NodeManager_Module::init (CORBA::ORB_ptr orb,
ACE_NEW_RETURN (nm,
DAnCE::NodeManager_Impl (orb,
this->root_poa_.in (),
+ this->installer_.in (),
ACE_TEXT_ALWAYS_CHAR (node_name.c_str()),
properties),
CORBA::Object::_nil ());
@@ -594,3 +626,30 @@ DAnCE_NodeManager_Module::create_nm_properties (DAnCE::Utility::PROPERTY_MAP &pr
}
}
+void
+DAnCE_NodeManager_Module::load_artifact_installation_modules (int argc, ACE_TCHAR *argv [])
+{
+ DAnCE::InstallationRepositoryManagerSvc
+ * dirms = ACE_Dynamic_Service<DAnCE::InstallationRepositoryManagerSvc>::instance ("InstallationRepositoryManager");
+
+ if (dirms)
+ {
+ dirms->init (argc, argv);
+ }
+
+ DAnCE::ArtifactInstallationHandlerSvc
+ * dfihs = ACE_Dynamic_Service<DAnCE::ArtifactInstallationHandlerSvc>::instance ("FileInstallationHandler");
+
+ if (dfihs)
+ {
+ dfihs->init (argc, argv);
+ }
+
+ DAnCE::ArtifactInstallationHandlerSvc
+ * dhihs = ACE_Dynamic_Service<DAnCE::ArtifactInstallationHandlerSvc>::instance ("HttpInstallationHandler");
+
+ if (dhihs)
+ {
+ dhihs->init (argc, argv);
+ }
+}
diff --git a/CIAO/DAnCE/NodeManager/Node_Manager_Module.h b/CIAO/DAnCE/NodeManager/Node_Manager_Module.h
index 915963c965d..6c51b7f2fab 100644
--- a/CIAO/DAnCE/NodeManager/Node_Manager_Module.h
+++ b/CIAO/DAnCE/NodeManager/Node_Manager_Module.h
@@ -31,6 +31,7 @@
#include "tao/PortableServer/PortableServer.h"
#include "orbsvcs/CosNamingC.h"
#include "DAnCE/DAnCE/DAnCE_Utility.h"
+#include "DAnCE/DAnCE_ArtifactInstallationC.h"
namespace DAnCE
{
@@ -88,6 +89,7 @@ class DAnCE_NodeManager_Module
void register_value_factories (void);
void create_poas (void);
void create_nm_properties (DAnCE::Utility::PROPERTY_MAP &props);
+ void load_artifact_installation_modules (int argc, ACE_TCHAR *argv []);
/// Here we store the servants.
typedef ACE_Map_Manager < ACE_TString,
@@ -101,6 +103,8 @@ class DAnCE_NodeManager_Module
PortableServer::POA_var root_poa_;
PortableServer::POA_var nm_poa_;
+
+ DAnCE::ArtifactInstallation_var installer_;
};
#include /**/ "ace/post.h"
diff --git a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp
index 2f034d9f115..9f9d52e71ce 100644
--- a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp
+++ b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.cpp
@@ -7,6 +7,8 @@
#include "Artifact_Installation_Impl.inl"
#endif
+#include "ace/Auto_Ptr.h"
+
namespace DAnCE
{
/*
@@ -14,6 +16,7 @@ namespace DAnCE
*/
ArtifactRegistry::ArtifactRegistry ()
+ : install_count_ (0)
{
}
@@ -82,15 +85,27 @@ namespace DAnCE
const char * plan_uuid,
const ::Deployment::ArtifactDeploymentDescription & artifact)
{
- ACE_GUARD_REACTION (TLOCK,
- handler_guard_,
- handler_lock_,
- throw Deployment::PlanError (
- plan_uuid,
- "ArtifactInstallation handler lock failed"));
-
std::string name = artifact.name.in ();
+ // allocate (and lock) the artifact registry for the given plan
+ ArtifactRegistry::Guard ar_guard (this->allocate_artifact_registry (plan_uuid, name));
+
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ ACE_TEXT ("installation request for plan %C, artifact %C\n"),
+ plan_uuid, name.c_str ()));
+
+ // check to see if artifact has already been previously installed
+ if (ar_guard->install_count () > 0)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ ACE_TEXT ("detected previously installed plan %C, artifact %C @ location %C\n"),
+ plan_uuid, name.c_str (), ar_guard->location ().c_str ()));
+
+ // just increment install count and return
+ ar_guard->increment_install_count ();
+ return;
+ }
+
// extract artifact properties
ArtifactInstallationHandler::TPropertyMap properties;
for (CORBA::ULong i=0; i < artifact.execParameter.length () ;++i)
@@ -118,7 +133,7 @@ namespace DAnCE
std::string location = artifact.location[loc_n].in ();
DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
- ACE_TEXT ("installation request for plan %C, artifact %C @ location[%u] %C\n"),
+ ACE_TEXT ("installation attempt for plan %C, artifact %C @ location[%u] %C\n"),
plan_uuid, name.c_str (), loc_n, location.c_str ()));
// parse protocol stack & path; URI = <protocol>:[<protocol>:[...]]//<path>
@@ -128,14 +143,59 @@ namespace DAnCE
// if no protocols specified no further action necessary
if (!prot_stack.empty ())
{
- // process protocol handlers
- this->install_i (plan_uuid,
- name,
- prot_stack,
- location,
- properties);
+ // process protocol handlers from last to first
+ while (!prot_stack.empty ())
+ {
+ std::string protocol = prot_stack.top ();
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ ACE_TEXT ("handling protocol %C for artifact %C @ location %C from plan %C\n"),
+ protocol.c_str (), name.c_str (), location.c_str (), plan_uuid));
+
+ // find protocol handler and install
+ if (!this->install_i (plan_uuid, protocol, location, properties))
+ {
+ DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ ACE_TEXT ("unknown protocol %C for artifact %C from plan %C\n"),
+ protocol.c_str (), name.c_str (), plan_uuid));
+
+ std::string err ("unknown installation protocol ");
+ err += protocol;
+ throw Deployment::PlanError (plan_uuid,
+ err.c_str ());
+ }
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ ACE_TEXT ("protocol %C installed artifact %C @ location %C from plan %C to location %C\n"),
+ protocol.c_str (), name.c_str (), location.c_str (), plan_uuid, location.c_str ()));
+
+ // register installed version for later removal
+ ar_guard->versions ().push_back (
+ ArtifactRegistry::Version(protocol, location));
+
+ // remove handled protocol
+ prot_stack.pop ();
+ }
+
+ // check property settings and clean installation intermediates if required
+ ArtifactInstallationProperties property_reader (properties);
+ const std::string& propval = property_reader.get_property (
+ ArtifactInstallationProperties::PROP_KEEP_INTERMEDIATES);
+ if (propval != "yes" && propval != "true")
+ {
+ this->remove_intermediates (plan_uuid, name, *ar_guard);
+ }
+ }
+ else
+ {
+ // just register the artifact without protocol
+ ar_guard->versions ().push_back (
+ ArtifactRegistry::Version(std::string(),location));
}
+ // we successfully installed the artifact so increment the install count
+ ar_guard->increment_install_count ();
+
DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
ACE_TEXT ("installed plan %C, artifact %C @ location %C\n"),
plan_uuid, name.c_str (), location.c_str ()));
@@ -144,13 +204,13 @@ namespace DAnCE
}
catch (Deployment::PlanError& ex)
{
- DANCE_DEBUG (3, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
+ DANCE_DEBUG (2, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install - ")
ACE_TEXT ("installation failed for plan %C, artifact %C @ location[%u] %C : %C\n"),
plan_uuid, name.c_str (), loc_n, artifact.location[loc_n].in (),
ex.reason.in ()));
// artifact installation failed for this location; clean up anything left behind
- this->remove (plan_uuid, name.c_str ());
+ this->remove_i (plan_uuid, name.c_str (), &ar_guard, false);
// if we have alternates we continue otherwise we fail finally
if (++loc_n >= artifact.location.length ())
@@ -211,100 +271,147 @@ namespace DAnCE
}
}
- void ArtifactInstallation_Impl::install_i (const std::string& plan_uuid,
- const std::string& name,
- TProtocolStack& protstack,
+ bool ArtifactInstallation_Impl::install_i (const std::string& plan_uuid,
+ const std::string& protocol,
std::string& location,
const TPropertyMap& properties)
{
- // process protocol handlers from last to first
- while (!protstack.empty ())
- {
- std::string protocol = protstack.top ();
-
- // find protocol handler
- THandlerMap::iterator ith = handlers_.find (protocol);
- if (ith == handlers_.end ())
- {
- DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install_i - ")
- ACE_TEXT ("unknown protocol %C for artifact %C from plan %C\n"),
- protocol.c_str (), name.c_str (), plan_uuid.c_str ()));
-
- std::string err ("unknown installation protocol ");
- err += protocol;
- throw Deployment::PlanError (plan_uuid.c_str (),
- err.c_str ());
- }
-
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install_i - ")
- ACE_TEXT ("handling protocol %C for artifact %C @ location %C from plan %C\n"),
- protocol.c_str (), name.c_str (), location.c_str (), plan_uuid.c_str ()));
+ ACE_GUARD_REACTION (TLOCK,
+ handler_guard_,
+ handler_lock_,
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ "ArtifactInstallation handler lock failed"));
+ // find protocol handler
+ THandlerMap::iterator ith = handlers_.find (protocol);
+ if (ith != handlers_.end ())
+ {
// activate protocol installation handler
// after successfull installation the protocol handler will update
// the location to the installed version
ith->second->install (plan_uuid, location, properties);
+ return true;
+ }
+ return false;
+ }
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::install_i - ")
- ACE_TEXT ("protocol %C installed artifact %C @ location %C from plan %C to location %C\n"),
- protocol.c_str (), name.c_str (), location.c_str (), plan_uuid.c_str (), location.c_str ()));
-
- // register installed version for later removal
- this->register_version (plan_uuid, name, protocol, location);
+ ArtifactRegistry*
+ ArtifactInstallation_Impl::allocate_artifact_registry (const std::string& plan_uuid,
+ const std::string& name)
+ {
+ ACE_GUARD_REACTION (TLOCK,
+ handler_guard_,
+ handler_lock_,
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ "ArtifactInstallation handler lock failed"));
- // remove handled protocol
- protstack.pop ();
+ // get existing or create new
+ ArtifactRegistry* ar = 0;
+ TArtifactsMap& plan_map = this->artifacts_[plan_uuid];
+ TArtifactsMap::iterator it_art = plan_map.find (name);
+ if (it_art == plan_map.end ())
+ {
+ ACE_NEW_NORETURN (ar, ArtifactRegistry ());
+ if (ar == 0)
+ {
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ "out of memory");
+ }
+ plan_map[name] = ar;
+ }
+ else
+ {
+ ar = it_art->second;
}
- ArtifactInstallationProperties property_reader (properties);
- const std::string& propval = property_reader.get_property (
- ArtifactInstallationProperties::PROP_KEEP_INTERMEDIATES);
- if (propval != "yes" && propval != "true")
+ // lock
+ if (ar->lock ().acquire () != 0)
{
- this->remove_intermediates (plan_uuid, name);
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ "ArtifactRegistry lock failed");
}
+ return ar;
}
- void ArtifactInstallation_Impl::register_version (const std::string& plan_uuid,
- const std::string& name,
- const std::string& protocol,
- const std::string& location)
+ ArtifactRegistry*
+ ArtifactInstallation_Impl::lock_artifact_registry (const std::string& plan_uuid,
+ const std::string& name)
{
ACE_GUARD_REACTION (TLOCK,
- artifact_guard_,
- artifact_lock_,
+ handler_guard_,
+ handler_lock_,
throw Deployment::PlanError (
plan_uuid.c_str (),
- "ArtifactInstallation artifact lock failed"));
+ "ArtifactInstallation handler lock failed"));
+
+ // get existing
+ TArtifactsMap& plan_map = this->artifacts_[plan_uuid];
+ TArtifactsMap::iterator it_art = plan_map.find (name);
+ if (it_art == plan_map.end ())
+ {
+ std::string err ("unknown artifact ");
+ err += name;
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ err.c_str ());
+ }
+ ArtifactRegistry* ar = it_art->second;
- this->artifacts_[plan_uuid][name].versions ().push_back (
- ArtifactRegistry::Version(protocol,location));
+ // lock
+ if (ar->lock ().acquire () != 0)
+ {
+ throw Deployment::PlanError (
+ plan_uuid.c_str (),
+ "ArtifactRegistry lock failed");
+ }
+ return ar;
}
void ArtifactInstallation_Impl::remove (
const char * plan_uuid,
const char * artifact_name)
{
- ACE_GUARD_REACTION (TLOCK,
- handler_guard_,
- handler_lock_,
- throw Deployment::PlanError (
- plan_uuid,
- "ArtifactInstallation handler lock failed"));
-
DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove - ")
- ACE_TEXT ("removing versions for artifact %C from plan %C\n"),
- artifact_name, plan_uuid));
+ ACE_TEXT ("uninstall request for artifact %C from plan %C\n"),
+ artifact_name, plan_uuid));
+
+ ArtifactRegistry* ar =
+ this->remove_artifact_registry (plan_uuid, artifact_name);
+
+ if (ar == 0)
+ return; // nothing to do yet
+
+ this->remove_i (plan_uuid, artifact_name, ar);
+ }
+
+ void ArtifactInstallation_Impl::remove_all (const char * plan_uuid)
+ {
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_all - ")
+ ACE_TEXT ("removing versions for plan %C\n"),
+ plan_uuid));
- ArtifactRegistry artifact_reg;
- this->remove_artifact_registry (plan_uuid, artifact_name, artifact_reg);
+ // this method removes all installed artifacts irrespective of
+ // install count!
- this->remove_i (plan_uuid, artifact_name, artifact_reg);
+ TArtifactsMap artifacts_map;
+ this->remove_artifacts_map (plan_uuid, artifacts_map);
+
+ for (TArtifactsMap::iterator ita = artifacts_map.begin ();
+ ita != artifacts_map.end ();
+ ++ita)
+ {
+ this->remove_i (plan_uuid, ita->first.c_str (), ita->second);
+ }
}
void ArtifactInstallation_Impl::remove_intermediates (
const std::string& plan_uuid,
- const std::string& artifact_name)
+ const std::string& artifact_name,
+ ArtifactRegistry& artifact_reg)
{
ACE_GUARD_REACTION (TLOCK,
handler_guard_,
@@ -313,11 +420,10 @@ namespace DAnCE
plan_uuid.c_str (),
"ArtifactInstallation handler lock failed"));
- DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove - ")
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_intermediates - ")
ACE_TEXT ("removing intermediate versions for artifact %C from plan %C\n"),
artifact_name.c_str (), plan_uuid.c_str ()));
- ArtifactRegistry& artifact_reg = this->get_artifact_registry (plan_uuid, artifact_name);
ArtifactRegistry::TVersions& versions = artifact_reg.versions ();
while (versions.size () > 1)
{
@@ -325,7 +431,7 @@ namespace DAnCE
THandlerMap::iterator ith = handlers_.find (versions.front ().protocol_);
if (ith == handlers_.end ())
{
- DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
+ DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_intermediates - ")
ACE_TEXT ("cannot find protocol %C to remove version ")
ACE_TEXT ("@ location %C for artifact %C from plan %C\n"),
versions.front ().protocol_.c_str (), versions.front ().location_.c_str (),
@@ -333,7 +439,7 @@ namespace DAnCE
}
else
{
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_intermediates - ")
ACE_TEXT ("removing version of protocol %C @ %C for artifact %C from plan %C\n"),
versions.front ().protocol_.c_str (), versions.front ().location_.c_str (),
artifact_name.c_str (), plan_uuid.c_str ()));
@@ -345,37 +451,9 @@ namespace DAnCE
}
void ArtifactInstallation_Impl::remove_i (const char * plan_uuid,
- const char * artifact_name,
- ArtifactRegistry& artifact_reg)
- {
- for (ArtifactRegistry::TVersions::iterator iti =
- artifact_reg.versions ().begin ();
- iti != artifact_reg.versions ().end ();
- ++iti)
- {
- // find protocol handler
- THandlerMap::iterator ith = handlers_.find (iti->protocol_);
- if (ith == handlers_.end ())
- {
- DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
- ACE_TEXT ("cannot find protocol %C to remove version ")
- ACE_TEXT ("@ location %C for artifact %C from plan %C\n"),
- iti->protocol_.c_str (), iti->location_.c_str (),
- artifact_name, plan_uuid));
- }
- else
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
- ACE_TEXT ("removing version of protocol %C @ %C for artifact %C from plan %C\n"),
- iti->protocol_.c_str (), iti->location_.c_str (),
- artifact_name, plan_uuid));
-
- ith->second->remove (plan_uuid, iti->location_);
- }
- }
- }
-
- void ArtifactInstallation_Impl::remove_all (const char * plan_uuid)
+ const char * artifact_name,
+ ArtifactRegistry* artifact_reg,
+ bool do_delete)
{
ACE_GUARD_REACTION (TLOCK,
handler_guard_,
@@ -384,60 +462,66 @@ namespace DAnCE
plan_uuid,
"ArtifactInstallation handler lock failed"));
- DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_all - ")
- ACE_TEXT ("removing versions for plan %C\n"),
- plan_uuid));
-
- TArtifactsMap artifacts_map;
- this->remove_artifacts_map (plan_uuid, artifacts_map);
+ ACE_Auto_Ptr<ArtifactRegistry> safe_artifact_reg (do_delete ? artifact_reg : 0);
- for (TArtifactsMap::iterator ita = artifacts_map.begin ();
- ita != artifacts_map.end ();
- ++ita)
- {
- this->remove_i (plan_uuid, ita->first.c_str (), ita->second);
- }
- }
-
- void ArtifactInstallation_Impl::remove_artifact_registry (
- const std::string& plan_uuid,
- const std::string& name,
- ArtifactRegistry& artifact_reg)
- {
- ACE_GUARD_REACTION (TLOCK,
- artifact_guard_,
- artifact_lock_,
- throw Deployment::PlanError (
- plan_uuid.c_str (),
- "ArtifactInstallation artifact lock failed"));
-
- TArtifactsRegistry::iterator it_reg = this->artifacts_.find (plan_uuid);
- if (it_reg != this->artifacts_.end ())
+ for (ArtifactRegistry::TVersions::iterator iti =
+ artifact_reg->versions ().begin ();
+ iti != artifact_reg->versions ().end ();
+ ++iti)
{
- TArtifactsMap::iterator it_art = it_reg->second.find (name);
- if (it_art != it_reg->second.end ())
+ // in case no protocol registered there is nothing to remove
+ if (!iti->protocol_.empty ())
{
- artifact_reg = it_art->second;
- it_reg->second.erase (it_art);
+ // find protocol handler
+ THandlerMap::iterator ith = handlers_.find (iti->protocol_);
+ if (ith == handlers_.end ())
+ {
+ DANCE_DEBUG (1, (LM_ERROR, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
+ ACE_TEXT ("cannot find protocol %C to remove version ")
+ ACE_TEXT ("@ location %C for artifact %C from plan %C\n"),
+ iti->protocol_.c_str (), iti->location_.c_str (),
+ artifact_name, plan_uuid));
+ }
+ else
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove_i - ")
+ ACE_TEXT ("removing version of protocol %C @ %C for artifact %C from plan %C\n"),
+ iti->protocol_.c_str (), iti->location_.c_str (),
+ artifact_name, plan_uuid));
+
+ ith->second->remove (plan_uuid, iti->location_);
+ }
}
}
}
- ArtifactRegistry& ArtifactInstallation_Impl::get_artifact_registry (
+ ArtifactRegistry* ArtifactInstallation_Impl::remove_artifact_registry (
const std::string& plan_uuid,
const std::string& name)
{
- TArtifactsRegistry::iterator it_reg = this->artifacts_.find (plan_uuid);
- if (it_reg != this->artifacts_.end ())
+ // lock the artifact registry for the given plan
+ ArtifactRegistry::Guard ar_guard (this->lock_artifact_registry (plan_uuid, name));
+
+ // check to see if artifact has already been previously installed
+ if (ar_guard->install_count () > 0)
{
- TArtifactsMap::iterator it_art = it_reg->second.find (name);
- if (it_art != it_reg->second.end ())
+ // decrement install count
+ ar_guard->decrement_install_count ();
+ // only if we reach 0, we really remove artifacts
+ if (ar_guard->install_count () == 0)
{
- return it_art->second;
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT("ArtifactInstallation_Impl::remove - ")
+ ACE_TEXT ("removing versions for artifact %C from plan %C\n"),
+ name.c_str (), plan_uuid.c_str ()));
+
+ // erase the artifact registry
+ this->artifacts_[plan_uuid].erase (name);
+
+ ArtifactRegistry* ar = &ar_guard;
+ return ar;
}
}
- throw Deployment::PlanError (plan_uuid.c_str (),
- "corrupt artifact registry");
+ return 0;
}
void ArtifactInstallation_Impl::remove_artifacts_map (
@@ -445,11 +529,11 @@ namespace DAnCE
TArtifactsMap& artifacts_map)
{
ACE_GUARD_REACTION (TLOCK,
- artifact_guard_,
- artifact_lock_,
+ handler_guard_,
+ handler_lock_,
throw Deployment::PlanError (
plan_uuid.c_str (),
- "ArtifactInstallation artifact lock failed"));
+ "ArtifactInstallation handler lock failed"));
TArtifactsRegistry::iterator it_reg = this->artifacts_.find (plan_uuid);
if (it_reg != this->artifacts_.end ())
@@ -463,7 +547,7 @@ namespace DAnCE
const char * uuid,
const char * artifact_name)
{
- ACE_GUARD_RETURN (TLOCK, artifact_guard_, artifact_lock_, 0);
+ ACE_GUARD_RETURN (TLOCK, guard_, handler_lock_, 0);
TArtifactsRegistry::iterator it_reg = this->artifacts_.find (uuid);
if (it_reg != this->artifacts_.end ())
@@ -471,7 +555,7 @@ namespace DAnCE
TArtifactsMap::iterator it_art = it_reg->second.find (artifact_name);
if (it_art != it_reg->second.end ())
{
- return CORBA::string_dup (it_art->second.location ().c_str ());
+ return CORBA::string_dup (it_art->second->location ().c_str ());
}
}
return 0;
diff --git a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h
index 0a7b895e78d..8d4242022e7 100644
--- a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h
+++ b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.h
@@ -15,6 +15,7 @@
#include "ace/Service_Object.h"
#include "ace/Recursive_Thread_Mutex.h"
+#include "ace/Synch.h"
#include "DAnCE/DAnCE_ArtifactInstallationS.h"
#include "DAnCE_Artifact_Installation_export.h"
#include "DAnCE_Artifact_Installation_Handler.h"
@@ -27,6 +28,7 @@ namespace DAnCE
class ArtifactRegistry
{
public:
+ typedef ACE_MT_SYNCH::MUTEX TLOCK;
struct Version
{
std::string protocol_;
@@ -50,7 +52,31 @@ namespace DAnCE
TVersions& versions ();
const TVersions& versions () const;
+ ulong install_count () const;
+ void increment_install_count ();
+ void decrement_install_count ();
+
+ TLOCK& lock ();
+
+ class Guard
+ {
+ public:
+ Guard (ArtifactRegistry* ar);
+ ~Guard ();
+
+ ArtifactRegistry* operator ->(void);
+
+ ArtifactRegistry& operator *(void);
+
+ ArtifactRegistry* operator &(void);
+
+ private:
+ ArtifactRegistry* arp_;
+ };
+
private:
+ TLOCK lock_;
+ u_long install_count_;
TVersions versions_;
};
@@ -58,7 +84,7 @@ namespace DAnCE
: public POA_DAnCE::ArtifactInstallation
{
public:
- typedef ACE_Recursive_Thread_Mutex TLOCK;
+ typedef ACE_MT_SYNCH::MUTEX TLOCK;
typedef ArtifactInstallationHandler::TPropertyMap TPropertyMap;
ArtifactInstallation_Impl ();
@@ -84,45 +110,42 @@ namespace DAnCE
// key is artifact name
typedef std::map<std::string,
- ArtifactRegistry> TArtifactsMap;
+ ArtifactRegistry*> TArtifactsMap;
// key is plan uuid
typedef std::map<std::string,
TArtifactsMap> TArtifactsRegistry;
+ ArtifactRegistry* allocate_artifact_registry (const std::string& plan_uuid,
+ const std::string& name);
+
+ ArtifactRegistry* lock_artifact_registry (const std::string& plan_uuid,
+ const std::string& name);
+
void parse_uri (const char* plan_uuid,
std::string& location,
TProtocolStack& protstack);
- void install_i (const std::string& plan_uuid,
- const std::string& name,
- TProtocolStack& protstack,
+ bool install_i (const std::string& plan_uuid,
+ const std::string& protocol,
std::string& location,
const TPropertyMap& properties);
- void register_version (const std::string& plan_uuid,
- const std::string& name,
- const std::string& protocol,
- const std::string& location);
-
void remove_i (const char * plan_uuid,
const char * artifact_name,
- ArtifactRegistry& artifact_reg);
+ ArtifactRegistry* artifact_reg,
+ bool do_delete = true);
void remove_intermediates (const std::string& plan_uuid,
- const std::string& artifact_name);
-
- void remove_artifact_registry (const std::string& plan_uuid,
- const std::string& name,
- ArtifactRegistry& artifact_reg);
+ const std::string& artifact_name,
+ ArtifactRegistry& artifact_reg);
- ArtifactRegistry& get_artifact_registry (const std::string& plan_uuid,
- const std::string& name);
+ ArtifactRegistry* remove_artifact_registry (const std::string& plan_uuid,
+ const std::string& name);
void remove_artifacts_map (const std::string& plan_uuid,
TArtifactsMap& artifacts_map);
TArtifactsRegistry artifacts_;
- TLOCK artifact_lock_;
public:
diff --git a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl
index b356445a921..5267846af2c 100644
--- a/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl
+++ b/CIAO/DAnCE/tools/Artifact_Installation/Artifact_Installation_Impl.inl
@@ -34,6 +34,7 @@ namespace DAnCE
ArtifactRegistry& ArtifactRegistry::operator =(const ArtifactRegistry& ar)
{
this->versions_ = ar.versions ();
+ this->install_count_ = ar.install_count ();
return *this;
}
@@ -45,13 +46,71 @@ namespace DAnCE
ACE_INLINE
ArtifactRegistry::TVersions& ArtifactRegistry::versions ()
- {
- return this->versions_;
- }
+ {
+ return this->versions_;
+ }
ACE_INLINE
const ArtifactRegistry::TVersions& ArtifactRegistry::versions () const
{
return this->versions_;
}
+
+ ACE_INLINE
+ ulong ArtifactRegistry::install_count () const
+ {
+ return this->install_count_;
+ }
+
+ ACE_INLINE
+ void ArtifactRegistry::increment_install_count ()
+ {
+ ++this->install_count_;
+ }
+
+ ACE_INLINE
+ void ArtifactRegistry::decrement_install_count ()
+ {
+ --this->install_count_;
+ }
+
+ ACE_INLINE
+ ArtifactRegistry::TLOCK& ArtifactRegistry::lock ()
+ {
+ return this->lock_;
+ }
+
+ ACE_INLINE
+ ArtifactRegistry::Guard::Guard (ArtifactRegistry* ar)
+ : arp_ (ar)
+ {
+ }
+
+ ACE_INLINE
+ ArtifactRegistry::Guard::~Guard ()
+ {
+ if (this->arp_)
+ {
+ this->arp_->lock ().release ();
+ }
+ this->arp_ = 0;
+ }
+
+ ACE_INLINE
+ ArtifactRegistry* ArtifactRegistry::Guard::operator ->(void)
+ {
+ return this->arp_;
+ }
+
+ ACE_INLINE
+ ArtifactRegistry* ArtifactRegistry::Guard::operator &(void)
+ {
+ return this->arp_;
+ }
+
+ ACE_INLINE
+ ArtifactRegistry& ArtifactRegistry::Guard::operator *(void)
+ {
+ return *this->arp_;
+ }
}