summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/NodeCache.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
committerBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
commitabada90e3f84dc703b8ddc9efcbed8a946fadead (patch)
tree2c6f9dccd510ea97cb927a7bd635422efaae547a /cpp/src/IceGrid/NodeCache.cpp
parentremoving trace message (diff)
downloadice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip
Expanded tabs into spaces
Diffstat (limited to 'cpp/src/IceGrid/NodeCache.cpp')
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp824
1 files changed, 412 insertions, 412 deletions
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index 63e23ea919c..a431b527712 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -29,107 +29,107 @@ namespace IceGrid
struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPtr&, void>
{
ToInternalServerDescriptor(const InternalServerDescriptorPtr& descriptor, const InternalNodeInfoPtr& node) :
- _desc(descriptor),
- _node(node)
+ _desc(descriptor),
+ _node(node)
{
}
void
operator()(const CommunicatorDescriptorPtr& desc)
{
- //
- // Figure out the configuration file name for the communicator
- // (if it's a service, it's "config_<service name>", if it's
- // the server, it's just "config").
- //
- string filename = "config";
- ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
- if(svc)
- {
- filename += "_" + svc->name;
- }
- PropertyDescriptorSeq& props = _desc->properties[filename];
-
- PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
-
- //
- // Add the adapters and their configuration.
- //
- for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
- {
- _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
-
- props.push_back(createProperty("# Object adapter " + q->name));
- PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
- prop.name = "Ice.OA." + q->name + ".Endpoints";
- props.push_back(prop);
- props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
- if(!q->replicaGroupId.empty())
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
- }
- if(q->registerProcess)
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
- _desc->processRegistered = true;
- }
- }
-
- _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
-
- const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
- for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
- {
- props.push_back(createProperty("# Database environment " + p->name));
- if(p->dbHome.empty())
- {
- _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
- }
- else
- {
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
- }
- }
-
- //
- // Copy the communicator descriptor properties.
- //
- if(!communicatorProps.empty())
- {
- if(svc)
- {
- props.push_back(createProperty("# Service descriptor properties"));
- }
- else
- {
- props.push_back(createProperty("# Server descriptor properties"));
- }
- copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
- }
+ //
+ // Figure out the configuration file name for the communicator
+ // (if it's a service, it's "config_<service name>", if it's
+ // the server, it's just "config").
+ //
+ string filename = "config";
+ ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
+ if(svc)
+ {
+ filename += "_" + svc->name;
+ }
+ PropertyDescriptorSeq& props = _desc->properties[filename];
+
+ PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
+
+ //
+ // Add the adapters and their configuration.
+ //
+ for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
+ {
+ _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
+
+ props.push_back(createProperty("# Object adapter " + q->name));
+ PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
+ prop.name = "Ice.OA." + q->name + ".Endpoints";
+ props.push_back(prop);
+ props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
+ if(!q->replicaGroupId.empty())
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
+ }
+ if(q->registerProcess)
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
+ _desc->processRegistered = true;
+ }
+ }
+
+ _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
+
+ const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
+ for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
+ {
+ props.push_back(createProperty("# Database environment " + p->name));
+ if(p->dbHome.empty())
+ {
+ _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
+ }
+ else
+ {
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
+ }
+ }
+
+ //
+ // Copy the communicator descriptor properties.
+ //
+ if(!communicatorProps.empty())
+ {
+ if(svc)
+ {
+ props.push_back(createProperty("# Service descriptor properties"));
+ }
+ else
+ {
+ props.push_back(createProperty("# Server descriptor properties"));
+ }
+ copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
+ }
}
PropertyDescriptor
removeProperty(PropertyDescriptorSeq& properties, const string& name)
{
- string value;
- PropertyDescriptorSeq::iterator p = properties.begin();
- while(p != properties.end())
- {
- if(p->name == name)
- {
- value = p->value;
- p = properties.erase(p);
- }
- else
- {
- ++p;
- }
- }
- PropertyDescriptor desc;
- desc.name = name;
- desc.value = value;
- return desc;
+ string value;
+ PropertyDescriptorSeq::iterator p = properties.begin();
+ while(p != properties.end())
+ {
+ if(p->name == name)
+ {
+ value = p->value;
+ p = properties.erase(p);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ PropertyDescriptor desc;
+ desc.name = name;
+ desc.value = value;
+ return desc;
}
InternalServerDescriptorPtr _desc;
@@ -141,60 +141,60 @@ class LoadCB : public AMI_Node_loadServer
public:
LoadCB(const TraceLevelsPtr& traceLevels,
- const ServerEntryPtr& server,
- const string& node,
- int timeout) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
+ const ServerEntryPtr& server,
+ const string& node,
+ int timeout) :
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
{
}
void
ice_response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt)
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "loaded `" << _id << "' on node `" << _node << "'";
- }
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "loaded `" << _id << "' on node `" << _node << "'";
+ }
- //
- // Add the node session timeout on the proxies to ensure the
- // timeout is large enough.
- //
- _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
+ //
+ // Add the node session timeout on the proxies to ensure the
+ // timeout is large enough.
+ //
+ _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
- }
-
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -211,51 +211,51 @@ class DestroyCB : public AMI_Node_destroyServer
public:
DestroyCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, const string& node) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
{
}
void
ice_response()
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "unloaded `" << _id << "' on node `" << _node << "'";
- }
- _server->destroyCallback();
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "unloaded `" << _id << "' on node `" << _node << "'";
+ }
+ _server->destroyCallback();
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
- }
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -277,13 +277,13 @@ public:
void
ice_response()
{
- _node->finishedRegistration();
+ _node->finishedRegistration();
}
void
ice_exception(const Ice::Exception& ex)
{
- _node->finishedRegistration(ex);
+ _node->finishedRegistration(ex);
}
private:
@@ -306,15 +306,15 @@ NodeCache::get(const string& name, bool create) const
NodeEntryPtr entry = getImpl(name);
if(!entry && create)
{
- NodeCache& self = const_cast<NodeCache&>(*this);
- entry = new NodeEntry(self, name);
- self.addImpl(name, entry);
+ NodeCache& self = const_cast<NodeCache&>(*this);
+ entry = new NodeEntry(self, name);
+ self.addImpl(name, entry);
}
if(!entry)
{
- NodeNotExistException ex;
- ex.name = name;
- throw ex;
+ NodeNotExistException ex;
+ ex.name = name;
+ throw ex;
}
return entry;
}
@@ -366,50 +366,50 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(session)
{
- while(_session)
- {
- if(_session->isDestroyed())
- {
- // If the current session has just been destroyed, wait for the setSession(0) call.
- assert(session != _session);
- wait();
- }
- else
- {
- NodeSessionIPtr session = _session;
- sync.release();
- try
- {
- session->getNode()->ice_ping();
- throw NodeActiveException();
- }
- catch(const Ice::LocalException&)
- {
- try
- {
- session->destroy();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- }
- sync.acquire();
- }
- }
-
- //
- // Clear the saved proxy, the node has established a session
- // so we won't need anymore to try to register it with this
- // registry.
- //
- _proxy = 0;
+ while(_session)
+ {
+ if(_session->isDestroyed())
+ {
+ // If the current session has just been destroyed, wait for the setSession(0) call.
+ assert(session != _session);
+ wait();
+ }
+ else
+ {
+ NodeSessionIPtr session = _session;
+ sync.release();
+ try
+ {
+ session->getNode()->ice_ping();
+ throw NodeActiveException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ try
+ {
+ session->destroy();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ sync.acquire();
+ }
+ }
+
+ //
+ // Clear the saved proxy, the node has established a session
+ // so we won't need anymore to try to register it with this
+ // registry.
+ //
+ _proxy = 0;
}
else
{
- if(!_session)
- {
- return;
- }
+ if(!_session)
+ {
+ return;
+ }
}
_session = session;
@@ -417,25 +417,25 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
if(session)
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' up";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' up";
+ }
}
else
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' down";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' down";
+ }
}
}
@@ -462,7 +462,7 @@ NodeEntry::getServers() const
ServerEntrySeq entries;
for(map<string, ServerEntryPtr>::const_iterator p = _servers.begin(); p != _servers.end(); ++p)
{
- entries.push_back(p->second);
+ entries.push_back(p->second);
}
return entries;
}
@@ -476,7 +476,7 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
map<string, NodeDescriptor>::const_iterator p = _descriptors.find(application);
if(p == _descriptors.end())
{
- throw NodeNotExistException(); // The node doesn't exist in the given application.
+ throw NodeNotExistException(); // The node doesn't exist in the given application.
}
//
@@ -486,30 +486,30 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
loadFactor = -1.0f;
if(!p->second.loadFactor.empty())
{
- istringstream is(p->second.loadFactor);
- is >> loadFactor;
+ istringstream is(p->second.loadFactor);
+ is >> loadFactor;
}
if(loadFactor < 0.0f)
{
- if(_session->getInfo()->os != "Windows")
- {
- //
- // On Unix platforms, we divide the load averages by the
- // number of processors. A load of 2 on a dual processor
- // machine is the same as a load of 1 on a single process
- // machine.
- //
- loadFactor = 1.0f / _session->getInfo()->nProcessors;
- }
- else
- {
- //
- // On Windows, load1, load5 and load15 are the average of
- // the CPU utilization (all CPUs). We don't need to divide
- // by the number of CPU.
- //
- loadFactor = 1.0f;
- }
+ if(_session->getInfo()->os != "Windows")
+ {
+ //
+ // On Unix platforms, we divide the load averages by the
+ // number of processors. A load of 2 on a dual processor
+ // machine is the same as a load of 1 on a single process
+ // machine.
+ //
+ loadFactor = 1.0f / _session->getInfo()->nProcessors;
+ }
+ else
+ {
+ //
+ // On Windows, load1, load5 and load15 are the average of
+ // the CPU utilization (all CPUs). We don't need to divide
+ // by the number of CPU.
+ //
+ loadFactor = 1.0f;
+ }
}
return _session->getLoadInfo();
@@ -535,60 +535,60 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con
{
try
{
- NodePrx node;
- int sessionTimeout;
- InternalServerDescriptorPtr desc;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
- sessionTimeout = _session->getTimeout();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
-
- ServerInfo info = server;
- try
- {
- info.descriptor = getServerDescriptor(server, session);
- }
- catch(const DeploymentException&)
- {
- //
- // We ignore the deployment error for now (which can
- // only be caused in theory by session variables not
- // being defined because the server isn't
- // allocated...)
- //
- }
- desc = getInternalServerDescriptor(info);
- }
- assert(desc);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- out << "loading `" << desc->id << "' on node `" << _name << "'";
- if(session)
- {
- out << " for session `" << session->getId() << "'";
- }
- }
-
- AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
- node->loadServer_async(amiCB, desc, _cache.getReplicaName());
+ NodePrx node;
+ int sessionTimeout;
+ InternalServerDescriptorPtr desc;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+ sessionTimeout = _session->getTimeout();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+
+ ServerInfo info = server;
+ try
+ {
+ info.descriptor = getServerDescriptor(server, session);
+ }
+ catch(const DeploymentException&)
+ {
+ //
+ // We ignore the deployment error for now (which can
+ // only be caused in theory by session variables not
+ // being defined because the server isn't
+ // allocated...)
+ //
+ }
+ desc = getInternalServerDescriptor(info);
+ }
+ assert(desc);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ out << "loading `" << desc->id << "' on node `" << _name << "'";
+ if(session)
+ {
+ out << " for session `" << session->getId() << "'";
+ }
+ }
+
+ AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
+ node->loadServer_async(amiCB, desc, _cache.getReplicaName());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -597,36 +597,36 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info, in
{
try
{
- NodePrx node;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
- }
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'";
- }
-
- AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name);
- node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName());
+ NodePrx node;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+ }
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'";
+ }
+
+ AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name);
+ node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -654,18 +654,18 @@ NodeEntry::getServerDescriptor(const ServerInfo& server, const SessionIPtr& sess
if(session)
{
- resolve.setReserved("session.id", session->getId());
+ resolve.setReserved("session.id", session->getId());
}
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server.descriptor);
if(iceBox)
{
- return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
+ return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
}
else
{
- return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
- PropertySetDescriptorDict());
+ return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
+ PropertySetDescriptorDict());
}
}
@@ -691,28 +691,28 @@ NodeEntry::__decRef()
bool doRemove = false;
bool doDelete = false;
{
- Lock sync(*this); // We use a recursive mutex so it's fine to
- // create Ptr with the mutex locked.
- assert(_ref > 0);
- --_ref;
-
- if(_ref == 1)
- {
- doRemove = canRemove();
- }
- else if(_ref == 0)
- {
- doDelete = true;
- }
+ Lock sync(*this); // We use a recursive mutex so it's fine to
+ // create Ptr with the mutex locked.
+ assert(_ref > 0);
+ --_ref;
+
+ if(_ref == 1)
+ {
+ doRemove = canRemove();
+ }
+ else if(_ref == 0)
+ {
+ doDelete = true;
+ }
}
if(doRemove)
{
- _cache.remove(_name);
+ _cache.remove(_name);
}
else if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -721,45 +721,45 @@ NodeEntry::checkSession() const
{
if(_session && !_session->isDestroyed())
{
- return;
+ return;
}
else if(!_proxy && !_registering)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
else if(_proxy)
{
- //
- // If the node proxy is set, we attempt to get the node to
- // register with this registry.
- //
- assert(!_registering);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "creating node `" << _name << "' session";
- }
-
- //
- // NOTE: setting _registering to true must be done before the
- // call otherwise if the callback is call immediately we'll
- // hang in the while loop.
- //
- _registering = true;
- NodeEntry* self = const_cast<NodeEntry*>(this);
- _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
- _proxy = 0; // Registration with the proxy is only attempted once.
+ //
+ // If the node proxy is set, we attempt to get the node to
+ // register with this registry.
+ //
+ assert(!_registering);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "creating node `" << _name << "' session";
+ }
+
+ //
+ // NOTE: setting _registering to true must be done before the
+ // call otherwise if the callback is call immediately we'll
+ // hang in the while loop.
+ //
+ _registering = true;
+ NodeEntry* self = const_cast<NodeEntry*>(this);
+ _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
+ _proxy = 0; // Registration with the proxy is only attempted once.
}
while(_registering)
{
- wait();
+ wait();
}
if(!_session)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
}
@@ -776,7 +776,7 @@ NodeEntry::setProxy(const NodePrx& node)
//
if(!_session)
{
- _proxy = node;
+ _proxy = node;
}
}
@@ -786,21 +786,21 @@ NodeEntry::finishedRegistration()
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- if(_session)
- {
- out << "node `" << _name << "' session created";
- }
- else
- {
- out << "node `" << _name << "' session creation failed";
- }
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ if(_session)
+ {
+ out << "node `" << _name << "' session created";
+ }
+ else
+ {
+ out << "node `" << _name << "' session creation failed";
+ }
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -810,14 +810,14 @@ NodeEntry::finishedRegistration(const Ice::Exception& ex)
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' session creation failed:\n" << ex;
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' session creation failed:\n" << ex;
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -840,17 +840,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
server->deactivationTimeout = info.descriptor->deactivationTimeout;
if(!info.descriptor->iceVersion.empty())
{
- server->iceVersion = info.descriptor->iceVersion;
+ server->iceVersion = info.descriptor->iceVersion;
}
else
{
- server->iceVersion = string(ICE_STRING_VERSION);
+ server->iceVersion = string(ICE_STRING_VERSION);
}
server->applicationDistrib = info.descriptor->applicationDistrib;
if(!info.descriptor->distrib.icepatch.empty())
{
- server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
- info.descriptor->distrib.directories);
+ server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
+ info.descriptor->distrib.directories);
}
server->options = info.descriptor->options;
server->envs = info.descriptor->envs;
@@ -875,15 +875,15 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
if(iceBox)
{
- for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
- {
- ServiceDescriptorPtr s = p->descriptor;
- const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
- props.push_back(
- createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
- servicesStr += s->name + " ";
- }
- props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
+ for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
+ {
+ ServiceDescriptorPtr s = p->descriptor;
+ const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
+ props.push_back(
+ createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
+ servicesStr += s->name + " ";
+ }
+ props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
}
//
@@ -899,17 +899,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
//
if(getMMVersion(server->iceVersion) < 30200)
{
- const string oaPrefix = "Ice.OA.";
- for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
- {
- for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- if(q->name.find(oaPrefix) == 0)
- {
- q->name = q->name.substr(oaPrefix.size());
- }
- }
- }
+ const string oaPrefix = "Ice.OA.";
+ for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
+ {
+ for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ if(q->name.find(oaPrefix) == 0)
+ {
+ q->name = q->name.substr(oaPrefix.size());
+ }
+ }
+ }
}
return server;