From ac587d9f1a6d34e46956fd17c81f99beb7ed97ad Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Wed, 10 Sep 2014 19:09:53 +0000 Subject: IceGrid::Admin now provides remote access to IceGrid registry and node Admin objects, and icegridadmin uses these new operations to show the Ice log file for IceGrid registries and IceGrid nodes (ICE-2400) --- cpp/src/IceGrid/RegistryAdminRouter.cpp | 126 ++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 cpp/src/IceGrid/RegistryAdminRouter.cpp (limited to 'cpp/src/IceGrid/RegistryAdminRouter.cpp') 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 +#include + +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); +} -- cgit v1.2.3