diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-09-04 19:23:32 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-09-04 19:23:32 +0000 |
commit | bdeb0007e50f676bf416ca25c493c888548ea7cd (patch) | |
tree | f7f25ecd302b273e31d80a420e5667b40900a267 /cpp | |
parent | Temporary fix to use binary freeze db (diff) | |
download | ice-bdeb0007e50f676bf416ca25c493c888548ea7cd.tar.bz2 ice-bdeb0007e50f676bf416ca25c493c888548ea7cd.tar.xz ice-bdeb0007e50f676bf416ca25c493c888548ea7cd.zip |
Added local exceptions ObjectAdapterActiveException and
ObjectAdapterNotRegisteredException.
:LocatoRegistry::addAdapter method to setAdapterDirectProxy.
Minor IcePack fixes.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/config/IcePackAdmin.py | 1 | ||||
-rw-r--r-- | cpp/doc/Properties.sgml | 39 | ||||
-rw-r--r-- | cpp/slice/Ice/LocalException.ice | 23 | ||||
-rw-r--r-- | cpp/slice/Ice/Locator.ice | 37 | ||||
-rw-r--r-- | cpp/slice/IcePack/Admin.ice | 151 | ||||
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 13 | ||||
-rw-r--r-- | cpp/src/IcePack/ActivatorI.cpp | 26 | ||||
-rw-r--r-- | cpp/src/IcePack/ApplicationBuilder.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IcePack/ComponentBuilder.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IcePack/Grammar.y | 5 | ||||
-rw-r--r-- | cpp/src/IcePack/LocatorRegistryI.cpp | 30 | ||||
-rw-r--r-- | cpp/src/IcePack/LocatorRegistryI.h | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.cpp | 22 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/Scanner.l | 4 | ||||
-rw-r--r-- | cpp/src/IcePack/ServerAdapterI.cpp | 5 | ||||
-rw-r--r-- | cpp/src/IcePack/ServerBuilder.cpp | 7 | ||||
-rw-r--r-- | cpp/src/IcePack/ServerDeployerI.cpp | 19 | ||||
-rw-r--r-- | cpp/src/IcePack/ServerI.cpp | 61 | ||||
-rw-r--r-- | cpp/test/Ice/location/ServerLocator.cpp | 9 | ||||
-rw-r--r-- | cpp/test/Ice/location/ServerLocator.h | 2 |
22 files changed, 391 insertions, 95 deletions
diff --git a/cpp/config/IcePackAdmin.py b/cpp/config/IcePackAdmin.py index 99d2e2df109..f888a37bbe0 100644 --- a/cpp/config/IcePackAdmin.py +++ b/cpp/config/IcePackAdmin.py @@ -34,6 +34,7 @@ def startIcePackRegistry(toplevel, port, testdir): r' --IcePack.Registry.Internal.Endpoints=default' + \ r' --IcePack.Registry.Admin.Endpoints=default' + \ r' --IcePack.Registry.Data=' + dataDir + \ + r' --IcePack.Registry.AllowNotRegisteredAdapters' + \ r' --Ice.ProgramName=icepackregistry' icePackPipe = os.popen(command) diff --git a/cpp/doc/Properties.sgml b/cpp/doc/Properties.sgml index 1f744b19c8b..f2c70ca34db 100644 --- a/cpp/doc/Properties.sgml +++ b/cpp/doc/Properties.sgml @@ -165,7 +165,7 @@ router. </para></note> <section><title>Ice.Adapter.<replaceable>name</replaceable>.Locator</title> <section><title>Synopsis</title> <synopsis> -Ice.Adapter.<replaceable>name</replaceable>.Locator=<replaceable>num</replaceable> +Ice.Adapter.<replaceable>name</replaceable>.Locator=<replaceable>locator</replaceable> </synopsis> </section> <section> @@ -175,7 +175,9 @@ Specifies a locator (as stringified proxy to the &Ice; locator interface) for the object adapter with the name <replaceable>name</replaceable>. By doing so, the object adapter will register itself and its endpoints with the locator registry from this -locator. +locator. To prevent the object adapter to register its endpoints with +the locator registry you can set <replaceable>locator</replaceable> to +0. </para> </section> </section> @@ -929,6 +931,22 @@ Defines the path of the &IcePack; registry data directory. </section> </section> +<section><title>IcePack.Registry.AllowNotRegisteredAdapters</title> +<section><title>Synopsis</title> +<synopsis> +IcePack.Registry.AllowNotRegisteredAdapters=<replaceable>num</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +If <replaceable>num</replaceable> is set to a value larger than zero, +the locator registry will allow &Ice; servers to set endpoints for +adapters which haven't been registered. +</para> +</section> +</section> + <section><title>IcePack.Registry.Trace.ServerRegistry</title> <section><title>Synopsis</title> <synopsis> @@ -1087,6 +1105,23 @@ will kill the server.</para> </section> </section> +<section><title>IcePack.Node.CollocateRegistry</title> +<section><title>Synopsis</title> +<synopsis> +IcePack.Node.CollocateRegistry=<replaceable>num</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +If <replaceable>num</replaceable> is set to a value larger than zero, +the node will also collocate the &IcePack; registry. +</para> +<note><para>The collocated registry is configured with the same +properties as the standalone &IcePack; registry.</para></note> +</section> +</section> + <section><title>IcePack.Node.Trace.Server</title> <section><title>Synopsis</title> <synopsis> diff --git a/cpp/slice/Ice/LocalException.ice b/cpp/slice/Ice/LocalException.ice index 16147b9b994..582bbde1d8b 100644 --- a/cpp/slice/Ice/LocalException.ice +++ b/cpp/slice/Ice/LocalException.ice @@ -95,6 +95,29 @@ local exception ObjectAdapterDeactivatedException /** * + * This exception is raised only if the [ObjectAdapter] [Locator] is + * set and if the [ObjectAdapter] activation failed because it's not + * already registered with the [Locator]. + * + **/ +local exception ObjectAdapterNotRegisteredException +{ +}; + +/** + * + * This exception is raised only if the [ObjectAdapter] [Locator] is + * set and if the [ObjectAdapter] can't be activated because the + * [Locator] detected another active [ObjectAdapter] with the same + * name. + * + **/ +local exception ObjectAdapterActiveException +{ +}; + +/** + * * This exception is raised if not suitable endpoint is available. * **/ diff --git a/cpp/slice/Ice/Locator.ice b/cpp/slice/Ice/Locator.ice index e3588aaf93d..b37e9a3cb4f 100644 --- a/cpp/slice/Ice/Locator.ice +++ b/cpp/slice/Ice/Locator.ice @@ -53,8 +53,28 @@ interface Locator /** * + * This exception is raised if the server tries to set endpoints for + * an adapter which is not registered with the locator. + * + **/ +exception AdapterNotRegistered +{ +}; + +/** + * + * This exception is raised if the server tries to set endpoints for + * an adapter which is already active. + * + **/ +exception AdapterAlreadyActive +{ +}; + +/** + * * The &Ice; locator registry interface. This interface is used by - * servers to register adapters with the locator. + * servers to register adapter endpoints with the locator. * * <note><para> The [LocatorRegistry] interface is intended to be used * by &Ice; internals and by locator implementations. Regular user @@ -66,15 +86,24 @@ interface LocatorRegistry { /** * - * Add the adapter and its endpoints to the locator registry. + * Set the adapter endpoints with the locator registry. * * @param name The adapter name. * * @param proxy The adapter proxy (a dummy direct proxy created - * with the adapter). + * with the adapter). The direct proxy contains the adapter + * endpoints. + * + * @throws AdapterNotRegistered Raised if the locator only allows + * registered adapters to set their active proxy and if the + * adapter is not registered with the locator. + * + * @throws AdapterAlreadyActive Raised if an adapter with the same + * name is already active. * */ - idempotent void addAdapter(string name, Object* proxy); + idempotent void setAdapterDirectProxy(string name, Object* proxy) + throws AdapterNotRegistered, AdapterAlreadyActive; }; }; diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice index 7b35e5736f0..78de3bcdf9a 100644 --- a/cpp/slice/IcePack/Admin.ice +++ b/cpp/slice/IcePack/Admin.ice @@ -51,44 +51,101 @@ exception NodeNotExistException /** * - * These exceptions are raised when the deployment of the server failed. + * A generic exception base for all kind of deployment error + * exception. * **/ exception DeploymentException { + /** + * + * The path of the component which cause the deployment to + * fail. The path is a dot separated list of component names. It + * always starts with the node name is followed by the server name + * and eventually the service name. + * + **/ string component; + + /** + * + * The reason for the failure. + * + **/ string reason; }; -// TODO: ML: Documentation. +/** + * + * This exception is raised when an error occured while parsing the + * XML descriptor of a component. + * + **/ exception ParserDeploymentException extends DeploymentException { }; -// TODO: ML: Documentation. +/** + * + * This exception is raised when an error occured during the adapter + * regsitration. + * + **/ exception AdapterDeploymentException extends DeploymentException { -// TODO: ML: Documentation. + /** + * + * The name of the adapter which couldn't be registered. + * + **/ string adapter; }; -// TODO: ML: Documentation. +/** + * + * This exception is raised when an error occured during the + * registration of a Yellow offer. + * + **/ exception OfferDeploymentException extends DeploymentException { -// TODO: ML: Documentation. + /** + * + * The Yellow interface which couldn't be registered with the + * Yellow service. + * + **/ string intf; -// TODO: ML: Documentation. + + /** + * + * The proxy which couldn't be registered with the Yellow service. + * + **/ Object* proxy; }; -// TODO: ML: Documentation. +/** + * + * This exception is raised if an error occured when deploying a + * server. + * + **/ exception ServerDeploymentException extends DeploymentException { -// TODO: ML: Documentation. + /** + * + * The name of the server which couldn't be deployed. + * + **/ string server; }; -// TODO: ML: Documentation. +/** + * + * This exception is raised if a node couldn't be reach. + * + **/ exception NodeUnreachableException { }; @@ -102,7 +159,7 @@ sequence<string> Args; /** * - * A vector of strings representing targets. + * A vector of strings representing deployment targets. * **/ sequence<string> Targets; @@ -114,24 +171,80 @@ sequence<string> Targets; **/ enum ServerState { - // TODO: ML: Documentation for each individual element. + /** + * + * The server is not running. + * + **/ Inactive, + + /** + * + * The server is being activated and will change to the Active + * state if the server fork succeed or to the Inactive state if it + * failed. + * + **/ Activating, + + /** + * + * The server is running. + * + **/ Active, + + /** + * + * The server is being deactivated. + * + **/ Deactivating, + + /** + * + * The server is being destroyed. + * + **/ Destroying, + + /** + * + * The server is destroyed. + * + **/ Destroyed }; -// TODO: ML: Documentation. +/** + * + * The server activation mode. + * + **/ enum ServerActivation { - // TODO: ML: Documentation for each individual element. + /** + * + * The server is activated on demand when a client requests one of + * the adapter endpoints and if the server isn't already running. + * + **/ OnDemand, + + /** + * + * The server is activated manually through the administrative + * interface. + * + **/ Manual }; -// TODO: ML: Documentation. +/** + * + * The server description. + * + **/ struct ServerDescription { /** @@ -150,7 +263,8 @@ struct ServerDescription /** * - * Deployment descriptor. + * The path of the deployment descriptor used to deploy the + * server. * **/ string descriptor; @@ -171,10 +285,7 @@ struct ServerDescription /** * - * The optional server path. If none is given, no automatic - * activation will be performed. This path can be an absolute or - * relative path (be aware of security risks if you use a relative - * path). + * The server path. * * @see args * @see pwd diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 0f64228c893..baa65868bf0 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -75,6 +75,20 @@ Ice::ObjectAdapterDeactivatedException::ice_print(ostream& out) const } void +Ice::ObjectAdapterActiveException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nobject adapter already active"; +} + +void +Ice::ObjectAdapterNotRegisteredException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nobject adapter not registered with the locator"; +} + +void Ice::NoEndpointException::ice_print(ostream& out) const { Exception::ice_print(out); diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 932fdb037cb..0089e105b31 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -78,7 +78,18 @@ Ice::ObjectAdapterI::activate() // activate operation instead of a non obvious network // exception? // - _locatorInfo->getLocatorRegistry()->addAdapter(_name, newDirectProxy(ident)); + try + { + _locatorInfo->getLocatorRegistry()->setAdapterDirectProxy(_name, newDirectProxy(ident)); + } + catch(const Ice::AdapterNotRegistered&) + { + throw ObjectAdapterNotRegisteredException(__FILE__, __LINE__); + } + catch(const Ice::AdapterAlreadyActive&) + { + throw ObjectAdapterActiveException(__FILE__, __LINE__); + } } } diff --git a/cpp/src/IcePack/ActivatorI.cpp b/cpp/src/IcePack/ActivatorI.cpp index 7628fb8fa7c..3a6fabe53b9 100644 --- a/cpp/src/IcePack/ActivatorI.cpp +++ b/cpp/src/IcePack/ActivatorI.cpp @@ -287,12 +287,20 @@ IcePack::ActivatorI::activate(const ServerPtr& server) void IcePack::ActivatorI::deactivate(const ServerPtr& server) { - pid_t pid = static_cast<pid_t>(server->getPid()); - + Ice::Int pid = server->getPid(); + + if(pid == 0) + { + // + // Server is already deactivated. + // + return; + } + // // Send a SIGTERM to the process. // - if(::kill(pid, SIGTERM)) + if(::kill(static_cast<pid_t>(pid), SIGTERM)) { SyscallException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -309,12 +317,20 @@ IcePack::ActivatorI::deactivate(const ServerPtr& server) void IcePack::ActivatorI::kill(const ServerPtr& server) { - pid_t pid = static_cast<pid_t>(server->getPid()); + Ice::Int pid = server->getPid(); + if(pid == 0) + { + // + // Server is already deactivated. + // + return; + } + // // Send a SIGKILL to the process. // - if(::kill(pid, SIGKILL)) + if(::kill(static_cast<pid_t>(pid), SIGKILL)) { SyscallException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); diff --git a/cpp/src/IcePack/ApplicationBuilder.cpp b/cpp/src/IcePack/ApplicationBuilder.cpp index 6fae0a27dc2..687a1e11150 100644 --- a/cpp/src/IcePack/ApplicationBuilder.cpp +++ b/cpp/src/IcePack/ApplicationBuilder.cpp @@ -20,9 +20,10 @@ class AddServer : public Task { public: - AddServer(const ServerDeployerPrx& deployer, const string& name, const string& descriptor, const string& binpath, - const string& libpath, const Targets& targets) : + AddServer(const ServerDeployerPrx& deployer, const string& node, const string& name, const string& descriptor, + const string& binpath, const string& libpath, const Targets& targets) : _deployer(deployer), + _node(node), _name(name), _descriptor(descriptor), _binpath(binpath), @@ -46,6 +47,7 @@ public: ServerDeploymentException ex; ex.server = _name; ex.reason = os.str(); + ex.component = _node + "." + _name; throw ex; } } @@ -65,6 +67,7 @@ public: ServerDeploymentException ex; ex.server = _name; ex.reason = os.str(); + ex.component = _node + "." + _name; throw ex; } catch(const Ice::LocalException& lex) @@ -75,6 +78,7 @@ public: ServerDeploymentException ex; ex.server = _name; ex.reason = os.str(); + ex.component = _node + "." + _name; throw ex; } } @@ -82,6 +86,7 @@ public: private: ServerDeployerPrx _deployer; + string _node; string _name; string _descriptor; string _binpath; @@ -237,7 +242,7 @@ IcePack::ApplicationBuilder::addServer(const string& name, try { ServerDeployerPrx deployer = node->getServerDeployer(); - _tasks.push_back(new AddServer(deployer, name, descriptor, binpath, libpath, _targets)); + _tasks.push_back(new AddServer(deployer, nodeName, name, descriptor, binpath, libpath, _targets)); } catch(::Ice::LocalException&) { diff --git a/cpp/src/IcePack/ComponentBuilder.cpp b/cpp/src/IcePack/ComponentBuilder.cpp index b97565f8422..0dd68963fb4 100644 --- a/cpp/src/IcePack/ComponentBuilder.cpp +++ b/cpp/src/IcePack/ComponentBuilder.cpp @@ -679,8 +679,8 @@ IcePack::ComponentBuilder::undo() catch(const DeploymentException& ex) { ostringstream os; - os << "exception while removing component " << _componentPath << ":\n"; - os << ex << ": " << ex.reason; + os << "exception while removing component " << (ex.component.empty() ? _componentPath : ex.component); + os << ":\n" << ex << ": " << ex.reason; _communicator->getLogger()->warning(os.str()); } diff --git a/cpp/src/IcePack/Grammar.y b/cpp/src/IcePack/Grammar.y index 607bb730964..0b4f6e5a6ad 100644 --- a/cpp/src/IcePack/Grammar.y +++ b/cpp/src/IcePack/Grammar.y @@ -49,6 +49,7 @@ yyerror(const char* s) %token ICE_PACK_STOP %token ICE_PACK_DESCRIBE %token ICE_PACK_STATE +%token ICE_PACK_PID %token ICE_PACK_ENDPOINTS %% @@ -126,6 +127,10 @@ command { parser->stateServer($3); } +| ICE_PACK_SERVER ICE_PACK_PID strings ';' +{ + parser->pidServer($3); +} | ICE_PACK_SERVER ICE_PACK_REMOVE strings ';' { parser->removeServer($3); diff --git a/cpp/src/IcePack/LocatorRegistryI.cpp b/cpp/src/IcePack/LocatorRegistryI.cpp index f1c7abfb9f4..ebe793821c3 100644 --- a/cpp/src/IcePack/LocatorRegistryI.cpp +++ b/cpp/src/IcePack/LocatorRegistryI.cpp @@ -22,7 +22,7 @@ IcePack::LocatorRegistryI::LocatorRegistryI(const AdapterRegistryPtr& registry, } void -IcePack::LocatorRegistryI::addAdapter(const string& name, const Ice::ObjectPrx& proxy, const Ice::Current&) +IcePack::LocatorRegistryI::setAdapterDirectProxy(const string& name, const Ice::ObjectPrx& proxy, const Ice::Current&) { while(true) { @@ -39,13 +39,7 @@ IcePack::LocatorRegistryI::addAdapter(const string& name, const Ice::ObjectPrx& } catch(const AdapterActiveException&) { - // - // TODO: we have to do something here. We can't just let - // the server try to override the direct proxy of an - // active adapter without saying anything. We need to - // throw here to prevent the server from starting. - // - return; + throw Ice::AdapterAlreadyActive(); } catch(const Ice::ObjectNotExistException&) { @@ -60,7 +54,7 @@ IcePack::LocatorRegistryI::addAdapter(const string& name, const Ice::ObjectPrx& // is possibly because the IcePack node is down and // the server is started manually for example. We // should probably throw here to prevent the server - // from starting. + // from starting? // return; } @@ -83,14 +77,22 @@ IcePack::LocatorRegistryI::addAdapter(const string& name, const Ice::ObjectPrx& // didn't previously registered its object adapters (using the // IcePack deployment mechanism). // - AdapterPrx adapter = AdapterPrx::uncheckedCast(_adapter->addWithUUID(new StandaloneAdapterI())); - try + Ice::PropertiesPtr properties = _adapter->getCommunicator()->getProperties(); + if(properties->getPropertyAsInt("IcePack.Registry.AllowNotRegisteredAdapters") > 0) { - _registry->add(name, adapter); + AdapterPrx adapter = AdapterPrx::uncheckedCast(_adapter->addWithUUID(new StandaloneAdapterI())); + try + { + _registry->add(name, adapter); + } + catch(const AdapterExistsException&) + { + _adapter->remove(adapter->ice_getIdentity()); + } } - catch(const AdapterExistsException&) + else { - _adapter->remove(adapter->ice_getIdentity()); + throw Ice::AdapterNotRegistered(); } } } diff --git a/cpp/src/IcePack/LocatorRegistryI.h b/cpp/src/IcePack/LocatorRegistryI.h index b84b5083bcc..a3a0e484109 100644 --- a/cpp/src/IcePack/LocatorRegistryI.h +++ b/cpp/src/IcePack/LocatorRegistryI.h @@ -24,7 +24,7 @@ public: LocatorRegistryI(const AdapterRegistryPtr&, const Ice::ObjectAdapterPtr&); - virtual void addAdapter(const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); + virtual void setAdapterDirectProxy(const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); private: diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index 1fba9a89a86..28e2e033597 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -59,6 +59,7 @@ IcePack::Parser::usage() " deployed.\n" "server describe NAME Get server NAME description.\n" "server state NAME Get server NAME state.\n" + "server pid NAME Get server NAME pid.\n" "server start NAME Starts server NAME.\n" "server stop NAME Stop server NAME.\n" "server remove NAME Remove server NAME.\n" @@ -406,6 +407,27 @@ IcePack::Parser::stateServer(const list<string>& args) } void +IcePack::Parser::pidServer(const list<string>& args) +{ + if(args.size() != 1) + { + error("`server pid' requires exactly one argument\n(`help' for more info)"); + return; + } + + try + { + cout << _admin->getServerPid(args.front()) << endl; + } + catch(const Exception& ex) + { + ostringstream s; + s << ex; + error(s.str()); + } +} + +void IcePack::Parser::listAllServers() { try diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h index 45affe567ec..d1ce46e4158 100644 --- a/cpp/src/IcePack/Parser.h +++ b/cpp/src/IcePack/Parser.h @@ -79,6 +79,7 @@ public: void stopServer(const std::list<std::string>&); void describeServer(const std::list<std::string>&); void stateServer(const std::list<std::string>&); + void pidServer(const std::list<std::string>&); void removeServer(const std::list<std::string>&); void listAllServers(); diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l index 8e296b642da..ee00147b0c6 100644 --- a/cpp/src/IcePack/Scanner.l +++ b/cpp/src/IcePack/Scanner.l @@ -132,6 +132,10 @@ NL [\n] return ICE_PACK_STATE; } +"pid" { + return ICE_PACK_PID; +} + "endpoints" { return ICE_PACK_ENDPOINTS; } diff --git a/cpp/src/IcePack/ServerAdapterI.cpp b/cpp/src/IcePack/ServerAdapterI.cpp index 5121a6881c6..cbf747f5d8a 100644 --- a/cpp/src/IcePack/ServerAdapterI.cpp +++ b/cpp/src/IcePack/ServerAdapterI.cpp @@ -99,7 +99,10 @@ IcePack::ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Cu // null. We don't allow to overide an existing proxy by another // non null proxy. // - assert(!(prx && _proxy)); + if(prx && _proxy) + { + throw AdapterActiveException(); + } _proxy = prx; _notified = true; diff --git a/cpp/src/IcePack/ServerBuilder.cpp b/cpp/src/IcePack/ServerBuilder.cpp index 34fbc342f82..9fbdac41272 100644 --- a/cpp/src/IcePack/ServerBuilder.cpp +++ b/cpp/src/IcePack/ServerBuilder.cpp @@ -359,7 +359,12 @@ IcePack::ServerBuilder::parse(const std::string& descriptor) Ice::PropertiesPtr props = _nodeInfo->getCommunicator()->getProperties(); _properties->setProperty("Ice.ProgramName", _variables["name"]); - _properties->setProperty("Yellow.Query", props->getProperty("IcePack.Yellow.Query")); + + // + // TODO: Shall we really generate yellow configuration here? + // + _properties->setProperty("Yellow.Query", + _nodeInfo->getCommunicator()->proxyToString(_nodeInfo->getYellowQuery())); // // TODO: we shouldn't generate this in the configuration. See diff --git a/cpp/src/IcePack/ServerDeployerI.cpp b/cpp/src/IcePack/ServerDeployerI.cpp index 0aa48dff273..19d495733bd 100644 --- a/cpp/src/IcePack/ServerDeployerI.cpp +++ b/cpp/src/IcePack/ServerDeployerI.cpp @@ -59,6 +59,12 @@ IcePack::ServerDeployerI::remove(const string& name, const Ice::Current&) { ServerRegistryPrx registry = _nodeInfo->getServerRegistry(); + // + // Component path is used to identify the component. For example: + // node1.server1.service3 + // + string componentPath = _nodeInfo->getNode()->getName() + "." + name; + ServerPrx server; try { @@ -69,6 +75,7 @@ IcePack::ServerDeployerI::remove(const string& name, const Ice::Current&) ServerDeploymentException ex; ex.server = name; ex.reason = "server doesn't exist"; + ex.component = componentPath; throw ex; } @@ -83,6 +90,7 @@ IcePack::ServerDeployerI::remove(const string& name, const Ice::Current&) ServerDeploymentException ex; ex.server = name; ex.reason = "server doesn't exist"; + ex.component = componentPath; throw ex; } @@ -93,8 +101,9 @@ IcePack::ServerDeployerI::remove(const string& name, const Ice::Current&) { ServerDeploymentException ex; ex.server = name; - ex.reason = "server is not from this node"; - throw ex; + ex.reason = "server is not managed by this node"; + ex.component = componentPath; + throw ex; } map<string, string> variables; @@ -102,12 +111,6 @@ IcePack::ServerDeployerI::remove(const string& name, const Ice::Current&) variables["binpath"] = desc.path; // Required for parsing to succeed. variables["libpath"] = ""; - // - // Component path is used to identify the component. For example: - // node1.server1.service3 - // - string componentPath = _nodeInfo->getNode()->getName() + "." + name; - ServerBuilder builder(_nodeInfo, variables, componentPath, desc.targets); // diff --git a/cpp/src/IcePack/ServerI.cpp b/cpp/src/IcePack/ServerI.cpp index 435fcb92ab2..b98b7c9a453 100644 --- a/cpp/src/IcePack/ServerI.cpp +++ b/cpp/src/IcePack/ServerI.cpp @@ -324,32 +324,43 @@ IcePack::ServerI::stopInternal() // manager to shutdown the server. // bool deactivate = true; + + // + // TODO: use the service manager to shutdown icebox servers. The + // following code should work once it's possible to set an + // activation mode on a per adapter basis -- we really don't want + // to activate the icebox in this method if it's already + // deactivated. + // - if(description.serviceManager) - { - try - { - // - // Set a timeout on the service manager proxy and try to - // shutdown the icebox. - // - IceBox::ServiceManagerPrx serviceManager = - IceBox::ServiceManagerPrx::uncheckedCast(description.serviceManager->ice_timeout(_waitTime)); - - serviceManager->shutdown(); - - deactivate = false; - } - catch(const Ice::LocalException& ex) - { - if(_traceLevels->server > 1) - { - Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat); - out << "couldn't contact the IceBox `" << description.name << "' service manager:\n"; - out << ex; - } - } - } +// if(description.serviceManager) +// { +// if(_state == Deactivating) +// { +// try +// { +// // +// // Set a timeout on the service manager proxy and try to +// // shutdown the icebox. +// // +// IceBox::ServiceManagerPrx serviceManager = +// IceBox::ServiceManagerPrx::uncheckedCast(description.serviceManager->ice_timeout(_waitTime)); + +// serviceManager->shutdown(); + +// deactivate = false; +// } +// catch(const Ice::LocalException& ex) +// { +// if(_traceLevels->server > 1) +// { +// Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat); +// out << "couldn't contact the IceBox `" << description.name << "' service manager:\n"; +// out << ex; +// } +// } +// } +// } if(deactivate) { diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp index 916f8c3ddd1..7b2750c2443 100644 --- a/cpp/test/Ice/location/ServerLocator.cpp +++ b/cpp/test/Ice/location/ServerLocator.cpp @@ -16,7 +16,8 @@ ServerLocatorRegistry::ServerLocatorRegistry() } void -ServerLocatorRegistry::addAdapter(const ::std::string& adapter, const ::Ice::ObjectPrx& object, const ::Ice::Current&) +ServerLocatorRegistry::setAdapterDirectProxy(const ::std::string& adapter, const ::Ice::ObjectPrx& object, + const ::Ice::Current&) { _adapters[adapter] = object; } @@ -38,12 +39,6 @@ Ice::ObjectPrx ServerLocator::findAdapterByName(const ::std::string& adapter, const ::Ice::Current&) const { return _registry->getAdapter(adapter); -// std::map< std::string, Ice::ObjectPrx >::iterator p = _adapters.find(adapter); -// if(p != _adapters.end()) -// { -// return p->second; -// } -// return 0; } Ice::LocatorRegistryPrx diff --git a/cpp/test/Ice/location/ServerLocator.h b/cpp/test/Ice/location/ServerLocator.h index c6508927059..0c8e1eda9b4 100644 --- a/cpp/test/Ice/location/ServerLocator.h +++ b/cpp/test/Ice/location/ServerLocator.h @@ -20,7 +20,7 @@ public: ServerLocatorRegistry(); - virtual void addAdapter(const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); + virtual void setAdapterDirectProxy(const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); // // Internal method |