summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp96
-rw-r--r--cpp/src/IceGrid/AdminI.cpp40
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp28
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.h5
-rw-r--r--cpp/src/IceGrid/DescriptorParser.cpp10
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp4
-rw-r--r--cpp/src/IceGrid/Internal.ice3
-rw-r--r--cpp/src/IceGrid/NodeI.cpp38
-rw-r--r--cpp/src/IceGrid/NodeI.h4
-rw-r--r--cpp/src/IceGrid/ServerI.cpp7
-rw-r--r--cpp/src/IceGrid/ServerI.h1
11 files changed, 134 insertions, 102 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 16619378bdd..31219486211 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -86,45 +86,28 @@ Ice::ObjectAdapterI::activate()
Ice::voidMemFun(&IncomingConnectionFactory::activate));
}
- //
- // We must get and call on the locator registry outside the thread
- // synchronization to avoid deadlocks. (we can't make remote calls
- // within the OA synchronization because the remote call will
- // indirectly call isLocal() on this OA with the OA factory
- // locked).
- //
- LocatorRegistryPrx locatorRegistry;
- if(locatorInfo)
- {
- locatorRegistry = locatorInfo->getLocatorRegistry();
- }
-
- if(registerProcess)
- {
- if(!locatorRegistry)
- {
- Warning out(communicator->getLogger());
- out << "object adapter `" << _name << "' cannot register the process without a locator registry";
- registerProcess = false;
- }
- else if(serverId.empty())
- {
- Warning out(communicator->getLogger());
- out << "object adapter `" << _name << "' cannot register the process without a value for Ice.ServerId";
- registerProcess = false;
- }
- }
-
- if(locatorRegistry)
+ if(registerProcess || !_id.empty())
{
//
- // TODO: This might throw if we can't connect to the
- // locator. Shall we raise a special exception for the
- // activate operation instead of a non obvious network
- // exception?
+ // We must get and call on the locator registry outside the thread
+ // synchronization to avoid deadlocks. (we can't make remote calls
+ // within the OA synchronization because the remote call will
+ // indirectly call isLocal() on this OA with the OA factory
+ // locked).
//
-
- if(!_id.empty())
+ LocatorRegistryPrx locatorRegistry;
+ if(locatorInfo)
+ {
+ //
+ // TODO: This might throw if we can't connect to the
+ // locator. Shall we raise a special exception for the
+ // activate operation instead of a non obvious network
+ // exception?
+ //
+ locatorRegistry = locatorInfo->getLocatorRegistry();
+ }
+
+ if(locatorRegistry && !_id.empty())
{
try
{
@@ -163,26 +146,39 @@ Ice::ObjectAdapterI::activate()
ex.id = _id;
throw ex;
}
- }
+ }
- if(registerProcess)
- {
- try
+ if(registerProcess)
+ {
+ if(!locatorRegistry)
{
- ProcessPtr servant = new ProcessI(communicator);
- Ice::ObjectPrx proxy = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
- locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(proxy));
+ Warning out(communicator->getLogger());
+ out << "object adapter `" << _name << "' cannot register the process without a locator registry";
}
- catch(const ObjectAdapterDeactivatedException&)
+ else if(serverId.empty())
{
- // IGNORE: The object adapter is already inactive.
+ Warning out(communicator->getLogger());
+ out << "object adapter `" << _name << "' cannot register the process without a value for Ice.ServerId";
}
- catch(const ServerNotFoundException&)
+ else
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "server";
- ex.id = serverId;
- throw ex;
+ try
+ {
+ ProcessPtr servant = new ProcessI(communicator);
+ Ice::ObjectPrx proxy = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
+ locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(proxy));
+ }
+ catch(const ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE: The object adapter is already inactive.
+ }
+ catch(const ServerNotFoundException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "server";
+ ex.id = serverId;
+ throw ex;
+ }
}
}
}
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp
index eb262971728..1e3a31f8b4b 100644
--- a/cpp/src/IceGrid/AdminI.cpp
+++ b/cpp/src/IceGrid/AdminI.cpp
@@ -312,28 +312,28 @@ AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
{
ApplicationHelper helper(_database->getApplicationDescriptor(name));
DistributionDescriptor appDistrib;
- map<string, DistributionDescriptorDict> nodeDistrib;
- helper.getDistributions(appDistrib, nodeDistrib);
+ vector<string> nodes;
+ helper.getDistributions(appDistrib, nodes);
- if(nodeDistrib.empty())
+ if(nodes.empty())
{
amdCB->ice_response();
return;
}
- PatchAggregatorPtr aggregator = new PatchAggregator(amdCB, _traceLevels, name, nodeDistrib.size());
- for(map<string, DistributionDescriptorDict>::const_iterator p = nodeDistrib.begin(); p != nodeDistrib.end(); ++p)
+ PatchAggregatorPtr aggregator = new PatchAggregator(amdCB, _traceLevels, name, nodes.size());
+ for(vector<string>::const_iterator p = nodes.begin(); p != nodes.end(); ++p)
{
if(_traceLevels->patch > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "started patching of application `" << name << "' on node `" << p->first << "'";
+ out << "started patching of application `" << name << "' on node `" << *p << "'";
}
- AMI_Node_patchPtr cb = new PatchCB(aggregator, p->first);
+ AMI_Node_patchPtr cb = new PatchCB(aggregator, *p);
try
{
- _database->getNode(p->first)->patch_async(cb, name, appDistrib, p->second, shutdown);
+ _database->getNode(*p)->patch_async(cb, name, "", appDistrib, shutdown);
}
catch(const Ice::Exception& ex)
{
@@ -359,7 +359,15 @@ AdminI::getDefaultApplicationDescriptor(const Current& current) const
"IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
}
- ApplicationDescriptor desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
+ ApplicationDescriptor desc;
+ try
+ {
+ desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
+ }
+ catch(const IceXML::ParserException& ex)
+ {
+ throw DeploymentException("can't parse default templates:\n" + ex.reason());
+ }
desc.name = "";
if(!desc.nodes.empty())
{
@@ -479,22 +487,22 @@ AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& i
ServerInfo info = _database->getServerInfo(id);
ApplicationHelper helper(_database->getApplicationDescriptor(info.application));
DistributionDescriptor appDistrib;
- map<string, DistributionDescriptorDict> nodeDistrib;
- helper.getDistributions(appDistrib, nodeDistrib, id);
+ vector<string> nodes;
+ helper.getDistributions(appDistrib, nodes, id);
- if(appDistrib.icepatch.empty() && nodeDistrib.empty())
+ if(appDistrib.icepatch.empty() && nodes.empty())
{
amdCB->ice_response();
return;
}
- assert(nodeDistrib.size() == 1);
+ assert(nodes.size() == 1);
- map<string, DistributionDescriptorDict>::const_iterator p = nodeDistrib.begin();
- AMI_Node_patchPtr amiCB = new ServerPatchCB(amdCB, _traceLevels, id, p->first);
+ vector<string>::const_iterator p = nodes.begin();
+ AMI_Node_patchPtr amiCB = new ServerPatchCB(amdCB, _traceLevels, id, *p);
try
{
- _database->getNode(p->first)->patch_async(amiCB, info.application, appDistrib, p->second, shutdown);
+ _database->getNode(*p)->patch_async(amiCB, info.application, id, appDistrib, shutdown);
}
catch(const Ice::Exception& ex)
{
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 705b757e319..6d4767398c8 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -1705,8 +1705,8 @@ NodeHelper::getServerInfos(const string& application, map<string, ServerInfo>& s
}
}
-DistributionDescriptorDict
-NodeHelper::getDistributions(const string& server) const
+bool
+NodeHelper::hasDistributions(const string& server) const
{
//
// Get the server distributions to patch.
@@ -1719,14 +1719,14 @@ NodeHelper::getDistributions(const string& server) const
{
if(!p->second.getServerInstance()->distrib.icepatch.empty())
{
- distribs.insert(make_pair(p->first, p->second.getServerInstance()->distrib));
+ return true;
}
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
if(!p->second.getServerInstance()->distrib.icepatch.empty())
{
- distribs.insert(make_pair(p->first, p->second.getServerInstance()->distrib));
+ return true;
}
}
}
@@ -1736,16 +1736,21 @@ NodeHelper::getDistributions(const string& server) const
if(p == _serverInstances.end())
{
p = _servers.find(server);
+ if(p == _servers.end())
+ {
+ p = _serverInstances.end();
+ }
}
if(p != _serverInstances.end())
{
if(!p->second.getServerInstance()->distrib.icepatch.empty())
{
- distribs.insert(make_pair(server, p->second.getServerInstance()->distrib));
+ return true;
}
}
}
- return distribs;
+
+ return false;
}
bool
@@ -2217,17 +2222,16 @@ ApplicationHelper::getServerInfos() const
}
void
-ApplicationHelper::getDistributions(DistributionDescriptor& distribution,
- map<string, DistributionDescriptorDict>& nodeDistributions,
+ApplicationHelper::getDistributions(DistributionDescriptor& distribution,
+ vector<string>& nodes,
const string& server) const
{
distribution = _instance.distrib;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- DistributionDescriptorDict distrib = n->second.getDistributions(server);
- if(!distrib.empty())
+ if(n->second.hasDistributions(server))
{
- nodeDistributions.insert(make_pair(n->first, distrib));
+ nodes.push_back(n->first);
if(!server.empty())
{
break;
@@ -2236,7 +2240,7 @@ ApplicationHelper::getDistributions(DistributionDescriptor& distribution,
else if(!_instance.distrib.icepatch.empty() &&
(server.empty() && n->second.hasServers() || n->second.hasServer(server)))
{
- nodeDistributions.insert(make_pair(n->first, distrib));
+ nodes.push_back(n->first);
}
}
}
diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h
index 0572748ff3c..85043c40de7 100644
--- a/cpp/src/IceGrid/DescriptorHelper.h
+++ b/cpp/src/IceGrid/DescriptorHelper.h
@@ -246,7 +246,7 @@ public:
const NodeDescriptor& getDescriptor() const;
const NodeDescriptor& getInstance() const;
void getServerInfos(const std::string&, std::map<std::string, ServerInfo>&) const;
- DistributionDescriptorDict getDistributions(const std::string&) const;
+ bool hasDistributions(const std::string&) const;
bool hasServers() const;
bool hasServer(const std::string&) const;
void print(IceUtil::Output&) const;
@@ -281,8 +281,7 @@ public:
const ApplicationDescriptor& getInstance() const;
TemplateDescriptor getServerTemplate(const std::string&) const;
TemplateDescriptor getServiceTemplate(const std::string&) const;
- void getDistributions(DistributionDescriptor&, std::map<std::string, DistributionDescriptorDict>&,
- const std::string& = std::string()) const;
+ void getDistributions(DistributionDescriptor&, std::vector<std::string>&,const std::string& = std::string()) const;
void print(IceUtil::Output&) const;
void printDiff(IceUtil::Output&, const ApplicationHelper&) const;
diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp
index 11711954bc9..f4bed9e2f6a 100644
--- a/cpp/src/IceGrid/DescriptorParser.cpp
+++ b/cpp/src/IceGrid/DescriptorParser.cpp
@@ -384,6 +384,16 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
}
_currentCommunicator->addDbEnvProperty(attributes);
}
+ else if(name == "description" || name == "option" || name == "env" || name == "directory")
+ {
+ //
+ // Nothing to do.
+ //
+ }
+ else
+ {
+ error("unknown element `" + name + "'");
+ }
attributes.checkUnknownAttributes();
}
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index c1e88ca6f3b..1e51dd6d1a7 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -345,8 +345,8 @@ NodeService::start(int argc, char* argv[])
// activator to each activated server).
//
const string instanceNameProperty = "IceGrid.InstanceName";
- const string locatorId = properties->getPropertyWithDefault(instanceNameProperty, "IceGrid") + "/Locator";
- string locatorPrx = locatorId + ":" + properties->getProperty("IceGrid.Registry.Client.Endpoints");
+ const string locatorId = properties->getPropertyWithDefault(instanceNameProperty, "IceGrid") + "/Locator";
+ string locatorPrx = locatorId + ":" + properties->getProperty("IceGrid.Registry.Client.Endpoints");
properties->setProperty("Ice.Default.Locator", locatorPrx);
}
else if(properties->getProperty("Ice.Default.Locator").empty())
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index 5022ffd41a2..e240f17fac1 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -202,8 +202,7 @@ interface Node
* which case the servers will be shutdown.
*
**/
- ["ami"] idempotent void patch(string application, DistributionDescriptor appDistrib,
- DistributionDescriptorDict serverDistribs, bool shutdown)
+ ["ami"] idempotent void patch(string application, string server, DistributionDescriptor appDistrib, bool shutdown)
throws PatchException;
/**
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index 2b428ff04af..0fdb413263c 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -273,8 +273,8 @@ NodeI::destroyServer_async(const AMD_Node_destroyServerPtr& amdCB, const string&
void
NodeI::patch(const string& application,
+ const string& server,
const DistributionDescriptor& appDistrib,
- const DistributionDescriptorDict& serverDistribs,
bool shutdown,
const Ice::Current&)
{
@@ -288,20 +288,17 @@ NodeI::patch(const string& application,
}
_patchInProgress.insert(application);
- if(!appDistrib.icepatch.empty())
+ if(server.empty() || !appDistrib.icepatch.empty())
{
servers = getApplicationServers(application);
}
else
{
- for(DistributionDescriptorDict::const_iterator p = serverDistribs.begin(); p != serverDistribs.end(); ++p)
+ Ice::Identity id = createServerIdentity(server);
+ ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id));
+ if(svr)
{
- Ice::Identity id = createServerIdentity(p->first);
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(id));
- if(server)
- {
- servers.insert(server);
- }
+ servers.insert(svr);
}
}
}
@@ -323,7 +320,7 @@ NodeI::patch(const string& application,
}
}
- if(!running.empty())
+ if((servers.empty() || !appDistrib.icepatch.empty()) && !running.empty())
{
PatchException ex;
ex.reason = "patch on node `" + _name + "' failed:\n";
@@ -360,16 +357,27 @@ NodeI::patch(const string& application,
}
//
- // Patch the servers.
+ // Patch the server(s).
//
- for(DistributionDescriptorDict::const_iterator p = serverDistribs.begin(); p != serverDistribs.end(); ++p)
+ for(s = servers.begin(); s != servers.end(); ++s)
{
- icepatch = FileServerPrx::checkedCast(getCommunicator()->stringToProxy(p->second.icepatch));
+ if(!server.empty() && (*s)->getId() != server)
+ {
+ continue;
+ }
+
+ DistributionDescriptor dist = (*s)->getDistribution();
+ icepatch = FileServerPrx::checkedCast(getCommunicator()->stringToProxy(dist.icepatch));
if(!icepatch)
{
- throw "proxy `" + p->second.icepatch + "' is not a file server.";
+ throw "proxy `" + dist.icepatch + "' is not a file server.";
+ }
+ patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist.directories);
+
+ if(!server.empty())
+ {
+ break;
}
- patch(icepatch, "servers/" + p->first + "/distrib", p->second.directories);
}
}
catch(const Ice::LocalException& ex)
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 0c6732bdeb1..d02622892a0 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -39,8 +39,8 @@ public:
virtual void loadServer_async(const AMD_Node_loadServerPtr&, const std::string&, const ServerDescriptorPtr&,
const Ice::Current&);
virtual void destroyServer_async(const AMD_Node_destroyServerPtr&, const std::string&, const Ice::Current&);
- virtual void patch(const std::string&, const DistributionDescriptor&, const DistributionDescriptorDict&,
- bool, const Ice::Current&);
+ virtual void patch(const std::string&, const std::string&, const DistributionDescriptor&, bool,
+ const Ice::Current&);
virtual std::string getName(const Ice::Current& = Ice::Current()) const;
virtual std::string getHostname(const Ice::Current& = Ice::Current()) const;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 09b7ed28db0..8cd5ce1bad0 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -697,6 +697,13 @@ ServerI::getId() const
return _id;
}
+DistributionDescriptor
+ServerI::getDistribution() const
+{
+ Lock sync(*this);
+ return _desc->distrib;
+}
+
void
ServerI::load(const AMD_Node_loadServerPtr& amdCB, const string& application, const ServerDescriptorPtr& desc)
{
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index 9daeff7be39..1df40bd93c0 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -81,6 +81,7 @@ public:
std::string getApplication() const;
ServerActivation getActivationMode() const;
const std::string& getId() const;
+ DistributionDescriptor getDistribution() const;
void load(const AMD_Node_loadServerPtr&, const std::string&, const ServerDescriptorPtr&);
bool startPatch(bool);