summaryrefslogtreecommitdiff
path: root/CIAO/ciao/Deployment/Handlers
diff options
context:
space:
mode:
authormcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-10-20 09:46:10 +0000
committermcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-10-20 09:46:10 +0000
commit02686f8d5108580e8a3d56bfe9b124405fdedd18 (patch)
tree0426ac218b7505e1c06dbf5ff8d2b10144d7ce75 /CIAO/ciao/Deployment/Handlers
parentb2334408ebeffc6686b1f976247926df8411caec (diff)
downloadATCD-02686f8d5108580e8a3d56bfe9b124405fdedd18.tar.gz
Tue Oct 20 09:30:13 UTC 2011 Martin Corino <mcorino@remedy.nl>
Merged changes from Remedy work branch.
Diffstat (limited to 'CIAO/ciao/Deployment/Handlers')
-rw-r--r--CIAO/ciao/Deployment/Handlers/CIAO_State.cpp173
-rw-r--r--CIAO/ciao/Deployment/Handlers/CIAO_State.h11
-rw-r--r--CIAO/ciao/Deployment/Handlers/Connection_Handler.cpp79
-rw-r--r--CIAO/ciao/Deployment/Handlers/Connection_Handler.h5
4 files changed, 218 insertions, 50 deletions
diff --git a/CIAO/ciao/Deployment/Handlers/CIAO_State.cpp b/CIAO/ciao/Deployment/Handlers/CIAO_State.cpp
index 97c58878251..cad4f3049a5 100644
--- a/CIAO/ciao/Deployment/Handlers/CIAO_State.cpp
+++ b/CIAO/ciao/Deployment/Handlers/CIAO_State.cpp
@@ -20,6 +20,11 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::add_container");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->container_mutex_,
+ CORBA::NO_RESOURCES ());
+
if (CIAO_debug_level && // Let's only perform this lookup if we have logging enabled.
this->containers_.find (id) != this->containers_.end ())
{
@@ -35,6 +40,12 @@ namespace CIAO
Deployment_State::remove_container (const char *id)
{
CIAO_TRACE ("Deployment_State::remove_container");
+
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->container_mutex_,
+ CORBA::NO_RESOURCES ());
+
CONTAINERS::iterator pos = this->containers_.find (id);
if (pos != this->containers_.end ())
@@ -46,12 +57,15 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::fetch_container");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->container_mutex_,
+ CORBA::NO_RESOURCES ());
+
CONTAINERS::iterator pos = this->containers_.find (id);
if (pos == this->containers_.end ())
- {
- return CIAO::Container::_nil ();
- }
+ return CIAO::Container::_nil ();
return CIAO::Container::_duplicate (pos->second.in ());
}
@@ -63,33 +77,58 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::add_home");
- if (CIAO_debug_level && // Let's only perform this lookup if we have logging enabled.
- this->homes_.find (id) != this->homes_.end ())
- {
- CIAO_ERROR (1, (LM_WARNING, CLINFO
- "Deployment_State::add_home - "
- "Warning: Attempting to add duplicate home reference\n"));
- }
-
- this->instance_container_[id] = cont_id;
- this->homes_[id] = Components::CCMHome::_duplicate (home);
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->home_mutex_,
+ CORBA::NO_RESOURCES ());
+
+ if (CIAO_debug_level && // Let's only perform this lookup if we have logging enabled.
+ this->homes_.find (id) != this->homes_.end ())
+ {
+ CIAO_ERROR (1, (LM_WARNING, CLINFO
+ "Deployment_State::add_home - "
+ "Warning: Attempting to add duplicate home reference\n"));
+ }
+ this->homes_[id] = Components::CCMHome::_duplicate (home);
+ }
+
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->instance_container_mutex_,
+ CORBA::NO_RESOURCES ());
+ this->instance_container_[id] = cont_id;
+ }
}
void
Deployment_State::remove_home (const char *id)
{
CIAO_TRACE ("Deployment_State::remove_home");
-
- HOMES::iterator pos = this->homes_.find (id);
-
- if (pos != this->homes_.end ())
- this->homes_.erase (pos);
-
- INSTANCE_CONTAINER::iterator cont =
- this->instance_container_.find (id);
-
- if (cont != this->instance_container_.end ())
- this->instance_container_.erase (cont);
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->home_mutex_,
+ CORBA::NO_RESOURCES ());
+
+ HOMES::iterator pos = this->homes_.find (id);
+
+ if (pos != this->homes_.end ())
+ this->homes_.erase (pos);
+ }
+
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->instance_container_mutex_,
+ CORBA::NO_RESOURCES ());
+ INSTANCE_CONTAINER::iterator cont =
+ this->instance_container_.find (id);
+
+ if (cont != this->instance_container_.end ())
+ this->instance_container_.erase (cont);
+ }
}
Components::CCMHome_ptr
@@ -97,9 +136,16 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::fetch_home");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->home_mutex_,
+ CORBA::NO_RESOURCES ());
+
HOMES::iterator pos = this->homes_.find (id);
- if (pos == this->homes_.end ()) return Components::CCMHome::_nil ();
+ if (pos == this->homes_.end ())
+ return Components::CCMHome::_nil ();
+
return Components::CCMHome::_duplicate (pos->second.in ());
}
@@ -110,16 +156,28 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::add_component");
- if (CIAO_debug_level && // Let's only perform this lookup if we have logging enabled.
- this->components_.find (id) != this->components_.end ())
- {
- CIAO_ERROR (1, (LM_WARNING, CLINFO
- "Deployment_State::add_component - "
- "Warning: Attempting to add duplicate component reference\n"));
- }
-
- this->instance_container_[id] = cont_id;
- this->components_[id] = Components::CCMObject::_duplicate (component);
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->component_mutex_,
+ CORBA::NO_RESOURCES ());
+
+ if (CIAO_debug_level && // Let's only perform this lookup if we have logging enabled.
+ this->components_.find (id) != this->components_.end ())
+ {
+ CIAO_ERROR (1, (LM_WARNING, CLINFO
+ "Deployment_State::add_component - "
+ "Warning: Attempting to add duplicate component reference\n"));
+ }
+ this->components_[id] = Components::CCMObject::_duplicate (component);
+ }
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->instance_container_mutex_,
+ CORBA::NO_RESOURCES ());
+ this->instance_container_[id] = cont_id;
+ }
}
void
@@ -127,16 +185,28 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::remove_component");
- COMPONENTS::iterator pos = this->components_.find (id);
-
- if (pos != this->components_.end ())
- this->components_.erase (pos);
-
- INSTANCE_CONTAINER::iterator cont =
- this->instance_container_.find (id);
-
- if (cont != this->instance_container_.end ())
- this->instance_container_.erase (cont);
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->component_mutex_,
+ CORBA::NO_RESOURCES ());
+ COMPONENTS::iterator pos = this->components_.find (id);
+
+ if (pos != this->components_.end ())
+ this->components_.erase (pos);
+ }
+
+ {
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->instance_container_mutex_,
+ CORBA::NO_RESOURCES ());
+ INSTANCE_CONTAINER::iterator cont =
+ this->instance_container_.find (id);
+
+ if (cont != this->instance_container_.end ())
+ this->instance_container_.erase (cont);
+ }
}
Components::CCMObject_ptr
@@ -144,12 +214,15 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::fetch_component");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->component_mutex_,
+ CORBA::NO_RESOURCES ());
+
COMPONENTS::iterator pos = this->components_.find (id);
if (pos == this->components_.end ())
- {
- return Components::CCMObject::_nil ();
- }
+ return Components::CCMObject::_nil ();
return Components::CCMObject::_duplicate (pos->second.in ());
}
@@ -159,6 +232,10 @@ namespace CIAO
{
CIAO_TRACE ("Deployment_State::instance_to_container");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->instance_container_mutex_,
+ CORBA::NO_RESOURCES ());
INSTANCE_CONTAINER::const_iterator cont =
this->instance_container_.find (id);
diff --git a/CIAO/ciao/Deployment/Handlers/CIAO_State.h b/CIAO/ciao/Deployment/Handlers/CIAO_State.h
index cb1d81f7ba3..a63a3c90dd1 100644
--- a/CIAO/ciao/Deployment/Handlers/CIAO_State.h
+++ b/CIAO/ciao/Deployment/Handlers/CIAO_State.h
@@ -56,25 +56,36 @@ namespace CIAO
Connection_Handler connection_handler;
private:
+ /// Container administration
typedef std::map < std::string,
CIAO::Container_var > CONTAINERS;
CONTAINERS containers_;
+ TAO_SYNCH_MUTEX container_mutex_;
+
typedef std::map < std::string, std::string > INSTANCE_CONTAINER;
/// maps instance ids to containers.
INSTANCE_CONTAINER instance_container_;
+ TAO_SYNCH_MUTEX instance_container_mutex_;
+
+ /// Homes administration
typedef std::map < std::string,
Components::CCMHome_var > HOMES;
HOMES homes_;
+ TAO_SYNCH_MUTEX home_mutex_;
+
+ /// Components administration
typedef std::map < std::string,
Components::CCMObject_var > COMPONENTS;
COMPONENTS components_;
+
+ TAO_SYNCH_MUTEX component_mutex_;
};
typedef ACE_Singleton <Deployment_State,
diff --git a/CIAO/ciao/Deployment/Handlers/Connection_Handler.cpp b/CIAO/ciao/Deployment/Handlers/Connection_Handler.cpp
index 2e5c0a2e614..a2efc2e6d76 100644
--- a/CIAO/ciao/Deployment/Handlers/Connection_Handler.cpp
+++ b/CIAO/ciao/Deployment/Handlers/Connection_Handler.cpp
@@ -276,7 +276,7 @@ namespace CIAO
}
else
{
- //only because of the receptacle is an external endpoint
+ //only because the receptacle is an external endpoint
this->disconnect_non_local (conn, conn.externalReference[0].portName.in ());
}
break;
@@ -320,7 +320,7 @@ namespace CIAO
// pass through
throw;
}
- // Since DANCE shutdown the Locality managers simultaniously,
+ // Since DANCE shuts down the Locality managers simultaniously,
// it could be that one locality manager is shutdown while the
// other wants to disconnect from this locality manager. Therefor
// we catch an OBJECT_NOT_EXIST, TRANSIENT and a COMM_FAILURE at this point
@@ -436,6 +436,10 @@ namespace CIAO
::Components::Cookie_var cookie = provided->connect (conn.externalReference[0].portName.in (),
facet.in ());
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), facet.in ());
+#endif
+
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_non_local_facet - "
"Connection <%C> successfully established.\n",
@@ -509,6 +513,10 @@ namespace CIAO
::Components::Cookie_var cookie = receptacle->connect (endpoint.portName.in (),
provided.in ());
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), provided.in ());
+#endif
+
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_non_local_receptacle - "
"Connection <%C> successfully established.\n",
@@ -597,6 +605,9 @@ namespace CIAO
}
Components::Cookie_var cookie = publisher->subscribe (endpoint.portName.in (),
event.in ());
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), publisher.in());
+#endif
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_publisher - "
@@ -704,6 +715,10 @@ namespace CIAO
conn.externalReference[0].portName.in ()));
}
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), event.in());
+#endif
+
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_consumer - "
"Connection <%C> successfully established.\n",
@@ -775,6 +790,9 @@ namespace CIAO
emitter->connect_consumer (endpoint.portName.in (),
event.in ());
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), emitter.in());
+#endif
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_emitter - "
@@ -796,9 +814,14 @@ namespace CIAO
CIAO_TRACE ("Connection_Handler::disconnect_non_local");
::Components::CCMObject_var obj = this->get_ccm_object (conn.name.in ());
+ CIAO_DEBUG (6, (LM_DEBUG, CLINFO
+ "Connection_Handler::disconnect_non_local - "
+ "About to disconnect <%C>\n",
+ conn.name.in()));
::CORBA::Object_var safe_tmp =
obj->disconnect (port_name,
this->get_cookie (conn.name.in ()));
+
this->remove_cookie (conn.name.in ());
}
@@ -972,6 +995,9 @@ namespace CIAO
facet_endpoint.portName.in (),
receptacle,
receptacle_endpoint.portName.in ());
+#if defined (CIAO_PRE_ESTABLISH_CONNECTIONS)
+ this->validate_connection(conn.name.in (), facet);
+#endif
CIAO_DEBUG (5, (LM_INFO, CLINFO
"Connection_Handler::connect_local_port - "
"Connected local port <%C>:<%C> to <%C>:<%C>\n",
@@ -1062,6 +1088,36 @@ namespace CIAO
receptacle_endpoint.portName.in ()));
}
+ void
+ Connection_Handler::validate_connection (const char * conn,
+ ::CORBA::Object_ptr obj)
+ {
+ CIAO_TRACE ("Connection_Handler::validate_connection");
+ try
+ {
+ if (!::CORBA::is_nil (obj))
+ {
+ ::CORBA::PolicyList_var pl;
+ if (obj->_validate_connection (pl.out ()))
+ {
+ CIAO_DEBUG (6, (LM_DEBUG, CLINFO "Connection_Handler::validate_connection - "
+ "Succesfully validated connection <%C>. Connection has been pre-established.\n",
+ conn));
+ }
+ else
+ {
+ CIAO_ERROR (1, (LM_ERROR, CLINFO "Connection_Handler::validate_connection - "
+ "Failed to pre-establish a connection <%C>.\n",
+ conn));
+ }
+ }
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception("Connection_Handler::validate_connection");
+ }
+ }
+
bool
Connection_Handler::is_local_connection (const ::Deployment::PlanConnectionDescription &conn)
{
@@ -1085,6 +1141,11 @@ namespace CIAO
{
CIAO_TRACE ("Connection_Handler::insert_cookie");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->cookies_mutex_,
+ CORBA::NO_RESOURCES ());
+
std::pair <std::string, CONNECTION_INFO> value_to_insert (connection_name,
conn_info);
std::pair<COOKIES::iterator, bool> ret = this->cookies_.insert (value_to_insert);
@@ -1112,6 +1173,11 @@ namespace CIAO
{
CIAO_TRACE ("Connection_Handler::remove_cookie");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->cookies_mutex_,
+ CORBA::NO_RESOURCES ());
+
COOKIES::iterator it = this->cookies_.find (connection_name);
if (it == this->cookies_.end ())
{
@@ -1134,6 +1200,11 @@ namespace CIAO
{
CIAO_TRACE ("Connection_Handler::get_cookie");
+ ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
+ guard,
+ this->cookies_mutex_,
+ CORBA::NO_RESOURCES ());
+
COOKIES::iterator it = this->cookies_.find (connection_name);
if (it == this->cookies_.end ())
{
@@ -1157,6 +1228,8 @@ namespace CIAO
::Components::CCMObject_ptr
Connection_Handler::get_ccm_object (const char * connection_name)
{
+ CIAO_TRACE ("Connection_Handler::get_ccm_object");
+
COOKIES::iterator it = this->cookies_.find (connection_name);
if (it == this->cookies_.end ())
{
@@ -1167,6 +1240,7 @@ namespace CIAO
throw ::Deployment::InvalidConnection (connection_name,
"Unable to find correct cookie");
}
+
::Components::CCMObject_var ret = it->second.second;
if (::CORBA::is_nil (ret.in ()))
{
@@ -1183,6 +1257,7 @@ namespace CIAO
::CORBA::ULong
Connection_Handler::retrieve_endpoint (const ::Deployment::PlanConnectionDescription &conn)
{
+ CIAO_TRACE ("Connection_Handler::retrieve_endpoint");
if (conn.internalEndpoint.length () == 0)
{
CIAO_ERROR (1, (LM_ERROR, CLINFO
diff --git a/CIAO/ciao/Deployment/Handlers/Connection_Handler.h b/CIAO/ciao/Deployment/Handlers/Connection_Handler.h
index 8238f2fe9a6..de4d22a7436 100644
--- a/CIAO/ciao/Deployment/Handlers/Connection_Handler.h
+++ b/CIAO/ciao/Deployment/Handlers/Connection_Handler.h
@@ -96,6 +96,9 @@ namespace CIAO
bool is_local_connection (const ::Deployment::PlanConnectionDescription &conn);
+ void validate_connection (const char * conn,
+ ::CORBA::Object_ptr obj);
+
::CORBA::ULong retrieve_endpoint (const ::Deployment::PlanConnectionDescription &conn);
typedef std::pair < ::Components::Cookie_var,
@@ -113,6 +116,8 @@ namespace CIAO
::Components::CCMObject_ptr get_ccm_object (const char * connection_name);
COOKIES cookies_;
+
+ TAO_SYNCH_MUTEX cookies_mutex_;
};
}
#endif