summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-11-30 11:01:12 -0500
committerBernard Normier <bernard@zeroc.com>2007-11-30 11:01:12 -0500
commit8844c4b9cc5321fdfb537820fd0c7517756189bd (patch)
treeaab20f66038f27ac96656f6715d10805bd58874c /cpp/src
parentFixed various bugs (diff)
downloadice-8844c4b9cc5321fdfb537820fd0c7517756189bd.tar.bz2
ice-8844c4b9cc5321fdfb537820fd0c7517756189bd.tar.xz
ice-8844c4b9cc5321fdfb537820fd0c7517756189bd.zip
Implemented service observers
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/PropertyNames.cpp44
-rw-r--r--cpp/src/Ice/PropertyNames.h2
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp202
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h12
-rw-r--r--cpp/src/IceGrid/AdminCallbackRouter.cpp97
-rw-r--r--cpp/src/IceGrid/AdminCallbackRouter.h45
-rw-r--r--cpp/src/IceGrid/Makefile.mak3
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp40
-rw-r--r--cpp/src/IceGrid/RegistryI.h2
-rw-r--r--cpp/src/IceGrid/SessionServantManager.cpp10
10 files changed, 427 insertions, 30 deletions
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index f72db807b30..4cd655a1d55 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Nov 26 11:29:02 2007
+// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Nov 29 17:38:46 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -127,6 +127,7 @@ const IceInternal::PropertyArray
const IceInternal::Property IceBoxPropsData[] =
{
+ IceInternal::Property("IceBox.InheritProperties", false, 0),
IceInternal::Property("IceBox.InstanceName", false, 0),
IceInternal::Property("IceBox.LoadOrder", false, 0),
IceInternal::Property("IceBox.PrintServicesReady", false, 0),
@@ -144,8 +145,8 @@ const IceInternal::Property IceBoxPropsData[] =
IceInternal::Property("IceBox.ServiceManager.ThreadPool.SizeMax", false, 0),
IceInternal::Property("IceBox.ServiceManager.ThreadPool.SizeWarn", false, 0),
IceInternal::Property("IceBox.ServiceManager.ThreadPool.StackSize", false, 0),
+ IceInternal::Property("IceBox.Trace.ServiceObserver", false, 0),
IceInternal::Property("IceBox.UseSharedCommunicator.*", false, 0),
- IceInternal::Property("IceBox.InheritProperties", false, 0),
};
const IceInternal::PropertyArray
@@ -227,6 +228,19 @@ const IceInternal::Property IceGridPropsData[] =
IceInternal::Property("IceGrid.Node.UserAccountMapper.ThreadPerConnection", false, 0),
IceInternal::Property("IceGrid.Node.UserAccountMapper", false, 0),
IceInternal::Property("IceGrid.Node.WaitTime", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.AdapterId", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.Endpoints", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.Locator", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.PublishedEndpoints", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.RegisterProcess", true, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ReplicaGroupId", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.Router", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPerConnection", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPerConnection.StackSize", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPool.Size", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPool.SizeMax", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPool.SizeWarn", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminCallbackRouter.ThreadPool.StackSize", false, 0),
IceInternal::Property("IceGrid.Registry.AdminCryptPasswords", false, 0),
IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.EndpointSelection", false, 0),
IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.ConnectionCached", false, 0),
@@ -239,6 +253,19 @@ const IceInternal::Property IceGridPropsData[] =
IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.ThreadPerConnection", false, 0),
IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier", false, 0),
IceInternal::Property("IceGrid.Registry.AdminSessionFilters", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.AdapterId", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.Endpoints", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.PublishedEndpoints", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.RegisterProcess", true, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ReplicaGroupId", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPerConnection", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPerConnection.StackSize", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.Size", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.SizeMax", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.SizeWarn", false, 0),
+ IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.StackSize", false, 0),
IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.EndpointSelection", false, 0),
IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.ConnectionCached", false, 0),
IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.PreferSecure", false, 0),
@@ -319,19 +346,6 @@ const IceInternal::Property IceGridPropsData[] =
IceInternal::Property("IceGrid.Registry.SessionManager.ThreadPool.SizeMax", false, 0),
IceInternal::Property("IceGrid.Registry.SessionManager.ThreadPool.SizeWarn", false, 0),
IceInternal::Property("IceGrid.Registry.SessionManager.ThreadPool.StackSize", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.AdapterId", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.Endpoints", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.PublishedEndpoints", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.RegisterProcess", true, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ReplicaGroupId", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPerConnection", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPerConnection.StackSize", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.Size", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.SizeMax", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.SizeWarn", false, 0),
- IceInternal::Property("IceGrid.Registry.AdminSessionManager.ThreadPool.StackSize", false, 0),
IceInternal::Property("IceGrid.Registry.SessionTimeout", false, 0),
IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.EndpointSelection", false, 0),
IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.ConnectionCached", false, 0),
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index eeb33e1fb30..34a3bb3af23 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Nov 26 11:29:02 2007
+// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Nov 29 17:38:46 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index 491f2f5e10d..d85a4f2f1ca 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -20,11 +20,51 @@ using namespace std;
typedef IceBox::Service* (*SERVICE_FACTORY)(CommunicatorPtr);
-IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[])
- : _communicator(communicator)
+namespace
+{
+
+template<class T>
+class AMICallback : public T
+{
+public:
+
+ AMICallback(const ServiceManagerIPtr& serviceManager, const ServiceObserverPrx& observer) :
+ _serviceManager(serviceManager),
+ _observer(observer)
+ {
+ }
+
+ virtual void ice_response()
+ {
+ // ok, success
+ }
+
+ virtual void ice_exception(const Ice::Exception& ex)
+ {
+ //
+ // Drop this observer
+ //
+ _serviceManager->removeObserver(_observer, ex);
+ }
+
+private:
+ ServiceManagerIPtr _serviceManager;
+ ServiceObserverPrx _observer;
+};
+
+}
+
+
+
+
+IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
+ _communicator(communicator),
+ _traceServiceObserver(0)
{
_logger = _communicator->getLogger();
+ _traceServiceObserver = _communicator->getProperties()->getPropertyAsInt("IceBox.Trace.ServiceObserver");
+
for(int i = 1; i < argc; i++)
{
_argv.push_back(argv[i]);
@@ -78,6 +118,13 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&)
out << "ServiceManager: unknown exception in start for service " << info.name;
}
+ if(info.active)
+ {
+ vector<string> services;
+ services.push_back(name);
+ servicesStarted(services);
+ }
+
return;
}
}
@@ -122,6 +169,13 @@ IceBox::ServiceManagerI::stopService(const string& name, const Current&)
out << "ServiceManager: unknown exception in stop for service " << info.name;
}
+ if(!info.active)
+ {
+ vector<string> services;
+ services.push_back(name);
+ servicesStopped(services);
+ }
+
return;
}
}
@@ -129,6 +183,75 @@ IceBox::ServiceManagerI::stopService(const string& name, const Current&)
throw NoSuchServiceException();
}
+
+void
+IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const Ice::Current&)
+{
+ //
+ // Null observers and duplicate registrations are ignored
+ //
+
+ IceUtil::Mutex::Lock lock(*this);
+ if(observer != 0 && _observers.insert(observer).second)
+ {
+ if(_traceServiceObserver >= 1)
+ {
+ Trace out(_logger, "IceBox.ServiceObserver");
+ out << "Added service observer: " << _communicator->proxyToString(observer);
+ }
+
+ vector<string> activeServices;
+ for(vector<ServiceInfo>::iterator p = _services.begin(); p != _services.end(); ++p)
+ {
+ const ServiceInfo& info = *p;
+ if(info.active)
+ {
+ activeServices.push_back(info.name);
+ }
+ }
+
+ if(activeServices.size() > 0)
+ {
+ try
+ {
+ observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
+ activeServices);
+ }
+ catch(const std::exception& ex)
+ {
+ _observers.erase(observer);
+ observerRemoved(observer, ex);
+ }
+ catch(...)
+ {
+ _observers.erase(observer);
+ throw;
+ }
+ }
+ }
+}
+
+
+void
+IceBox::ServiceManagerI::removeObserver(const ServiceObserverPrx& observer, const Ice::Exception& ex)
+{
+ IceUtil::Mutex::Lock lock(*this);
+
+ //
+ // It's possible to remove several times the same observer, e.g. multiple concurrent
+ // requests that fail
+ //
+
+ set<ServiceObserverPrx>::iterator p = _observers.find(observer);
+ if(p != _observers.end())
+ {
+ ServiceObserverPrx observer = *p;
+ _observers.erase(p);
+ observerRemoved(observer, ex);
+ }
+}
+
+
void
IceBox::ServiceManagerI::shutdown(const Current&)
{
@@ -495,6 +618,13 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
{
info.service->start(service, communicator, info.args);
info.active = true;
+
+ //
+ // There is no need to notify the observers since the 'start all'
+ // (that indirectly calls this function) occurs before the creation of
+ // the Server Admin object, and before the activation of the main
+ // object adapter (so before any observer can be registered)
+ //
}
catch(...)
{
@@ -563,6 +693,8 @@ IceBox::ServiceManagerI::stopAll()
//
vector<ServiceInfo>::reverse_iterator p;
+ vector<string> stoppedServices;
+
//
// First, for each service, we call stop on the service and flush its database environment to
// the disk.
@@ -576,6 +708,7 @@ IceBox::ServiceManagerI::stopAll()
{
info.service->stop();
info.active = false;
+ stoppedServices.push_back(info.name);
}
catch(const Ice::Exception& ex)
{
@@ -591,6 +724,8 @@ IceBox::ServiceManagerI::stopAll()
}
}
+ servicesStopped(stoppedServices);
+
for(p = _services.rbegin(); p != _services.rend(); ++p)
{
ServiceInfo& info = *p;
@@ -674,3 +809,66 @@ IceBox::ServiceManagerI::stopAll()
_services.clear();
}
+
+void
+IceBox::ServiceManagerI::servicesStarted(const vector<string>& services)
+{
+ if(services.size() > 0)
+ {
+ //
+ // Must be called with 'this' locked
+ //
+ for(set<ServiceObserverPrx>::iterator p = _observers.begin(); p != _observers.end(); ++p)
+ {
+ ServiceObserverPrx observer = *p;
+
+ try
+ {
+ observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
+ services);
+ }
+ catch(const std::exception& ex)
+ {
+ _observers.erase(p);
+ observerRemoved(observer, ex);
+ }
+ }
+ }
+}
+
+void
+IceBox::ServiceManagerI::servicesStopped(const vector<string>& services)
+{
+ if(services.size() > 0)
+ {
+ //
+ // Must be called with 'this' locked
+ //
+ for(set<ServiceObserverPrx>::iterator p = _observers.begin(); p != _observers.end(); ++p)
+ {
+ ServiceObserverPrx observer = *p;
+
+ try
+ {
+ observer->servicesStopped_async(new AMICallback<AMI_ServiceObserver_servicesStopped>(this, observer),
+ services);
+ }
+ catch(const std::exception& ex)
+ {
+ _observers.erase(p);
+ observerRemoved(observer, ex);
+ }
+ }
+ }
+}
+
+void
+IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, const std::exception& ex)
+{
+ if(_traceServiceObserver >= 1)
+ {
+ Trace out(_logger, "IceBox.ServiceObserver");
+ out << "Removed service observer: " << _communicator->proxyToString(observer)
+ << "\nafter catching " << ex.what();
+ }
+}
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index 5484aa7b3fa..2b9d7213c80 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -30,6 +30,9 @@ public:
virtual void startService(const std::string&, const ::Ice::Current&);
virtual void stopService(const std::string&, const ::Ice::Current&);
+
+ virtual void addObserver(const ServiceObserverPrx&, const Ice::Current&);
+
virtual void shutdown(const ::Ice::Current&);
int run();
@@ -48,16 +51,25 @@ public:
bool start();
void stop();
+ void removeObserver(const ServiceObserverPrx&, const Ice::Exception&);
+
private:
void load(const std::string&, const std::string&);
void start(const std::string&, const std::string&, const ::Ice::StringSeq&);
void stopAll();
+ void servicesStarted(const std::vector<std::string>&);
+ void servicesStopped(const std::vector<std::string>&);
+ void observerRemoved(const ServiceObserverPrx&, const std::exception&);
+
::Ice::CommunicatorPtr _communicator;
::Ice::LoggerPtr _logger;
::Ice::StringSeq _argv; // Filtered server argument vector, not including program name
std::vector<ServiceInfo> _services;
+
+ std::set<ServiceObserverPrx> _observers;
+ int _traceServiceObserver;
};
typedef IceUtil::Handle<ServiceManagerI> ServiceManagerIPtr;
diff --git a/cpp/src/IceGrid/AdminCallbackRouter.cpp b/cpp/src/IceGrid/AdminCallbackRouter.cpp
new file mode 100644
index 00000000000..5d1d77f119c
--- /dev/null
+++ b/cpp/src/IceGrid/AdminCallbackRouter.cpp
@@ -0,0 +1,97 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 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/AdminCallbackRouter.h>
+
+using namespace Ice;
+using namespace std;
+
+namespace
+{
+
+class AMICallback : public AMI_Array_Object_ice_invoke
+{
+public:
+
+ AMICallback(const AMD_Array_Object_ice_invokePtr& cb) :
+ _cb(cb)
+ {
+ }
+
+ virtual void ice_response(bool ok, const std::pair<const Byte*, const Byte*>& outParams)
+ {
+ _cb->ice_response(ok, outParams);
+ }
+
+ virtual void ice_exception(const Ice::Exception& ex)
+ {
+ _cb->ice_exception(ex);
+ }
+
+private:
+ AMD_Array_Object_ice_invokePtr _cb;
+};
+
+}
+
+
+void
+IceGrid::AdminCallbackRouter::addMapping(const string& category, const ConnectionPtr& con)
+{
+ IceUtil::Mutex::Lock sync(_mutex);
+
+#ifndef NDEBUG
+ bool inserted =
+#endif
+ _categoryToConnection.insert(map<string, ConnectionPtr>::value_type(category, con)).second;
+
+ assert(inserted == true);
+}
+
+void
+IceGrid::AdminCallbackRouter::removeMapping(const string& category)
+{
+ IceUtil::Mutex::Lock sync(_mutex);
+
+#ifndef NDEBUG
+ size_t one =
+#endif
+ _categoryToConnection.erase(category);
+
+ assert(one == 1);
+}
+
+
+void
+IceGrid::AdminCallbackRouter::ice_invoke_async(const AMD_Array_Object_ice_invokePtr& cb,
+ const pair<const Byte*, const Byte*>& inParams,
+ const Current& current)
+{
+ ConnectionPtr con;
+
+ {
+ IceUtil::Mutex::Lock sync(_mutex);
+ map<string, ConnectionPtr>::iterator p = _categoryToConnection.find(current.id.category);
+ if(p == _categoryToConnection.end())
+ {
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+ con = p->second;
+ }
+
+
+ ObjectPrx target = con->createProxy(current.id)->ice_facet(current.facet);
+
+
+ //
+ // Call with AMI
+ //
+ target->ice_invoke_async(new AMICallback(cb), current.operation, current.mode, inParams, current.ctx);
+}
+
diff --git a/cpp/src/IceGrid/AdminCallbackRouter.h b/cpp/src/IceGrid/AdminCallbackRouter.h
new file mode 100644
index 00000000000..1b094744e35
--- /dev/null
+++ b/cpp/src/IceGrid/AdminCallbackRouter.h
@@ -0,0 +1,45 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 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_ADMIN_CALLBACK_ROUTER_H
+#define ICE_GRID_ADMIN_CALLBACK_ROUTER_H
+
+#include <Ice/Ice.h>
+#include <IceUtil/IceUtil.h>
+#include <map>
+
+namespace IceGrid
+{
+
+//
+// The AdminCallbackRouter routes callbacks from the servers, nodes etc. to the
+// admin clients using the admin-client => registry connection.
+//
+
+class AdminCallbackRouter : public Ice::BlobjectArrayAsync
+{
+public:
+
+ void addMapping(const std::string&, const Ice::ConnectionPtr&);
+ void removeMapping(const std::string&);
+
+
+ virtual void ice_invoke_async(const Ice::AMD_Array_Object_ice_invokePtr&,
+ const std::pair<const Ice::Byte*, const Ice::Byte*>&,
+ const Ice::Current&);
+
+private:
+
+ IceUtil::Mutex _mutex;
+ std::map<std::string, Ice::ConnectionPtr> _categoryToConnection;
+};
+
+typedef IceUtil::Handle<AdminCallbackRouter> AdminCallbackRouterPtr;
+}
+#endif
diff --git a/cpp/src/IceGrid/Makefile.mak b/cpp/src/IceGrid/Makefile.mak
index efec8a4a2cf..2de450ba634 100644
--- a/cpp/src/IceGrid/Makefile.mak
+++ b/cpp/src/IceGrid/Makefile.mak
@@ -62,7 +62,8 @@ NODE_OBJS = NodeI.obj \
Activator.obj \
NodeSessionManager.obj
-REGISTRY_OBJS = RegistryI.obj \
+REGISTRY_OBJS = AdminCallbackRouter.obj \
+ RegistryI.obj \
RegistryServerAdminRouter.obj \
InternalRegistryI.obj \
StringApplicationInfoDict.obj \
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index 294c99d76bf..f4cad69f184 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -250,6 +250,7 @@ RegistryI::start(bool nowarn)
setupThreadPool(properties, "IceGrid.Registry.Server.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.SessionManager.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Internal.ThreadPool", 1, 100);
+ setupThreadPool(properties, "IceGrid.Registry.AdminCallbackRouter.ThreadPool", 1, 1);
_replicaName = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
_master = _replicaName == "Master";
@@ -377,13 +378,14 @@ RegistryI::start(bool nowarn)
registerNodes(internalRegistry, _session.getNodes(nodes));
}
- _serverAdapter = _communicator->createObjectAdapter("IceGrid.Registry.Server");
+ Ice::ObjectAdapterPtr serverAdapter =
+ _communicator->createObjectAdapter("IceGrid.Registry.Server");
_clientAdapter = _communicator->createObjectAdapter("IceGrid.Registry.Client");
Ice::Identity dummy;
dummy.name = "dummy";
_wellKnownObjects->addEndpoint("Client", _clientAdapter->createDirectProxy(dummy));
- _wellKnownObjects->addEndpoint("Server", _serverAdapter->createDirectProxy(dummy));
+ _wellKnownObjects->addEndpoint("Server", serverAdapter->createDirectProxy(dummy));
_wellKnownObjects->addEndpoint("Internal", registryAdapter->createDirectProxy(dummy));
setupNullPermissionsVerifier(registryAdapter);
@@ -395,9 +397,16 @@ RegistryI::start(bool nowarn)
QueryPrx query = setupQuery(_clientAdapter);
RegistryPrx registry = setupRegistry(_clientAdapter);
- Ice::LocatorRegistryPrx locatorRegistry = setupLocatorRegistry(_serverAdapter);
+ Ice::LocatorRegistryPrx locatorRegistry = setupLocatorRegistry(serverAdapter);
LocatorPrx internalLocator = setupLocator(_clientAdapter, registryAdapter, locatorRegistry, registry, query);
+ AdminCallbackRouterPtr adminCallbackRouter;
+
+ if(!properties->getProperty("IceGrid.Registry.AdminCallbackRouter.Endpoints").empty())
+ {
+ adminCallbackRouter = new AdminCallbackRouter;
+ }
+
//
// Create the session servant manager. The session servant manager is responsible
// for managing sessions servants and to ensure that session servants are only
@@ -406,12 +415,15 @@ RegistryI::start(bool nowarn)
//
Ice::ObjectPtr serverAdminRouter = new RegistryServerAdminRouter(_database);
- AdminCallbackRouterPtr adminCallbackRouter = new AdminCallbackRouter;
-
_servantManager = new SessionServantManager(_clientAdapter, _instanceName, true, getServerAdminCategory(), serverAdminRouter, adminCallbackRouter);
_clientAdapter->addServantLocator(_servantManager, "");
- _serverAdapter->addServantLocator(new DefaultServantLocator(adminCallbackRouter), "");
+
+ if(adminCallbackRouter != 0)
+ {
+ _adminCallbackRouterAdapter = _communicator->createObjectAdapter("IceGrid.Registry.AdminCallbackRouter");
+ _adminCallbackRouterAdapter->addServantLocator(new DefaultServantLocator(adminCallbackRouter), "");
+ }
Ice::ObjectAdapterPtr sessionAdpt = setupClientSessionFactory(registryAdapter, internalLocator, nowarn);
Ice::ObjectAdapterPtr admSessionAdpt = setupAdminSessionFactory(registryAdapter, serverAdminRouter, internalLocator, nowarn);
@@ -429,8 +441,13 @@ RegistryI::start(bool nowarn)
//
// We are ready to go!
//
- _serverAdapter->activate();
+ serverAdapter->activate();
+ if(_adminCallbackRouterAdapter != 0)
+ {
+ _adminCallbackRouterAdapter->activate();
+ }
_clientAdapter->activate();
+
if(sessionAdpt)
{
sessionAdpt->activate();
@@ -977,7 +994,14 @@ RegistryI::shutdown()
Ice::ObjectPrx
RegistryI::createAdminCallbackProxy(const Identity& identity) const
{
- return _serverAdapter->createProxy(identity);
+ if(_adminCallbackRouterAdapter != 0)
+ {
+ return _adminCallbackRouterAdapter->createProxy(identity);
+ }
+ else
+ {
+ return 0;
+ }
}
void
diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h
index a6b93c86ab5..445cd73cca6 100644
--- a/cpp/src/IceGrid/RegistryI.h
+++ b/cpp/src/IceGrid/RegistryI.h
@@ -101,7 +101,7 @@ private:
DatabasePtr _database;
Ice::ObjectAdapterPtr _clientAdapter;
- Ice::ObjectAdapterPtr _serverAdapter;
+ Ice::ObjectAdapterPtr _adminCallbackRouterAdapter;
WellKnownObjectsManagerPtr _wellKnownObjects;
std::string _instanceName;
bool _master;
diff --git a/cpp/src/IceGrid/SessionServantManager.cpp b/cpp/src/IceGrid/SessionServantManager.cpp
index 8cbedf9b4f0..b2b8577a925 100644
--- a/cpp/src/IceGrid/SessionServantManager.cpp
+++ b/cpp/src/IceGrid/SessionServantManager.cpp
@@ -84,7 +84,10 @@ SessionServantManager::addSession(const Ice::ObjectPtr& session, const Ice::Conn
if(!category.empty() && con != 0)
{
_adminConnections.insert(con);
- _adminCallbackRouter->addMapping(category, con);
+ if(_adminCallbackRouter != 0)
+ {
+ _adminCallbackRouter->addMapping(category, con);
+ }
}
return addImpl(session, session); // Register a servant for the session and return its proxy.
@@ -184,7 +187,10 @@ SessionServantManager::removeSession(const Ice::ObjectPtr& session)
assert(_adminConnections.find(p->second.connection) != _adminConnections.end());
_adminConnections.erase(_adminConnections.find(p->second.connection));
- _adminCallbackRouter->removeMapping(p->second.category);
+ if(_adminCallbackRouter != 0)
+ {
+ _adminCallbackRouter->removeMapping(p->second.category);
+ }
}
_sessions.erase(p);