diff options
31 files changed, 725 insertions, 387 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 01c9d6d6b06..6e7734979a4 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -773,8 +773,8 @@ IceInternal::Instance::setServerProcessProxy(const ObjectAdapterPtr& adminAdapte out << "the server is not known to the locator registry"; } - throw InitializationException(__FILE__, __LINE__, "Locator knows nothing about server `" + - serverId + "'"); + throw InitializationException(__FILE__, __LINE__, "Locator `" + _proxyFactory->proxyToString(locator) + + "' knows nothing about server `" + serverId + "'"); } catch(const LocalException& ex) { diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 9f7733b06c5..b6ef3371509 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -403,7 +403,7 @@ AdminI::getServerAdminCategory(const Current&) const return _registry->getServerAdminCategory(); } -Ice::ObjectPrx +ObjectPrx AdminI::getServerAdmin(const string& id, const Current& current) const { ServerProxyWrapper proxy(_database, id); // Ensure that the server exists and loaded on the node. @@ -774,6 +774,20 @@ AdminI::getNodeInfo(const string& name, const Ice::Current&) const return toNodeInfo(_database->getNode(name)->getInfo()); } +ObjectPrx +AdminI::getNodeAdmin(const string& name, const Current& current) const +{ + // + // Check if the node exists + // + _database->getNode(name); + + Ice::Identity adminId; + adminId.name = name; + adminId.category = _registry->getNodeAdminCategory(); + return current.adapter->createProxy(adminId); +} + bool AdminI::pingNode(const string& name, const Current&) const { @@ -900,6 +914,23 @@ AdminI::getRegistryInfo(const string& name, const Ice::Current&) const } } +ObjectPrx +AdminI::getRegistryAdmin(const string& name, const Current& current) const +{ + if(name != _registry->getName()) + { + // + // Check if the replica exists + // + _database->getReplica(name); + } + + Identity adminId; + adminId.name = name; + adminId.category = _registry->getReplicaAdminCategory(); + return current.adapter->createProxy(adminId); +} + bool AdminI::pingRegistry(const string& name, const Current&) const { diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h index c552f33617c..2d882041527 100644 --- a/cpp/src/IceGrid/AdminI.h +++ b/cpp/src/IceGrid/AdminI.h @@ -75,6 +75,7 @@ public: virtual ObjectInfoSeq getAllObjectInfos(const std::string&, const ::Ice::Current&) const; virtual NodeInfo getNodeInfo(const std::string&, const Ice::Current&) const; + virtual Ice::ObjectPrx getNodeAdmin(const std::string&, const Ice::Current&) const; virtual bool pingNode(const std::string&, const Ice::Current&) const; virtual LoadInfo getNodeLoad(const std::string&, const Ice::Current&) const; virtual int getNodeProcessorSocketCount(const std::string&, const Ice::Current&) const; @@ -83,6 +84,7 @@ public: virtual Ice::StringSeq getAllNodeNames(const ::Ice::Current&) const; virtual RegistryInfo getRegistryInfo(const std::string&, const Ice::Current&) const; + virtual Ice::ObjectPrx getRegistryAdmin(const std::string&, const Ice::Current&) const; virtual bool pingRegistry(const std::string&, const Ice::Current&) const; virtual void shutdownRegistry(const std::string&, const Ice::Current&); virtual Ice::StringSeq getAllRegistryNames(const ::Ice::Current&) const; diff --git a/cpp/src/IceGrid/AdminRouter.cpp b/cpp/src/IceGrid/AdminRouter.cpp new file mode 100644 index 00000000000..3c23bf46cce --- /dev/null +++ b/cpp/src/IceGrid/AdminRouter.cpp @@ -0,0 +1,60 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceGrid/AdminRouter.h> + +using namespace Ice; +using namespace std; + +namespace +{ + +class CallbackI : public IceUtil::Shared +{ +public: + + CallbackI(const AMD_Object_ice_invokePtr& cb) : + _cb(cb) + { + } + + void response(bool ok, const pair<const Byte*, const Byte*>& outParams) + { + _cb->ice_response(ok, outParams); + } + + void exception(const Ice::Exception&) + { + // Admin object is unreachable + _cb->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); + } + +private: + AMD_Object_ice_invokePtr _cb; +}; + +} + +void +IceGrid::AdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& cb, + const pair<const Byte*, const Byte*>& inParams, + const Current& current) +{ + ObjectPrx target = getTarget(current); + assert(target != 0); + + // + // Call with AMI + // + Callback_Object_ice_invokePtr amiCb = + newCallback_Object_ice_invoke(new CallbackI(cb), &CallbackI::response, &CallbackI::exception); + + target->begin_ice_invoke(current.operation, current.mode, inParams, current.ctx, amiCb); +} + diff --git a/cpp/src/IceGrid/NodeServerAdminRouter.h b/cpp/src/IceGrid/AdminRouter.h index 55b11fbdf6c..01add9a8af6 100644 --- a/cpp/src/IceGrid/NodeServerAdminRouter.h +++ b/cpp/src/IceGrid/AdminRouter.h @@ -7,26 +7,27 @@ // // ********************************************************************** -#ifndef ICE_GRID_NODE_SERVER_ADMIN_ROUTER_H -#define ICE_GRID_NODE_SERVER_ADMIN_ROUTER_H +#ifndef ICE_GRID_ADMIN_ROUTER_H +#define ICE_GRID_ADMIN_ROUTER_H -#include <IceGrid/NodeI.h> +#include <Ice/Ice.h> namespace IceGrid { -class NodeServerAdminRouter : public Ice::BlobjectArrayAsync +// +// An Admin Router routes requests to an admin object +// +class AdminRouter : public Ice::BlobjectArrayAsync { public: - NodeServerAdminRouter(const NodeIPtr&); + virtual Ice::ObjectPrx getTarget(const Ice::Current&) = 0; virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&); - -private: - NodeIPtr _node; }; + } #endif diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 089f2d49c26..ad4e2ce1534 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -15,7 +15,7 @@ #include <Ice/Locator.h> #include <Ice/Service.h> #include <IceGrid/Activator.h> -#include <IceGrid/NodeServerAdminRouter.h> +#include <IceGrid/NodeAdminRouter.h> #include <IceGrid/RegistryI.h> #include <IceGrid/FileUserAccountMapperI.h> #include <IceGrid/NodeI.h> @@ -87,7 +87,7 @@ class CollocatedRegistry : public RegistryI { public: - CollocatedRegistry(const CommunicatorPtr&, const ActivatorPtr&, bool, bool, const std::string&); + CollocatedRegistry(const CommunicatorPtr&, const ActivatorPtr&, bool, bool, const std::string&, const std::string&); virtual void shutdown(); private: @@ -96,32 +96,6 @@ private: }; -class DefaultServantLocator : public Ice::ServantLocator -{ -public: - - DefaultServantLocator(const ObjectPtr& servant) : - _servant(servant) - { - } - - virtual ObjectPtr locate(const Current&, LocalObjectPtr&) - { - return _servant; - } - - virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&) - { - } - - virtual void deactivate(const string&) - { - } - -private: - ObjectPtr _servant; -}; - #ifdef _WIN32 void setNoIndexingAttribute(const string& pa) @@ -152,8 +126,9 @@ CollocatedRegistry::CollocatedRegistry(const CommunicatorPtr& com, const ActivatorPtr& activator, bool nowarn, bool readonly, - const string& initFromReplica) : - RegistryI(com, new TraceLevels(com, "IceGrid.Registry"), nowarn, readonly, initFromReplica), + const string& initFromReplica, + const string& nodeName) : + RegistryI(com, new TraceLevels(com, "IceGrid.Registry"), nowarn, readonly, initFromReplica, nodeName), _activator(activator) { } @@ -291,6 +266,13 @@ NodeService::startImpl(int argc, char* argv[], int& status) PropertiesPtr properties = communicator()->getProperties(); + string name = properties->getProperty("IceGrid.Node.Name"); + if(name.empty()) + { + error("property `IceGrid.Node.Name' is not set"); + return false; + } + // // Disable server idle time. Otherwise, the adapter would be // shutdown prematurely and the deactivation would fail. @@ -325,7 +307,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // if(properties->getPropertyAsInt("IceGrid.Node.CollocateRegistry") > 0) { - _registry = new CollocatedRegistry(communicator(), _activator, nowarn, readonly, initFromReplica); + _registry = new CollocatedRegistry(communicator(), _activator, nowarn, readonly, initFromReplica, name); if(!_registry->start()) { return false; @@ -418,13 +400,6 @@ NodeService::startImpl(int argc, char* argv[], int& status) return false; } - string name = properties->getProperty("IceGrid.Node.Name"); - if(name.empty()) - { - error("property `IceGrid.Node.Name' is not set"); - return false; - } - // // Setup the Freeze database environment home directory. The name of the database // environment for the IceGrid node is the name of the node. @@ -507,9 +482,8 @@ NodeService::startImpl(int argc, char* argv[], int& status) _node = new NodeI(_adapter, *_sessions, _activator, _timer, traceLevels, nodeProxy, name, mapper, instanceName); _adapter->add(_node, nodeProxy->ice_getIdentity()); - _adapter->addServantLocator(new DefaultServantLocator(new NodeServerAdminRouter(_node)), - _node->getServerAdminCategory()); - + _adapter->addDefaultServant(new NodeServerAdminRouter(_node), _node->getServerAdminCategory()); + // // Start the platform info thread if needed. // @@ -539,26 +513,18 @@ NodeService::startImpl(int argc, char* argv[], int& status) _sessions->create(_node); // - // In some tests, we deploy icegridnodes using IceGrid: + // Create Admin unless there is a collocated registry with its own Admin // - if(properties->getProperty("Ice.Admin.Endpoints") != "") + if(!_registry && properties->getPropertyAsInt("Ice.Admin.Enabled") > 0) { - // - // Replace Process facet and create Admin object - // - try - { - ProcessPtr origProcess = ProcessPtr::dynamicCast(communicator()->removeAdminFacet("Process")); - communicator()->addAdminFacet(new ProcessI(_activator, origProcess), "Process"); - communicator()->getAdmin(); - } - catch(const Ice::NotRegisteredException&) - { - // - // Some plug-in removed the Process facet, so we don't replace it. - // (unlikely error though) - // - } + // Replace Admin facet + ProcessPtr origProcess = ProcessPtr::dynamicCast(communicator()->removeAdminFacet("Process")); + communicator()->addAdminFacet(new ProcessI(_activator, origProcess), "Process"); + + Identity adminId; + adminId.name = "NodeAdmin-" + name; + adminId.category = instanceName; + communicator()->createAdmin(_adapter, adminId); } // @@ -804,9 +770,17 @@ NodeService::initializeCommunicator(int& argc, char* argv[], initData.properties = createProperties(argc, argv, initData.properties); // - // Delay creation of Admin object: + // Never create Admin object in Ice.Admin adapter // - initData.properties->setProperty("Ice.Admin.DelayCreation", "1"); + initData.properties->setProperty("Ice.Admin.Endpoints", ""); + + // + // Enable Admin unless explicitely disabled (or enabled) in configuration + // + if(initData.properties->getProperty("Ice.Admin.Enabled").empty()) + { + initData.properties->setProperty("Ice.Admin.Enabled", "1"); + } // // Setup the client thread pool size. diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index fc991d75c4c..b411ef459bc 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -129,7 +129,7 @@ RegistryService::start(int argc, char* argv[], int& status) TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Registry"); - _registry = new RegistryI(communicator(), traceLevels, nowarn, readonly, initFromReplica); + _registry = new RegistryI(communicator(), traceLevels, nowarn, readonly, initFromReplica, ""); if(!_registry->start()) { return false; @@ -191,7 +191,21 @@ RegistryService::initializeCommunicator(int& argc, char* argv[], } } } - + + + // + // Never create Admin object in Ice.Admin adapter + // + initData.properties->setProperty("Ice.Admin.Endpoints", ""); + + // + // Enable Admin unless explicitely disabled (or enabled) in configuration + // + if(initData.properties->getProperty("Ice.Admin.Enabled").empty()) + { + initData.properties->setProperty("Ice.Admin.Enabled", "1"); + } + // // Setup the client thread pool size. // @@ -202,6 +216,7 @@ RegistryService::initializeCommunicator(int& argc, char* argv[], // initData.properties->setProperty("Ice.ACM.Close", "3"); + return Service::initializeCommunicator(argc, argv, initData); } diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile index 9eec43a8c7e..d40814258c9 100644 --- a/cpp/src/IceGrid/Makefile +++ b/cpp/src/IceGrid/Makefile @@ -28,7 +28,8 @@ ADMIN_OBJS = Client.o \ Util.o \ $(SLICE_OBJS) -COMMON_OBJS = DescriptorBuilder.o \ +COMMON_OBJS = AdminRouter.o \ + DescriptorBuilder.o \ DescriptorParser.o \ FileCache.o \ PlatformInfo.o \ @@ -37,8 +38,8 @@ COMMON_OBJS = DescriptorBuilder.o \ $(SLICE_OBJS) NODE_OBJS = Activator.o \ + NodeAdminRouter.o \ NodeI.o \ - NodeServerAdminRouter.o \ NodeSessionManager.o \ ServerAdapterI.o \ ServerI.o @@ -62,8 +63,8 @@ REGISTRY_OBJS = AdminCallbackRouter.o \ PluginFacadeI.o \ QueryI.o \ ReapThread.o \ - RegistryI.o \ - RegistryServerAdminRouter.o \ + RegistryAdminRouter.o \ + RegistryI.o \ ReplicaCache.o \ ReplicaSessionI.o \ ReplicaSessionManager.o \ diff --git a/cpp/src/IceGrid/Makefile.mak b/cpp/src/IceGrid/Makefile.mak index d7c05c68f3f..e7721e60eff 100644 --- a/cpp/src/IceGrid/Makefile.mak +++ b/cpp/src/IceGrid/Makefile.mak @@ -28,7 +28,8 @@ ADMIN_OBJS = Client.obj \ Util.obj \ $(SLICE_OBJS) -COMMON_OBJS = DescriptorBuilder.obj \ +COMMON_OBJS = AdminRouter.obj \ + DescriptorBuilder.obj \ DescriptorParser.obj \ FileCache.obj \ PlatformInfo.obj \ @@ -37,8 +38,8 @@ COMMON_OBJS = DescriptorBuilder.obj \ $(SLICE_OBJS) NODE_OBJS = Activator.obj \ - NodeI.obj \ - NodeServerAdminRouter.obj \ + NodeAdminRouter.obj \ + NodeI.obj \ NodeSessionManager.obj \ ServerAdapterI.obj \ ServerI.obj @@ -62,8 +63,8 @@ REGISTRY_OBJS = AdapterCache.obj \ PluginFacadeI.obj \ QueryI.obj \ ReapThread.obj \ - RegistryI.obj \ - RegistryServerAdminRouter.obj \ + RegistryAdminRouter.obj \ + RegistryI.obj \ ReplicaCache.obj \ ReplicaSessionI.obj \ ReplicaSessionManager.obj \ diff --git a/cpp/src/IceGrid/NodeServerAdminRouter.cpp b/cpp/src/IceGrid/NodeAdminRouter.cpp index b17b93fed09..6c4631b1e93 100644 --- a/cpp/src/IceGrid/NodeServerAdminRouter.cpp +++ b/cpp/src/IceGrid/NodeAdminRouter.cpp @@ -7,7 +7,7 @@ // // ********************************************************************** -#include <IceGrid/NodeServerAdminRouter.h> +#include <IceGrid/NodeAdminRouter.h> #include <Ice/Ice.h> #include <IceGrid/ServerI.h> #include <IceGrid/ServerAdapterI.h> @@ -16,45 +16,15 @@ using namespace IceGrid; using namespace Ice; using namespace std; -namespace -{ - -class InvokeAMICallback : public AMI_Array_Object_ice_invoke -{ -public: - - InvokeAMICallback(const AMD_Object_ice_invokePtr& cb) : - _cb(cb) - { - } - - virtual void ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams) - { - _cb->ice_response(ok, outParams); - } - - virtual void ice_exception(const Ice::Exception&) - { - _cb->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); // Server admin object is unreachable - } - -private: - AMD_Object_ice_invokePtr _cb; -}; - -} IceGrid::NodeServerAdminRouter::NodeServerAdminRouter(const NodeIPtr& node) : _node(node) { } -void -IceGrid::NodeServerAdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& cb, - const pair<const Byte*, const Byte*>& inParams, - const Current& current) +ObjectPrx +IceGrid::NodeServerAdminRouter::getTarget(const Current& current) { - // // First, get the ServerI servant // @@ -86,8 +56,6 @@ IceGrid::NodeServerAdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& target = target->ice_facet(current.facet); } - // - // Call with AMI - // - target->ice_invoke_async(new InvokeAMICallback(cb), current.operation, current.mode, inParams, current.ctx); + return target; } + diff --git a/cpp/src/IceGrid/NodeAdminRouter.h b/cpp/src/IceGrid/NodeAdminRouter.h new file mode 100644 index 00000000000..046a0dc0637 --- /dev/null +++ b/cpp/src/IceGrid/NodeAdminRouter.h @@ -0,0 +1,35 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_GRID_NODE_ADMIN_ROUTER_H +#define ICE_GRID_NODE_ADMIN_ROUTER_H + +#include <IceGrid/NodeI.h> +#include <IceGrid/AdminRouter.h> + +namespace IceGrid +{ + +// +// Routes requests to a server's admin object through the Node +// +class NodeServerAdminRouter : public AdminRouter +{ +public: + + NodeServerAdminRouter(const NodeIPtr&); + + virtual Ice::ObjectPrx getTarget(const Ice::Current&); + +private: + NodeIPtr _node; +}; + +} +#endif diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index e7f138ce926..d69de22d689 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -55,16 +55,17 @@ struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPt PropertyDescriptorSeq communicatorProps = desc->propertySet.properties; // - // If this is a service communicator and the IceBox server has admin - // endpoints configured, we ignore the server-lifetime attributes of - // the service object adapters and assume it's set to false. + // If this is a service communicator and the IceBox server has Admin + // enabled or Admin endpoints configured, we ignore the server-lifetime attributes + // of the service object adapters and assume it's set to false. // bool ignoreServerLifetime = false; if(svc) { if(_iceVersion == 0 || _iceVersion >= 30300) { - if(getProperty(_desc->properties["config"], "Ice.Admin.Endpoints") != "") + if(getPropertyAsInt(_desc->properties["config"], "Ice.Admin.Enabled") > 0 || + getProperty(_desc->properties["config"], "Ice.Admin.Endpoints") != "") { ignoreServerLifetime = true; } @@ -538,6 +539,17 @@ NodeEntry::getSession() const return _session; } +Ice::ObjectPrx +NodeEntry::getAdminProxy() const +{ + Ice::ObjectPrx prx = getProxy(); + assert(prx); + Ice::Identity adminId; + adminId.name = "NodeAdmin-" + _name ; + adminId.category = prx->ice_getIdentity().category; + return prx->ice_identity(adminId); +} + bool NodeEntry::canRemove() { @@ -939,12 +951,18 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const if(iceVersion == 0 || iceVersion >= 30300) { props.push_back(createProperty("Ice.Admin.ServerId", info.descriptor->id)); - if(hasProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints")) + + if(hasProperty(info.descriptor->propertySet.properties, "Ice.Admin.Enabled")) { - if(getProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints") != "") - { - server->processRegistered = true; - } + // Ice.Admin.Enabled explicitely set, leave Ice.Admin.Endpoints alone + server->processRegistered = + getPropertyAsInt(info.descriptor->propertySet.properties, "Ice.Admin.Enabled") > 0; + } + else if(hasProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints")) + { + // Ice.Admin.Endpoints explicitely set, check if not "" + server->processRegistered = + getProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints") != ""; } else { @@ -955,6 +973,10 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const else { props.push_back(createProperty("Ice.ServerId", info.descriptor->id)); + // + // Prior to Ice 3.3, use adapter's registerProcess to compute server->processRegistered; + // see ToInternalServerDescriptor::operator() above + // } props.push_back(createProperty("Ice.ProgramName", info.descriptor->id)); diff --git a/cpp/src/IceGrid/NodeCache.h b/cpp/src/IceGrid/NodeCache.h index 187d8e0e617..5b9d0a99401 100644 --- a/cpp/src/IceGrid/NodeCache.h +++ b/cpp/src/IceGrid/NodeCache.h @@ -52,6 +52,8 @@ public: LoadInfo getLoadInfoAndLoadFactor(const std::string&, float&) const; NodeSessionIPtr getSession() const; + Ice::ObjectPrx getAdminProxy() const; + bool canRemove(); void loadServer(const ServerEntryPtr&, const ServerInfo&, const SessionIPtr&, int, bool); diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 97c4c077b7e..e0a3205ffeb 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -1181,7 +1181,7 @@ NodeI::createServerIdentity(const string& name) const string NodeI::getServerAdminCategory() const { - return _instanceName + "-NodeRouter"; + return _instanceName + "-NodeServerAdminRouter"; } vector<ServerCommandPtr> diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 951ef773f97..75b1153109f 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -2352,107 +2352,120 @@ void Parser::showLog(const string& id, const string& reader, bool tail, bool follow, int lineCount) { cout << endl; + + Ice::ObjectPrx admin; if(reader == "server") { - Ice::ObjectPrx serverAdmin = _admin->getServerAdmin(id); + admin = _admin->getServerAdmin(id); + } + else if(reader == "node") + { + admin = _admin->getNodeAdmin(id); + } + else if(reader == "registry") + { + admin = _admin->getRegistryAdmin(id); + } - Ice::LoggerAdminPrx loggerAdmin; - try - { - loggerAdmin = Ice::LoggerAdminPrx::checkedCast(serverAdmin, "Logger"); - } - catch(const Ice::Exception&) - { - loggerAdmin = 0; - } + if(admin == 0) + { + error("cannot retrieve Admin proxy for " + reader + " `" + id + "'"); + return; + } + + Ice::LoggerAdminPrx loggerAdmin; + + try + { + loggerAdmin = Ice::LoggerAdminPrx::checkedCast(admin, "Logger"); + } + catch(const Ice::Exception&) + { + } + + if(loggerAdmin == 0) + { + error("cannot retrieve Logger admin facet for " + reader + " `" + id + "'"); + return; + } - if(loggerAdmin == 0) + if(follow) + { + Ice::ObjectPrx adminCallbackTemplate = _session->getAdminCallbackTemplate(); + + if(adminCallbackTemplate == 0) { - error("cannot retrieve Logger facet for server '" + id + "'"); + error("cannot retriever Callback template from IceGrid registry"); return; } - if(follow) + const Ice::EndpointSeq endpoints = adminCallbackTemplate->ice_getEndpoints(); + string publishedEndpoints; + + for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) { - Ice::ObjectPrx adminCallbackTemplate = _session->getAdminCallbackTemplate(); - - if(adminCallbackTemplate == 0) + if(publishedEndpoints.empty()) { - error("cannot retriever Callback template from IceGrid registry"); - return; - } - - const Ice::EndpointSeq endpoints = adminCallbackTemplate->ice_getEndpoints(); - string publishedEndpoints; - - for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) - { - if(publishedEndpoints.empty()) - { - publishedEndpoints = (*p)->toString(); - } - else - { - publishedEndpoints += ":" + (*p)->toString(); - } + publishedEndpoints = (*p)->toString(); } - - _communicator->getProperties()->setProperty("RemoteLoggerAdapter.PublishedEndpoints", publishedEndpoints); - - Ice::ObjectAdapterPtr adapter = - _communicator->createObjectAdapter("RemoteLoggerAdapter"); - - _session->ice_getConnection()->setAdapter(adapter); - - Ice::Identity id; - id.name = "RemoteLogger-" + IceUtil::generateUUID(); - id.category = adminCallbackTemplate->ice_getIdentity().category; - - RemoteLoggerIPtr servant = new RemoteLoggerI; - Ice::RemoteLoggerPrx prx = - Ice::RemoteLoggerPrx::uncheckedCast(adapter->add(servant, id)); - adapter->activate(); - - loggerAdmin->attachRemoteLogger(prx, Ice::LogMessageTypeSeq(), Ice::StringSeq(), - tail ? lineCount : -1); - - resetInterrupt(); + else { - Lock lock(*this); - while(!_interrupted) - { - wait(); - } + publishedEndpoints += ":" + (*p)->toString(); } - - servant->destroy(); - adapter->destroy(); + } + + _communicator->getProperties()->setProperty("RemoteLoggerAdapter.PublishedEndpoints", publishedEndpoints); + + Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapter("RemoteLoggerAdapter"); + + _session->ice_getConnection()->setAdapter(adapter); + + Ice::Identity id; + id.name = "RemoteLogger-" + IceUtil::generateUUID(); + id.category = adminCallbackTemplate->ice_getIdentity().category; + + RemoteLoggerIPtr servant = new RemoteLoggerI; + Ice::RemoteLoggerPrx prx = + Ice::RemoteLoggerPrx::uncheckedCast(adapter->add(servant, id)); + adapter->activate(); + + loggerAdmin->attachRemoteLogger(prx, Ice::LogMessageTypeSeq(), Ice::StringSeq(), tail ? lineCount : -1); - try - { - loggerAdmin->detachRemoteLogger(prx); - } - catch(const Ice::ObjectNotExistException&) - { - // ignored - } - catch(const Ice::RemoteLoggerNotAttachedException&) + resetInterrupt(); + { + Lock lock(*this); + while(!_interrupted) { - // ignored + wait(); } } - else + + servant->destroy(); + adapter->destroy(); + + try + { + loggerAdmin->detachRemoteLogger(prx); + } + catch(const Ice::ObjectNotExistException&) { - string prefix; - const Ice::LogMessageSeq logMessages = - loggerAdmin->getLog(Ice::LogMessageTypeSeq(), Ice::StringSeq(), - tail ? lineCount : -1, prefix); + // ignored + } + catch(const Ice::RemoteLoggerNotAttachedException&) + { + // ignored + } + } + else + { + string prefix; + const Ice::LogMessageSeq logMessages = loggerAdmin->getLog(Ice::LogMessageTypeSeq(), Ice::StringSeq(), + tail ? lineCount : -1, prefix); - for(Ice::LogMessageSeq::const_iterator p = logMessages.begin(); p != logMessages.end(); ++p) - { - printLogMessage(prefix, *p); - } + for(Ice::LogMessageSeq::const_iterator p = logMessages.begin(); p != logMessages.end(); ++p) + { + printLogMessage(prefix, *p); } } } diff --git a/cpp/src/IceGrid/RegistryAdminRouter.cpp b/cpp/src/IceGrid/RegistryAdminRouter.cpp new file mode 100644 index 00000000000..51c85c34dd2 --- /dev/null +++ b/cpp/src/IceGrid/RegistryAdminRouter.cpp @@ -0,0 +1,126 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceGrid/RegistryAdminRouter.h> +#include <Ice/Ice.h> + +using namespace IceGrid; +using namespace Ice; +using namespace std; + + +IceGrid::RegistryServerAdminRouter::RegistryServerAdminRouter(const DatabasePtr& database) : + _database(database) +{ +} + +ObjectPrx +IceGrid::RegistryServerAdminRouter::getTarget(const Current& current) +{ + ObjectPrx target = 0; + + try + { + target = _database->getServer(current.id.name)->getAdminProxy(); + } + catch(const ServerNotExistException&) + { + } + catch(const NodeUnreachableException&) + { + } + catch(const DeploymentException&) + { + } + + if(target == 0) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + return target->ice_facet(current.facet); +} + + +IceGrid::RegistryNodeAdminRouter::RegistryNodeAdminRouter(const string& collocNodeName, const DatabasePtr& database) : + _collocNodeName(collocNodeName), + _database(database) +{ +} + +ObjectPrx +IceGrid::RegistryNodeAdminRouter::getTarget(const Current& current) +{ + ObjectPrx target; + + if(!_collocNodeName.empty() && current.id.name == _collocNodeName) + { + // Straight to the local Admin object + target = current.adapter->getCommunicator()->getAdmin(); + } + else + { + try + { + target = _database->getNode(current.id.name)->getAdminProxy(); + } + catch(const NodeUnreachableException&) + { + } + catch(const NodeNotExistException&) + { + } + + if(target == 0) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + } + + return target->ice_facet(current.facet); +} + + + +IceGrid::RegistryReplicaAdminRouter::RegistryReplicaAdminRouter(const string& name, + const DatabasePtr& database) : + _name(name), + _database(database) +{ +} + +ObjectPrx +IceGrid::RegistryReplicaAdminRouter::getTarget(const Current& current) +{ + ObjectPrx target; + + if(current.id.name == _name) + { + // Straight to the local Admin object + target = current.adapter->getCommunicator()->getAdmin(); + } + else + { + try + { + // Forward to Admin object in remote replica + target = _database->getReplica(current.id.name)->getAdminProxy(); + } + catch(const RegistryNotExistException&) + { + } + } + + if(target == 0) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + return target->ice_facet(current.facet); +} diff --git a/cpp/src/IceGrid/RegistryAdminRouter.h b/cpp/src/IceGrid/RegistryAdminRouter.h new file mode 100644 index 00000000000..0048eb98fd8 --- /dev/null +++ b/cpp/src/IceGrid/RegistryAdminRouter.h @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_GRID_REGISTRY_ADMIN_ROUTER_H +#define ICE_GRID_REGISTRY_ADMIN_ROUTER_H + +#include <IceGrid/Database.h> +#include <IceGrid/AdminRouter.h> + +namespace IceGrid +{ + +class RegistryServerAdminRouter : public AdminRouter +{ +public: + + RegistryServerAdminRouter(const DatabasePtr&); + + virtual Ice::ObjectPrx getTarget(const Ice::Current&); + +private: + + const DatabasePtr _database; +}; + + +class RegistryNodeAdminRouter : public AdminRouter +{ +public: + + RegistryNodeAdminRouter(const std::string&, const DatabasePtr&); + + virtual Ice::ObjectPrx getTarget(const Ice::Current&); + +private: + + const std::string _collocNodeName; + const DatabasePtr _database; +}; + +class RegistryReplicaAdminRouter : public AdminRouter +{ +public: + + RegistryReplicaAdminRouter(const std::string&, const DatabasePtr&); + + virtual Ice::ObjectPrx getTarget(const Ice::Current&); + +private: + + const std::string _name; + const DatabasePtr _database; +}; + + +} +#endif diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index ad81676d9b1..0f8edea64ff 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -37,7 +37,7 @@ #include <IceGrid/WellKnownObjectsManager.h> #include <IceGrid/FileCache.h> -#include <IceGrid/RegistryServerAdminRouter.h> +#include <IceGrid/RegistryAdminRouter.h> #include <fstream> @@ -50,32 +50,6 @@ using namespace IceGrid; namespace { -class DefaultServantLocator : public Ice::ServantLocator -{ -public: - - DefaultServantLocator(const ObjectPtr& servant) : - _servant(servant) - { - } - - virtual ObjectPtr locate(const Current&, LocalObjectPtr&) - { - return _servant; - } - - virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&) - { - } - - virtual void deactivate(const string&) - { - } - -private: - ObjectPtr _servant; -}; - class LookupI : public IceGrid::Lookup { public: @@ -130,18 +104,54 @@ private: const WellKnownObjectsManagerPtr _wellKnownObjects; }; +class ProcessI : public Process +{ +public: + + ProcessI(const RegistryIPtr&, const ProcessPtr&); + + virtual void shutdown(const Current&); + virtual void writeMessage(const std::string&, Int, const Current&); + +private: + + RegistryIPtr _registry; + ProcessPtr _origProcess; +}; + + +ProcessI::ProcessI(const RegistryIPtr& registry, const ProcessPtr& origProcess) : + _registry(registry), + _origProcess(origProcess) +{ +} + +void +ProcessI::shutdown(const Current&) +{ + _registry->shutdown(); +} + +void +ProcessI::writeMessage(const string& message, Int fd, const Current& current) +{ + _origProcess->writeMessage(message, fd, current); +} + } RegistryI::RegistryI(const CommunicatorPtr& communicator, const TraceLevelsPtr& traceLevels, bool nowarn, bool readonly, - const string& initFromReplica) : + const string& initFromReplica, + const string& collocatedNodeName) : _communicator(communicator), _traceLevels(traceLevels), _nowarn(nowarn), _readonly(readonly), _initFromReplica(initFromReplica), + _collocatedNodeName(collocatedNodeName), _platform("IceGrid.Registry", communicator, traceLevels) { } @@ -516,16 +526,21 @@ RegistryI::startImpl() // Create the session servant manager. The session servant manager is responsible // for managing sessions servants and to ensure that session servants are only // accessed by the connection that created the session. The session servant manager - // also takes care of providing the router servant for server admin objects. + // also takes care of providing router servants for admin objects. // ObjectPtr serverAdminRouter = new RegistryServerAdminRouter(_database); + ObjectPtr nodeAdminRouter = new RegistryNodeAdminRouter(_collocatedNodeName, _database); + ObjectPtr replicaAdminRouter = new RegistryReplicaAdminRouter(_replicaName, _database); AdminCallbackRouterPtr adminCallbackRouter = new AdminCallbackRouter; - _servantManager = new SessionServantManager(_clientAdapter, _instanceName, true, getServerAdminCategory(), - serverAdminRouter, adminCallbackRouter); - + _servantManager = new SessionServantManager(_clientAdapter, _instanceName, true, + getServerAdminCategory(), serverAdminRouter, + getNodeAdminCategory(), nodeAdminRouter, + getReplicaAdminCategory(), replicaAdminRouter, + adminCallbackRouter); + _clientAdapter->addServantLocator(_servantManager, ""); - _serverAdapter->addServantLocator(new DefaultServantLocator(adminCallbackRouter), ""); + _serverAdapter->addDefaultServant(adminCallbackRouter, ""); vector<string> verifierProperties; verifierProperties.push_back("IceGrid.Registry.PermissionsVerifier"); @@ -536,7 +551,8 @@ RegistryI::startImpl() Glacier2Internal::setupNullPermissionsVerifier(_communicator, _instanceName, verifierProperties); ObjectAdapterPtr sessionAdpt = setupClientSessionFactory(internalLocator); - ObjectAdapterPtr admSessionAdpt = setupAdminSessionFactory(serverAdminRouter, internalLocator); + ObjectAdapterPtr admSessionAdpt = setupAdminSessionFactory(serverAdminRouter, nodeAdminRouter, replicaAdminRouter, + internalLocator); _wellKnownObjects->finish(); if(_master) @@ -687,6 +703,21 @@ RegistryI::setupInternalRegistry() Ice::ObjectPrx proxy = _registryAdapter->add(internalRegistry, internalRegistryId); _wellKnownObjects->add(proxy, InternalRegistry::ice_staticId()); + // + // Create Admin + // + if(_communicator->getProperties()->getPropertyAsInt("Ice.Admin.Enabled") > 0) + { + // Replace Admin facet + ProcessPtr origProcess = ProcessPtr::dynamicCast(_communicator->removeAdminFacet("Process")); + _communicator->addAdminFacet(new ProcessI(this, origProcess), "Process"); + + Identity adminId; + adminId.name = "RegistryAdmin-" + _replicaName; + adminId.category = _instanceName; + _communicator->createAdmin(_registryAdapter, adminId); + } + InternalRegistryPrx registry = InternalRegistryPrx::uncheckedCast(proxy); _database->getReplicaCache().setInternalRegistry(registry); return registry; @@ -735,7 +766,7 @@ RegistryI::setupClientSessionFactory(const IceGrid::LocatorPrx& locator) if(!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty()) { adapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager"); - servantManager = new SessionServantManager(adapter, _instanceName, false, "", 0, 0); + servantManager = new SessionServantManager(adapter, _instanceName, false, "", 0, "", 0, "", 0, 0); adapter->addServantLocator(servantManager, ""); } @@ -773,7 +804,8 @@ RegistryI::setupClientSessionFactory(const IceGrid::LocatorPrx& locator) } Ice::ObjectAdapterPtr -RegistryI::setupAdminSessionFactory(const Ice::ObjectPtr& router, const IceGrid::LocatorPrx& locator) +RegistryI::setupAdminSessionFactory(const Ice::ObjectPtr& serverAdminRouter, const Ice::ObjectPtr& nodeAdminRouter, + const Ice::ObjectPtr& replicaAdminRouter, const IceGrid::LocatorPrx& locator) { Ice::PropertiesPtr properties = _communicator->getProperties(); @@ -782,7 +814,10 @@ RegistryI::setupAdminSessionFactory(const Ice::ObjectPtr& router, const IceGrid: if(!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty()) { adapter = _communicator->createObjectAdapter("IceGrid.Registry.AdminSessionManager"); - servantManager = new SessionServantManager(adapter, _instanceName, false, getServerAdminCategory(), router, 0); + servantManager = new SessionServantManager(adapter, _instanceName, false, + getServerAdminCategory(), serverAdminRouter, + getNodeAdminCategory(), nodeAdminRouter, + getReplicaAdminCategory(), replicaAdminRouter, 0); adapter->addServantLocator(servantManager, ""); } diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h index 704ed0dd9f9..76a59b0cb06 100644 --- a/cpp/src/IceGrid/RegistryI.h +++ b/cpp/src/IceGrid/RegistryI.h @@ -51,7 +51,7 @@ class RegistryI : public Registry { public: - RegistryI(const Ice::CommunicatorPtr&, const TraceLevelsPtr&, bool, bool, const std::string&); + RegistryI(const Ice::CommunicatorPtr&, const TraceLevelsPtr&, bool, bool, const std::string&, const std::string&); ~RegistryI(); bool start(); @@ -73,7 +73,9 @@ public: void waitForShutdown(); virtual void shutdown(); - std::string getServerAdminCategory() const { return _instanceName + "-RegistryRouter"; } + std::string getServerAdminCategory() const { return _instanceName + "-RegistryServerAdminRouter"; } + std::string getNodeAdminCategory() const { return _instanceName + "-RegistryNodeAdminRouter"; } + std::string getReplicaAdminCategory() const { return _instanceName + "-RegistryReplicaAdminRouter"; } Ice::ObjectPrx createAdminCallbackProxy(const Ice::Identity&) const; @@ -90,7 +92,8 @@ private: InternalRegistryPrx setupInternalRegistry(); bool setupUserAccountMapper(); Ice::ObjectAdapterPtr setupClientSessionFactory(const LocatorPrx&); - Ice::ObjectAdapterPtr setupAdminSessionFactory(const Ice::ObjectPtr&, const LocatorPrx&); + Ice::ObjectAdapterPtr setupAdminSessionFactory(const Ice::ObjectPtr&, const Ice::ObjectPtr&, + const Ice::ObjectPtr&, const LocatorPrx&); Glacier2::PermissionsVerifierPrx getPermissionsVerifier(const LocatorPrx&, const std::string&); Glacier2::SSLPermissionsVerifierPrx getSSLPermissionsVerifier(const LocatorPrx&, const std::string&); @@ -104,6 +107,7 @@ private: const bool _nowarn; const bool _readonly; const std::string _initFromReplica; + const std::string _collocatedNodeName; DatabasePtr _database; Ice::ObjectAdapterPtr _clientAdapter; diff --git a/cpp/src/IceGrid/RegistryServerAdminRouter.cpp b/cpp/src/IceGrid/RegistryServerAdminRouter.cpp deleted file mode 100644 index 6189e4dbcc0..00000000000 --- a/cpp/src/IceGrid/RegistryServerAdminRouter.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceGrid/RegistryServerAdminRouter.h> -#include <Ice/Ice.h> - -using namespace IceGrid; -using namespace Ice; -using namespace std; - -namespace -{ - -class InvokeAMICallback : public AMI_Array_Object_ice_invoke -{ -public: - - InvokeAMICallback(const AMD_Object_ice_invokePtr& cb) : - _cb(cb) - { - } - - virtual void ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams) - { - _cb->ice_response(ok, outParams); - } - - virtual void ice_exception(const Ice::Exception&) - { - _cb->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); // Server admin object is unreachable - } - -private: - AMD_Object_ice_invokePtr _cb; -}; - -} - -IceGrid::RegistryServerAdminRouter::RegistryServerAdminRouter(const DatabasePtr& database) : - _database(database) -{ -} - -void -IceGrid::RegistryServerAdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& cb, - const pair<const Byte*, const Byte*>& inParams, - const Current& current) -{ - ObjectPrx target = 0; - - try - { - target = _database->getServer(current.id.name)->getAdminProxy(); - } - catch(const ServerNotExistException&) - { - } - catch(const NodeUnreachableException&) - { - } - catch(const DeploymentException&) - { - } - - if(target == 0) - { - throw ObjectNotExistException(__FILE__, __LINE__); - } - - // - // Set the facet - // - target = target->ice_facet(current.facet); - - // - // Call with AMI - // - target->ice_invoke_async(new InvokeAMICallback(cb), current.operation, current.mode, inParams, current.ctx); -} diff --git a/cpp/src/IceGrid/RegistryServerAdminRouter.h b/cpp/src/IceGrid/RegistryServerAdminRouter.h deleted file mode 100644 index e6763849088..00000000000 --- a/cpp/src/IceGrid/RegistryServerAdminRouter.h +++ /dev/null @@ -1,34 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_GRID_REGISTRY_SERVER_ADMIN_ROUTER_H -#define ICE_GRID_REGISTRY_SERVER_ADMIN_ROUTER_H - -#include <IceGrid/Database.h> - -namespace IceGrid -{ - -class RegistryServerAdminRouter : public Ice::BlobjectArrayAsync -{ -public: - - RegistryServerAdminRouter(const DatabasePtr&); - - virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, - const std::pair<const Ice::Byte*, const Ice::Byte*>&, - const Ice::Current&); - -private: - - const DatabasePtr _database; -}; - -} -#endif diff --git a/cpp/src/IceGrid/ReplicaCache.cpp b/cpp/src/IceGrid/ReplicaCache.cpp index 269dffb1d24..f0a22e58d06 100644 --- a/cpp/src/IceGrid/ReplicaCache.cpp +++ b/cpp/src/IceGrid/ReplicaCache.cpp @@ -279,3 +279,13 @@ ReplicaEntry::getProxy() const return _session->getInternalRegistry(); } +Ice::ObjectPrx +ReplicaEntry::getAdminProxy() const +{ + Ice::ObjectPrx prx = getProxy(); + assert(prx); + Ice::Identity adminId; + adminId.name = "RegistryAdmin-" + _name; + adminId.category = prx->ice_getIdentity().category; + return prx->ice_identity(adminId); +} diff --git a/cpp/src/IceGrid/ReplicaCache.h b/cpp/src/IceGrid/ReplicaCache.h index 6e7e2ec7f7b..333f47c759e 100644 --- a/cpp/src/IceGrid/ReplicaCache.h +++ b/cpp/src/IceGrid/ReplicaCache.h @@ -35,6 +35,8 @@ public: const ReplicaSessionIPtr& getSession() const; InternalReplicaInfoPtr getInfo() const; InternalRegistryPrx getProxy() const; + + Ice::ObjectPrx getAdminProxy() const; private: diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index 00a392a85cb..3c5abf094dd 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -455,7 +455,7 @@ ServerEntry::getAdminProxy() // Ice::Identity adminId; adminId.name = _id; - adminId.category = _cache.getInstanceName() + "-NodeRouter"; + adminId.category = _cache.getInstanceName() + "-NodeServerAdminRouter"; try { return getProxy(true)->ice_identity(adminId); diff --git a/cpp/src/IceGrid/SessionServantManager.cpp b/cpp/src/IceGrid/SessionServantManager.cpp index 6f85ff9ccff..a0a54302fe6 100644 --- a/cpp/src/IceGrid/SessionServantManager.cpp +++ b/cpp/src/IceGrid/SessionServantManager.cpp @@ -21,12 +21,20 @@ SessionServantManager::SessionServantManager(const Ice::ObjectAdapterPtr& adapte bool checkConnection, const string& serverAdminCategory, const Ice::ObjectPtr& serverAdminRouter, + const string& nodeAdminCategory, + const Ice::ObjectPtr& nodeAdminRouter, + const string& replicaAdminCategory, + const Ice::ObjectPtr& replicaAdminRouter, const AdminCallbackRouterPtr& adminCallbackRouter) : _adapter(adapter), _instanceName(instanceName), _checkConnection(checkConnection), _serverAdminCategory(serverAdminCategory), _serverAdminRouter(serverAdminRouter), + _nodeAdminCategory(nodeAdminCategory), + _nodeAdminRouter(nodeAdminRouter), + _replicaAdminCategory(replicaAdminCategory), + _replicaAdminRouter(replicaAdminRouter), _adminCallbackRouter(adminCallbackRouter) { } @@ -35,26 +43,43 @@ Ice::ObjectPtr SessionServantManager::locate(const Ice::Current& current, Ice::LocalObjectPtr&) { Lock sync(*this); + Ice::ObjectPtr servant; + bool plainServant = false; + if(_serverAdminRouter && current.id.category == _serverAdminCategory) { - if(_checkConnection && _adminConnections.find(current.con) == _adminConnections.end()) - { - return 0; - } - else - { - return _serverAdminRouter; - } + servant = _serverAdminRouter; + } + else if(_nodeAdminRouter && current.id.category == _nodeAdminCategory) + { + servant = _nodeAdminRouter; + } + else if(_replicaAdminRouter && current.id.category == _replicaAdminCategory) + { + servant = _replicaAdminRouter; } else { + plainServant = true; + map<Ice::Identity, ServantInfo>::const_iterator p = _servants.find(current.id); if(p == _servants.end() || (_checkConnection && p->second.connection != current.con)) { - return 0; + servant = 0; + } + else + { + servant = p->second.servant; } - return p->second.servant; } + + if(!plainServant && servant && _checkConnection && + _adminConnections.find(current.con) == _adminConnections.end()) + { + servant = 0; + } + + return servant; } void diff --git a/cpp/src/IceGrid/SessionServantManager.h b/cpp/src/IceGrid/SessionServantManager.h index 814371e64a5..5fba8a18b64 100644 --- a/cpp/src/IceGrid/SessionServantManager.h +++ b/cpp/src/IceGrid/SessionServantManager.h @@ -25,8 +25,11 @@ class SessionServantManager : public Ice::ServantLocator, public IceUtil::Mutex { public: - SessionServantManager(const Ice::ObjectAdapterPtr&, const std::string&, bool, const std::string&, - const Ice::ObjectPtr&, const AdminCallbackRouterPtr&); + SessionServantManager(const Ice::ObjectAdapterPtr&, const std::string&, bool, + const std::string&, const Ice::ObjectPtr&, + const std::string&, const Ice::ObjectPtr&, + const std::string&, const Ice::ObjectPtr&, + const AdminCallbackRouterPtr&); Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&); void finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&); @@ -74,6 +77,10 @@ private: const bool _checkConnection; const std::string _serverAdminCategory; const Ice::ObjectPtr _serverAdminRouter; + const std::string _nodeAdminCategory; + const Ice::ObjectPtr _nodeAdminRouter; + const std::string _replicaAdminCategory; + const Ice::ObjectPtr _replicaAdminRouter; const AdminCallbackRouterPtr _adminCallbackRouter; std::map<Ice::Identity, ServantInfo> _servants; diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp index 5b0fc8d72fc..3d402b4f278 100644 --- a/cpp/src/IceGrid/Util.cpp +++ b/cpp/src/IceGrid/Util.cpp @@ -78,6 +78,31 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name return result; } +int +IceGrid::getPropertyAsInt(const PropertyDescriptorSeq& properties, const string& name, int def) +{ + string strVal; + for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) + { + if(q->name == name) + { + strVal = q->value; + } + } + + int result = def; + + if(!strVal.empty()) + { + istringstream v(strVal); + if(!(v >> result) || !v.eof()) + { + result = def; + } + } + return result; +} + bool IceGrid::hasProperty(const PropertyDescriptorSeq& properties, const string& name) { diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h index 4400516cfb8..608a2f76571 100644 --- a/cpp/src/IceGrid/Util.h +++ b/cpp/src/IceGrid/Util.h @@ -40,6 +40,8 @@ std::string toString(const std::vector<std::string>&, const std::string& = std:: std::string toString(const Ice::Exception&); std::string getProperty(const PropertyDescriptorSeq&, const std::string&, const std::string& = std::string()); +int getPropertyAsInt(const PropertyDescriptorSeq&, const std::string&, int = 0); + bool hasProperty(const PropertyDescriptorSeq&, const std::string&); PropertyDescriptor createProperty(const std::string&, const std::string& = std::string()); std::string escapeProperty(const std::string&, bool = false); diff --git a/cpp/test/Ice/Makefile.mak b/cpp/test/Ice/Makefile.mak index 677b9d433df..10c9e92d648 100644 --- a/cpp/test/Ice/Makefile.mak +++ b/cpp/test/Ice/Makefile.mak @@ -48,7 +48,7 @@ SUBDIRS = $(SUBDIRS) \ gc \ interceptor \ logger \ - networkProxy + networkProxy \ properties \ servantLocator \ slicing \ diff --git a/cpp/test/IceGrid/replication/application.xml b/cpp/test/IceGrid/replication/application.xml index ef30515ed2e..a96761a6292 100644 --- a/cpp/test/IceGrid/replication/application.xml +++ b/cpp/test/IceGrid/replication/application.xml @@ -19,7 +19,7 @@ <property name="IceGrid.Node.Trace.Adapter" value="0"/> <property name="Ice.Trace.Network" value="0"/> <property name="Ice.Warn.Connections" value="0"/> - <property name="Ice.Admin.Endpoints" value=""/> + <property name="Ice.Admin.Enabled" value="0"/> <property name="Ice.Default.EncodingVersion" value="${encoding}"/> </server> @@ -58,7 +58,7 @@ <property name="Ice.Warn.Connections" value="0"/> <property name="IceGrid.Registry.Trace.Locator" value="0"/> <property name="IceGrid.Registry.UserAccounts" value="${test.dir}/useraccounts.txt"/> - <property name="Ice.Admin.Endpoints" value=""/> + <property name="Ice.Admin.Enabled" value="0"/> <property name="Ice.Default.EncodingVersion" value="${encoding}"/> </server> diff --git a/slice/IceGrid/Admin.ice b/slice/IceGrid/Admin.ice index 837b92e935f..f76459cc0c6 100644 --- a/slice/IceGrid/Admin.ice +++ b/slice/IceGrid/Admin.ice @@ -682,6 +682,7 @@ interface Admin idempotent Object* getServerAdmin(string id) throws ServerNotExistException, NodeUnreachableException, DeploymentException; + /** * * Enable or disable a server. A disabled server can't be started @@ -1058,6 +1059,24 @@ interface Admin ["nonmutating", "cpp:const"] idempotent NodeInfo getNodeInfo(string name) throws NodeNotExistException, NodeUnreachableException; + + /** + * + * Get a proxy to the IceGrid node's admin object. + * + * @param name The IceGrid node name + * + * @return A proxy to the IceGrid node's admin object + * + * @throws NodeNotExistException Raised if the node doesn't exist. + * + * @throws NodeUnreachableException Raised if the node could not be + * reached. + * + **/ + ["cpp:const"] idempotent Object* getNodeAdmin(string name) + throws NodeNotExistException, NodeUnreachableException; + /** * * Get the number of physical processor sockets for the machine @@ -1156,6 +1175,20 @@ interface Admin /** * + * Get a proxy to the IceGrid registry's admin object + * + * @param name The registry name + * + * @return A proxy to the IceGrid registry's admin object + * + * @throws RegistryNotExistException Raised if the registry doesn't exist. + * + **/ + ["cpp:const"] idempotent Object* getRegistryAdmin(string name) + throws RegistryNotExistException; + + /** + * * Shutdown an IceGrid registry. * * @param name The registry name. @@ -1171,7 +1204,7 @@ interface Admin /** * - * Get all the IceGrid registrys currently registered. + * Get all the IceGrid registries currently registered. * * @return The registry names. * |