summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/CHANGES5
-rw-r--r--cpp/demo/IcePack/hello/HelloI.cpp4
-rw-r--r--cpp/include/IceUtil/StringUtil.h8
-rw-r--r--cpp/slice/IcePack/Admin.ice54
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp1
-rw-r--r--cpp/src/Ice/PropertiesI.cpp52
-rw-r--r--cpp/src/Ice/PropertiesI.h2
-rw-r--r--cpp/src/IcePack/AdapterRegistryI.cpp4
-rw-r--r--cpp/src/IcePack/AdminI.cpp87
-rw-r--r--cpp/src/IcePack/AdminI.h4
-rw-r--r--cpp/src/IcePack/Grammar.y30
-rw-r--r--cpp/src/IcePack/IcePackNode.cpp16
-rw-r--r--cpp/src/IcePack/Internal.ice9
-rw-r--r--cpp/src/IcePack/LocatorI.cpp2
-rw-r--r--cpp/src/IcePack/NodeRegistryI.cpp46
-rw-r--r--cpp/src/IcePack/ObjectRegistryI.cpp26
-rw-r--r--cpp/src/IcePack/ObjectRegistryI.h5
-rw-r--r--cpp/src/IcePack/Parser.cpp83
-rw-r--r--cpp/src/IcePack/Parser.h2
-rw-r--r--cpp/src/IcePack/Registry.cpp10
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp48
21 files changed, 356 insertions, 142 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 76a3c28a648..ec90e730746 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,11 @@
Changes since version 2.0.0
---------------------------
+- Added 'object list' and 'object describe' IcePack admin commands.
+
+- Changed the signature of IcePack::Admin::removeObject() to take the identity
+ of the object instead of its proxy.
+
- Connection validation now checks for the timeout specified by the property
Ice.Override.ConnectTimeout and will raise Ice::ConnectTimeoutException if
the connection validation times out.
diff --git a/cpp/demo/IcePack/hello/HelloI.cpp b/cpp/demo/IcePack/hello/HelloI.cpp
index 0b95713079f..3b04f141ad6 100644
--- a/cpp/demo/IcePack/hello/HelloI.cpp
+++ b/cpp/demo/IcePack/hello/HelloI.cpp
@@ -93,7 +93,7 @@ HelloFactoryI::find(const string& name, const Ice::Current& current) const
// been removed from the object registry.
//
IcePack::AdminPrx admin = IcePack::AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin"));
- admin->removeObject(communicator->stringToProxy(name));
+ admin->removeObject(Ice::stringToIdentity(name));
throw NameNotExistException();
}
}
@@ -120,7 +120,7 @@ HelloI::destroy(const Ice::Current& current)
// from the IcePack object registry.
//
IcePack::AdminPrx admin = IcePack::AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin"));
- admin->removeObject(adapter->createProxy(current.id));
+ admin->removeObject(current.id);
//
// Remove the Hello object from the object adapter.
diff --git a/cpp/include/IceUtil/StringUtil.h b/cpp/include/IceUtil/StringUtil.h
index 16325a4489f..c5ceaa45326 100644
--- a/cpp/include/IceUtil/StringUtil.h
+++ b/cpp/include/IceUtil/StringUtil.h
@@ -35,6 +35,14 @@ ICE_UTIL_API bool unescapeString(const std::string&, std::string::size_type, std
//
ICE_UTIL_API std::string::size_type checkQuote(const std::string&, std::string::size_type = 0);
+//
+// Match `s' against the pattern `pat'. A * in the pattern acts
+// as a wildcard: it matches any non-empty sequence of characters
+// other than a period (`.'). We match by hand here because
+// it's portable across platforms (whereas regex() isn't).
+//
+ICE_UTIL_API bool match(const std::string&, const std::string&);
+
}
#endif
diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice
index 1c46d09590b..a4daca5be27 100644
--- a/cpp/slice/IcePack/Admin.ice
+++ b/cpp/slice/IcePack/Admin.ice
@@ -610,7 +610,7 @@ interface Admin
*
* Get a server's state.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @return The server state.
*
@@ -632,7 +632,7 @@ interface Admin
* Get a server's system process id. The process id is operating
* system dependent.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @return The server process id.
*
@@ -653,7 +653,7 @@ interface Admin
*
* Get the server's activation mode.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @return The server activation mode.
*
@@ -674,7 +674,7 @@ interface Admin
*
* Set the server's activation mode.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @return The server activation mode.
*
@@ -695,7 +695,7 @@ interface Admin
*
* Start a server.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @return True if the server was successfully started, false
* otherwise.
@@ -714,7 +714,7 @@ interface Admin
*
* Stop a server.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
*
* @throws ServerNotExistException Raised if the server is not
* found.
@@ -731,7 +731,8 @@ interface Admin
*
* Send signal to a server.
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
+ *
* @param signal The signal, for example SIGTERM or 15.
*
* @throws ServerNotExistException Raised if the server is not
@@ -751,8 +752,10 @@ interface Admin
*
* Write message on server stdout or stderr
*
- * @param name Must match the name of [ServerDescription::name].
+ * @param name The name of the server.
+ *
* @param message The message.
+ *
* @param fd 1 for stdout, 2 for stderr.
*
* @throws ServerNotExistException Raised if the server is not
@@ -835,17 +838,48 @@ interface Admin
*
* Remove an object from the object registry.
*
- * @param obj The object to be removed from the registry.
+ * @param id The identity of the object to be removed from the
+ * registry.
*
* @throws ObjectNotExistException Raised if the object cannot be
* found.
*
**/
- void removeObject(Object* obj)
+ void removeObject(Ice::Identity id)
+ throws ObjectNotExistException;
+
+ /**
+ *
+ * Get the object descriptor if the object with the given
+ * identity.
+ *
+ * @param id The identity of the object.
+ *
+ * @return The object descriptor.
+ *
+ * @throws ObjectNotExistExcpetion Raised if the object cannot be
+ * found.
+ *
+ **/
+ nonmutating ObjectDescriptor getObjectDescriptor(Ice::Identity id)
throws ObjectNotExistException;
/**
*
+ * List all the objects registered with the object registry and
+ * which have a stringified identity matching the given expression.
+ *
+ * @param expr The expression to use to match against the
+ * stringified identity of the object.
+ *
+ * @return All the object descriptors with a stringified identity
+ * matching the given expression.
+ *
+ **/
+ nonmutating ObjectDescriptorSeq getAllObjectDescriptors(string patt);
+
+ /**
+ *
* Ping an &IcePack; node to see if it is active.
*
* @param name The node name.
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 1c3f8e53766..a62ad4ea906 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -1093,6 +1093,7 @@ IceInternal::IncomingConnectionFactory::run()
// can accept connections with this factory's
// acceptor. Therefore we don't call validate() in thread per
// connection mode.
+ //
}
}
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index ad67bff93a0..95063f3e188 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <IceUtil/StringUtil.h>
#include <Ice/PropertiesI.h>
#include <Ice/Initialize.h>
#include <Ice/LocalException.h>
@@ -91,55 +92,6 @@ Ice::PropertiesI::getPropertiesForPrefix(const string& prefix)
return result;
}
-//
-// Match `s' against the pattern `pat'. A * in the pattern acts
-// as a wildcard: it matches any non-empty sequence of characters
-// other than a period (`.'). We match by hand here because
-// it's portable across platforms (whereas regex() isn't).
-//
-
-bool
-Ice::PropertiesI::match(const string& s, const string& pat)
-{
- assert(!s.empty());
- assert(!pat.empty());
-
- if(pat.find('*') == string::npos)
- {
- return s == pat;
- }
-
- string::size_type sIndex = 0;
- string::size_type patIndex = 0;
- do
- {
- if(pat[patIndex] == '*')
- {
- if(s[sIndex] == '.') // Don't allow matching x..y against x.*.y -- star matches non-empty sequence only.
- {
- return false;
- }
- while(sIndex < s.size() && s[sIndex] != '.')
- {
- ++sIndex;
- }
- patIndex++;
- }
- else
- {
- if(pat[patIndex] != s[sIndex])
- {
- return false;
- }
- ++sIndex;
- ++patIndex;
- }
- }
- while(sIndex < s.size() && patIndex < pat.size());
-
- return sIndex == s.size() && patIndex == pat.size();
-}
-
void
Ice::PropertiesI::setProperty(const string& key, const string& value)
{
@@ -171,7 +123,7 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
bool found = false;
for(const char* const* j = *i; *j != 0 && !found; ++j)
{
- found = match(key, *j);
+ found = IceUtil::match(key, *j);
}
if(!found)
{
diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h
index 1ce58dc3b74..ac6a611224b 100644
--- a/cpp/src/Ice/PropertiesI.h
+++ b/cpp/src/Ice/PropertiesI.h
@@ -46,8 +46,6 @@ private:
void loadConfig();
- static bool match(const std::string&, const std::string&);
-
std::map<std::string, std::string> _properties;
};
diff --git a/cpp/src/IcePack/AdapterRegistryI.cpp b/cpp/src/IcePack/AdapterRegistryI.cpp
index 7e6fbaf0c0e..7c30a753765 100644
--- a/cpp/src/IcePack/AdapterRegistryI.cpp
+++ b/cpp/src/IcePack/AdapterRegistryI.cpp
@@ -65,7 +65,7 @@ IcePack::AdapterRegistryI::add(const string& id, const AdapterPrx& adapter, cons
if(_traceLevels->adapterRegistry > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->adapterRegistryCat);
- out << "added adapter `" << id << "'";
+ out << "updated adapter `" << id << "'";
}
}
else
@@ -120,7 +120,7 @@ IcePack::AdapterRegistryI::findById(const string& id, const Ice::Current&)
StringObjectProxyDict::iterator p = dict.find(id);
if(p != dict.end())
{
- return AdapterPrx::uncheckedCast(p->second->ice_collocationOptimization(false));
+ return AdapterPrx::uncheckedCast(p->second);
}
throw AdapterNotExistException();
}
diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp
index 9c21ab78345..8c9089376e7 100644
--- a/cpp/src/IcePack/AdminI.cpp
+++ b/cpp/src/IcePack/AdminI.cpp
@@ -1021,7 +1021,7 @@ ServerCleaner::visitObject(const ObjectWrapper&, const ObjectDescriptor& object)
{
try
{
- _objectRegistry->remove(object.proxy);
+ _objectRegistry->remove(object.proxy->ice_getIdentity());
}
catch(const ObjectNotExistException&)
{
@@ -1029,9 +1029,12 @@ ServerCleaner::visitObject(const ObjectWrapper&, const ObjectDescriptor& object)
}
}
-IcePack::AdminI::AdminI(const CommunicatorPtr& communicator, const NodeRegistryPtr& nodeRegistry,
- const ApplicationRegistryPtr& applicationRegistry, const ServerRegistryPtr& serverRegistry,
- const AdapterRegistryPtr& adapterRegistry, const ObjectRegistryPtr& objectRegistry) :
+AdminI::AdminI(const CommunicatorPtr& communicator,
+ const NodeRegistryPtr& nodeRegistry,
+ const ApplicationRegistryPtr& applicationRegistry,
+ const ServerRegistryPtr& serverRegistry,
+ const AdapterRegistryPtr& adapterRegistry,
+ const ObjectRegistryPtr& objectRegistry) :
_communicator(communicator),
_nodeRegistry(nodeRegistry),
_applicationRegistry(applicationRegistry),
@@ -1041,12 +1044,12 @@ IcePack::AdminI::AdminI(const CommunicatorPtr& communicator, const NodeRegistryP
{
}
-IcePack::AdminI::~AdminI()
+AdminI::~AdminI()
{
}
void
-IcePack::AdminI::addApplication(const ApplicationDescriptorPtr& descriptor, const Current&)
+AdminI::addApplication(const ApplicationDescriptorPtr& descriptor, const Current&)
{
ApplicationDeployer(_nodeRegistry,
_applicationRegistry,
@@ -1057,7 +1060,7 @@ IcePack::AdminI::addApplication(const ApplicationDescriptorPtr& descriptor, cons
}
void
-IcePack::AdminI::updateApplication(const ApplicationDescriptorPtr& descriptor, const Current&)
+AdminI::updateApplication(const ApplicationDescriptorPtr& descriptor, const Current&)
{
ApplicationUpdater(_nodeRegistry,
_applicationRegistry,
@@ -1068,7 +1071,7 @@ IcePack::AdminI::updateApplication(const ApplicationDescriptorPtr& descriptor, c
}
void
-IcePack::AdminI::removeApplication(const string& name, const Current&)
+AdminI::removeApplication(const string& name, const Current&)
{
ApplicationCleaner(_nodeRegistry,
_applicationRegistry,
@@ -1079,19 +1082,19 @@ IcePack::AdminI::removeApplication(const string& name, const Current&)
}
ApplicationDescriptorPtr
-IcePack::AdminI::getApplicationDescriptor(const string& name, const Current&) const
+AdminI::getApplicationDescriptor(const string& name, const Current&) const
{
return _applicationRegistry->getDescriptor(name);
}
Ice::StringSeq
-IcePack::AdminI::getAllApplicationNames(const Current&) const
+AdminI::getAllApplicationNames(const Current&) const
{
return _applicationRegistry->getAll();
}
void
-IcePack::AdminI::addServer(const ServerDescriptorPtr& server, const Current&)
+AdminI::addServer(const ServerDescriptorPtr& server, const Current&)
{
if(!server->application.empty())
{
@@ -1110,7 +1113,7 @@ IcePack::AdminI::addServer(const ServerDescriptorPtr& server, const Current&)
}
void
-IcePack::AdminI::updateServer(const ServerDescriptorPtr& server, const Current&)
+AdminI::updateServer(const ServerDescriptorPtr& server, const Current&)
{
ServerDescriptorPtr orig = _serverRegistry->getDescriptor(server->name);
if(!orig->application.empty())
@@ -1177,7 +1180,7 @@ IcePack::AdminI::updateServer(const ServerDescriptorPtr& server, const Current&)
}
void
-IcePack::AdminI::removeServer(const string& name, const Current&)
+AdminI::removeServer(const string& name, const Current&)
{
ServerDescriptorPtr server = _serverRegistry->getDescriptor(name);
if(!server->application.empty())
@@ -1197,13 +1200,13 @@ IcePack::AdminI::removeServer(const string& name, const Current&)
}
ServerDescriptorPtr
-IcePack::AdminI::getServerDescriptor(const string& name, const Current&) const
+AdminI::getServerDescriptor(const string& name, const Current&) const
{
return _serverRegistry->getDescriptor(name);
}
ServerState
-IcePack::AdminI::getServerState(const string& name, const Current&) const
+AdminI::getServerState(const string& name, const Current&) const
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1221,7 +1224,7 @@ IcePack::AdminI::getServerState(const string& name, const Current&) const
}
Ice::Int
-IcePack::AdminI::getServerPid(const string& name, const Current&) const
+AdminI::getServerPid(const string& name, const Current&) const
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1239,7 +1242,7 @@ IcePack::AdminI::getServerPid(const string& name, const Current&) const
}
bool
-IcePack::AdminI::startServer(const string& name, const Current&)
+AdminI::startServer(const string& name, const Current&)
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1257,7 +1260,7 @@ IcePack::AdminI::startServer(const string& name, const Current&)
}
void
-IcePack::AdminI::stopServer(const string& name, const Current&)
+AdminI::stopServer(const string& name, const Current&)
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1275,7 +1278,7 @@ IcePack::AdminI::stopServer(const string& name, const Current&)
}
void
-IcePack::AdminI::sendSignal(const string& name, const string& signal, const Current&)
+AdminI::sendSignal(const string& name, const string& signal, const Current&)
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1293,7 +1296,7 @@ IcePack::AdminI::sendSignal(const string& name, const string& signal, const Curr
}
void
-IcePack::AdminI::writeMessage(const string& name, const string& message, Int fd, const Current&)
+AdminI::writeMessage(const string& name, const string& message, Int fd, const Current&)
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1312,13 +1315,13 @@ IcePack::AdminI::writeMessage(const string& name, const string& message, Int fd,
StringSeq
-IcePack::AdminI::getAllServerNames(const Current&) const
+AdminI::getAllServerNames(const Current&) const
{
return _serverRegistry->getAll();
}
ServerActivation
-IcePack::AdminI::getServerActivation(const ::std::string& name, const Ice::Current&) const
+AdminI::getServerActivation(const ::std::string& name, const Ice::Current&) const
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1336,7 +1339,7 @@ IcePack::AdminI::getServerActivation(const ::std::string& name, const Ice::Curre
}
void
-IcePack::AdminI::setServerActivation(const ::std::string& name, ServerActivation mode, const Ice::Current&)
+AdminI::setServerActivation(const ::std::string& name, ServerActivation mode, const Ice::Current&)
{
ServerPrx server = _serverRegistry->findByName(name);
try
@@ -1354,7 +1357,7 @@ IcePack::AdminI::setServerActivation(const ::std::string& name, ServerActivation
}
string
-IcePack::AdminI::getAdapterEndpoints(const string& id, const Current&) const
+AdminI::getAdapterEndpoints(const string& id, const Current&) const
{
AdapterPrx adapter = _adapterRegistry->findById(id);
try
@@ -1376,13 +1379,13 @@ IcePack::AdminI::getAdapterEndpoints(const string& id, const Current&) const
}
StringSeq
-IcePack::AdminI::getAllAdapterIds(const Current&) const
+AdminI::getAllAdapterIds(const Current&) const
{
return _adapterRegistry->getAll();
}
void
-IcePack::AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
+AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
{
ObjectDescriptor desc;
desc.proxy = proxy;
@@ -1400,7 +1403,7 @@ IcePack::AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& cu
}
void
-IcePack::AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const ::Ice::Current&)
+AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const ::Ice::Current&)
{
ObjectDescriptor desc;
desc.proxy = proxy;
@@ -1409,13 +1412,25 @@ IcePack::AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& ty
}
void
-IcePack::AdminI::removeObject(const Ice::ObjectPrx& proxy, const Ice::Current&)
+AdminI::removeObject(const Ice::Identity& id, const Ice::Current&)
{
- _objectRegistry->remove(proxy);
+ _objectRegistry->remove(id);
+}
+
+ObjectDescriptor
+AdminI::getObjectDescriptor(const Ice::Identity& id, const Ice::Current&) const
+{
+ return _objectRegistry->getObjectDescriptor(id);
+}
+
+ObjectDescriptorSeq
+AdminI::getAllObjectDescriptors(const string& expression, const Ice::Current&) const
+{
+ return _objectRegistry->findAll(expression);
}
bool
-IcePack::AdminI::pingNode(const string& name, const Current&) const
+AdminI::pingNode(const string& name, const Current&) const
{
NodePrx node = _nodeRegistry->findByName(name);
try
@@ -1434,7 +1449,7 @@ IcePack::AdminI::pingNode(const string& name, const Current&) const
}
void
-IcePack::AdminI::shutdownNode(const string& name, const Current&)
+AdminI::shutdownNode(const string& name, const Current&)
{
NodePrx node = _nodeRegistry->findByName(name);
try
@@ -1452,7 +1467,7 @@ IcePack::AdminI::shutdownNode(const string& name, const Current&)
}
void
-IcePack::AdminI::removeNode(const string& name, const Current&)
+AdminI::removeNode(const string& name, const Current&)
{
//
// Remove the node servers.
@@ -1475,7 +1490,7 @@ IcePack::AdminI::removeNode(const string& name, const Current&)
}
string
-IcePack::AdminI::getNodeHostname(const string& name, const Current&) const
+AdminI::getNodeHostname(const string& name, const Current&) const
{
NodePrx node = _nodeRegistry->findByName(name);
try
@@ -1494,19 +1509,19 @@ IcePack::AdminI::getNodeHostname(const string& name, const Current&) const
StringSeq
-IcePack::AdminI::getAllNodeNames(const Current&) const
+AdminI::getAllNodeNames(const Current&) const
{
return _nodeRegistry->getAll();
}
void
-IcePack::AdminI::shutdown(const Current&)
+AdminI::shutdown(const Current&)
{
_communicator->shutdown();
}
SliceChecksumDict
-IcePack::AdminI::getSliceChecksums(const Current&) const
+AdminI::getSliceChecksums(const Current&) const
{
return sliceChecksums();
}
diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h
index e723c57b570..8b7e6e79387 100644
--- a/cpp/src/IcePack/AdminI.h
+++ b/cpp/src/IcePack/AdminI.h
@@ -49,7 +49,9 @@ public:
virtual void addObject(const ::Ice::ObjectPrx&, const ::Ice::Current&);
virtual void addObjectWithType(const ::Ice::ObjectPrx&, const ::std::string&, const ::Ice::Current&);
- virtual void removeObject(const ::Ice::ObjectPrx&, const ::Ice::Current&);
+ virtual void removeObject(const ::Ice::Identity&, const ::Ice::Current&);
+ virtual ObjectDescriptor getObjectDescriptor(const Ice::Identity&, const ::Ice::Current&) const;
+ virtual ObjectDescriptorSeq getAllObjectDescriptors(const std::string&, const ::Ice::Current&) const;
virtual bool pingNode(const std::string&, const Ice::Current&) const;
virtual void shutdownNode(const std::string&, const Ice::Current&);
diff --git a/cpp/src/IcePack/Grammar.y b/cpp/src/IcePack/Grammar.y
index 01810a77ccc..4a4434e7db7 100644
--- a/cpp/src/IcePack/Grammar.y
+++ b/cpp/src/IcePack/Grammar.y
@@ -211,6 +211,18 @@ command
{
parser->findObject($3);
}
+| ICE_PACK_OBJECT ICE_PACK_LIST optional_strings ';'
+{
+ parser->listObject($3);
+}
+| ICE_PACK_OBJECT ICE_PACK_DESCRIBE optional_strings ';'
+{
+ parser->describeObject($3);
+}
+| ICE_PACK_OBJECT ICE_PACK_LIST ';'
+{
+ parser->listObject(YYSTYPE());
+}
| ICE_PACK_SHUTDOWN ';'
{
parser->shutdown();
@@ -246,4 +258,22 @@ strings
}
;
+// ----------------------------------------------------------------------
+optional_strings
+// ----------------------------------------------------------------------
+: ICE_PACK_STRING optional_strings
+{
+ $$ = $2;
+ $$.push_front($1.front());
+}
+| ICE_PACK_STRING
+{
+ $$ = $1;
+}
+|
+{
+ $$ = YYSTYPE()
+}
+;
+
%%
diff --git a/cpp/src/IcePack/IcePackNode.cpp b/cpp/src/IcePack/IcePackNode.cpp
index 45ff530b406..c6673a2c474 100644
--- a/cpp/src/IcePack/IcePackNode.cpp
+++ b/cpp/src/IcePack/IcePackNode.cpp
@@ -240,15 +240,23 @@ IcePack::NodeService::start(int argc, char* argv[])
struct _stat filestat;
if(::_stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- error("property `IcePack.Node.Data' is not set to a valid directory path");
- return false;
+ ostringstream os;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ os << ex;
+ error("property `IcePack.Node.Data' is set to an invalid path:\n" + os.str());
+ return false;
}
#else
struct stat filestat;
if(::stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- error("property `IcePack.Node.Data' is not set to a valid directory path");
- return false;
+ ostringstream os;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ os << ex;
+ error("property `IcePack.Node.Data' is set to an invalid path:\n" + os.str());
+ return false;
}
#endif
diff --git a/cpp/src/IcePack/Internal.ice b/cpp/src/IcePack/Internal.ice
index 654c60618d7..2b1d459de0b 100644
--- a/cpp/src/IcePack/Internal.ice
+++ b/cpp/src/IcePack/Internal.ice
@@ -38,7 +38,7 @@ interface ObjectRegistry
* Remove an object from the registry.
*
**/
- void remove(Object* obj)
+ void remove(Ice::Identity id)
throws ObjectNotExistException;
/**
@@ -70,6 +70,13 @@ interface ObjectRegistry
*
**/
nonmutating Ice::ObjectProxySeq findAllWithType(string type);
+
+ /**
+ *
+ * Find all the objects matching the given expression.
+ *
+ **/
+ nonmutating ObjectDescriptorSeq findAll(string expression);
};
/**
diff --git a/cpp/src/IcePack/LocatorI.cpp b/cpp/src/IcePack/LocatorI.cpp
index 6c78c23f400..5f87a60a5af 100644
--- a/cpp/src/IcePack/LocatorI.cpp
+++ b/cpp/src/IcePack/LocatorI.cpp
@@ -206,7 +206,7 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
AdapterPrx adapter;
try
{
- adapter = AdapterPrx::uncheckedCast(_adapterRegistry->findById(id));
+ adapter = AdapterPrx::uncheckedCast(_adapterRegistry->findById(id)->ice_collocationOptimization(false));
}
catch(const AdapterNotExistException&)
{
diff --git a/cpp/src/IcePack/NodeRegistryI.cpp b/cpp/src/IcePack/NodeRegistryI.cpp
index b75fb2290d0..63b8dec540c 100644
--- a/cpp/src/IcePack/NodeRegistryI.cpp
+++ b/cpp/src/IcePack/NodeRegistryI.cpp
@@ -101,42 +101,44 @@ NodeRegistryI::add(const string& name, const NodePrx& node, const Ice::Current&
break;
}
- AdapterPrx adapter;
- while(!adapter)
+ //
+ // Set the direct proxy of the node object adapter.
+ //
+ while(true)
{
try
{
- adapter = _adapterRegistry->findById("IcePack.Node." + name);
-
//
// TODO: ensure this adapter has been created by the adapter factory. It's possible that an
// adapter has been created with the same name. In such a case, the best is probably to
// prevent the node registration by throwing an appropriate exception. The user would then
// need to remove the adapter from the adapter registry to be able to run the node.
//
+
+ AdapterPrx adapter = _adapterRegistry->findById("IcePack.Node." + name);
+ adapter->setDirectProxy(node);
+ return;
}
catch(const AdapterNotExistException&)
{
- //
- // Create and register the node adapter.
- //
- adapter = _adapterFactory->createStandaloneAdapter("IcePackNodeAdapter." + name);
- try
- {
- _adapterRegistry->add("IcePack.Node." + name, adapter);
- }
- catch(const AdapterExistsException&)
- {
- adapter->destroy();
- adapter = 0;
- }
}
- }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
- //
- // Set the direct proxy of the node object adapter.
- //
- adapter->setDirectProxy(node);
+ //
+ // Create and register the node adapter.
+ //
+ AdapterPrx adapter = _adapterFactory->createStandaloneAdapter("IcePackNodeAdapter." + name);
+ try
+ {
+ _adapterRegistry->add("IcePack.Node." + name, adapter);
+ }
+ catch(const AdapterExistsException&)
+ {
+ adapter->destroy();
+ }
+ }
}
void
diff --git a/cpp/src/IcePack/ObjectRegistryI.cpp b/cpp/src/IcePack/ObjectRegistryI.cpp
index caaba45b346..2fd46f9bc83 100644
--- a/cpp/src/IcePack/ObjectRegistryI.cpp
+++ b/cpp/src/IcePack/ObjectRegistryI.cpp
@@ -7,6 +7,8 @@
//
// **********************************************************************
+#include <IceUtil/StringUtil.h>
+#include <Ice/IdentityUtil.h>
#include <IcePack/ObjectRegistryI.h>
#include <IcePack/TraceLevels.h>
#include <Freeze/Initialize.h>
@@ -84,7 +86,7 @@ ObjectRegistryI::add(const ObjectDescriptor& obj, const Ice::Current&)
}
void
-ObjectRegistryI::remove(const Ice::ObjectPrx& object, const Ice::Current&)
+ObjectRegistryI::remove(const Ice::Identity& id, const Ice::Current&)
{
IceUtil::Mutex::Lock sync(*this);
@@ -92,8 +94,6 @@ ObjectRegistryI::remove(const Ice::ObjectPrx& object, const Ice::Current&)
IdentityObjectDescDict objects(connection, _objectsDbName);
StringObjectProxySeqDict types(connection, _typesDbName);
- Ice::Identity id = object->ice_getIdentity();
-
IdentityObjectDescDict::iterator p = objects.find(id);
if(p == objects.end())
{
@@ -152,6 +152,7 @@ ObjectRegistryI::getObjectDescriptor(const Ice::Identity& id, const Ice::Current
Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
IdentityObjectDescDict objects(connection, _objectsDbName);
+
IdentityObjectDescDict::iterator p = objects.find(id);
if(p == objects.end())
{
@@ -206,3 +207,22 @@ ObjectRegistryI::findAllWithType(const string& type, const Ice::Current&) const
return p->second;
}
+
+ObjectDescriptorSeq
+ObjectRegistryI::findAll(const string& expression, const Ice::Current&) const
+{
+ Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
+ IdentityObjectDescDict objects(connection, _objectsDbName);
+
+ ObjectDescriptorSeq result;
+ for(IdentityObjectDescDict::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ if(expression.empty() ||
+ IceUtil::match(Ice::identityToString(p->second.proxy->ice_getIdentity()), expression))
+ {
+ result.push_back(p->second);
+ }
+ }
+ return result;
+}
+
diff --git a/cpp/src/IcePack/ObjectRegistryI.h b/cpp/src/IcePack/ObjectRegistryI.h
index 318ef874ebf..a232e79f803 100644
--- a/cpp/src/IcePack/ObjectRegistryI.h
+++ b/cpp/src/IcePack/ObjectRegistryI.h
@@ -28,14 +28,15 @@ public:
ObjectRegistryI(const Ice::CommunicatorPtr& communicator, const std::string&, const TraceLevelsPtr& traceLevels);
virtual void add(const IcePack::ObjectDescriptor&, const ::Ice::Current&);
- virtual void remove(const Ice::ObjectPrx&, const ::Ice::Current&);
+ virtual void remove(const Ice::Identity&, const ::Ice::Current&);
virtual ObjectDescriptor getObjectDescriptor(const Ice::Identity&, const ::Ice::Current&) const;
virtual Ice::ObjectPrx findById(const ::Ice::Identity&, const ::Ice::Current&) const;
virtual Ice::ObjectPrx findByType(const std::string&, const ::Ice::Current&) const;
virtual Ice::ObjectProxySeq findAllWithType(const std::string&, const ::Ice::Current&) const;
-
+ virtual ObjectDescriptorSeq findAll(const std::string&, const ::Ice::Current&) const;
+
private:
static const std::string _objectsDbName;
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
index dcd710a43fc..eaef6e75a37 100644
--- a/cpp/src/IcePack/Parser.cpp
+++ b/cpp/src/IcePack/Parser.cpp
@@ -25,6 +25,7 @@
#endif
#include <iterator>
+#include <iomanip>
extern FILE* yyin;
extern int yydebug;
@@ -322,6 +323,10 @@ IcePack::Parser::usage()
" optionally specifying its type.\n"
"object remove IDENTITY Remove an object from the object registry.\n"
"object find TYPE Find all objects with the type TYPE.\n"
+ "object describe EXPR Describe all registered objects whose stringified\n"
+ " identity match EXPR.\n"
+ "object list EXPR List all registered objects whose stringified\n"
+ " identity match EXPR.\n"
"\n"
"shutdown Shut the IcePack registry down.\n"
#ifdef GPL_BUILD
@@ -1118,7 +1123,14 @@ IcePack::Parser::endpointsAdapter(const list<string>& args)
try
{
string endpoints = _admin->getAdapterEndpoints(args.front());
- cout << endpoints << endl;
+ if(endpoints.empty())
+ {
+ cout << "<inactive>" << endl;
+ }
+ else
+ {
+ cout << endpoints << endl;
+ }
}
catch(const Ice::Exception& ex)
{
@@ -1194,7 +1206,7 @@ IcePack::Parser::removeObject(const list<string>& args)
try
{
- _admin->removeObject(_communicator->stringToProxy((*(args.begin()))));
+ _admin->removeObject(Ice::stringToIdentity((*(args.begin()))));
}
catch(const Ice::Exception& ex)
{
@@ -1230,6 +1242,73 @@ IcePack::Parser::findObject(const list<string>& args)
}
void
+IcePack::Parser::describeObject(const list<string>& args)
+{
+ try
+ {
+ ObjectDescriptorSeq objects;
+ if(args.size() == 1)
+ {
+ string arg = *(args.begin());
+ if(arg.find('*') == string::npos)
+ {
+ ObjectDescriptor desc = _admin->getObjectDescriptor(Ice::stringToIdentity(arg));
+ cout << "proxy = " << _communicator->proxyToString(desc.proxy) << endl;
+ cout << "type = " << desc.type << endl;
+ return;
+ }
+ else
+ {
+ objects = _admin->getAllObjectDescriptors(arg);
+ }
+ }
+ else
+ {
+ objects = _admin->getAllObjectDescriptors("");
+ }
+
+ for(ObjectDescriptorSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
+IcePack::Parser::listObject(const list<string>& args)
+{
+ try
+ {
+ ObjectDescriptorSeq objects;
+ if(args.size() == 1)
+ {
+ objects = _admin->getAllObjectDescriptors(*(args.begin()));
+ }
+ else
+ {
+ objects = _admin->getAllObjectDescriptors("");
+ }
+
+ for(ObjectDescriptorSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << Ice::identityToString(p->proxy->ice_getIdentity()) << endl;
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
IcePack::Parser::shutdown()
{
try
diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h
index 9ee4f3997d5..36781b29667 100644
--- a/cpp/src/IcePack/Parser.h
+++ b/cpp/src/IcePack/Parser.h
@@ -98,6 +98,8 @@ public:
void addObject(const std::list<std::string>&);
void removeObject(const std::list<std::string>&);
void findObject(const std::list<std::string>&);
+ void describeObject(const std::list<std::string>&);
+ void listObject(const std::list<std::string>&);
void shutdown();
diff --git a/cpp/src/IcePack/Registry.cpp b/cpp/src/IcePack/Registry.cpp
index 3a83ec1a862..ee2a8b87df1 100644
--- a/cpp/src/IcePack/Registry.cpp
+++ b/cpp/src/IcePack/Registry.cpp
@@ -79,8 +79,10 @@ IcePack::Registry::start(bool nowarn)
if(stat(_envName.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
Error out(_communicator->getLogger());
- out << "property `IcePack.Registry.Data' is not set to a valid directory path";
- return false;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ out << "property `IcePack.Registry.Data' is set to an invalid path:\n" << ex;
+ return false;
}
}
@@ -246,7 +248,7 @@ IcePack::Registry::start(bool nowarn)
ObjectPrx queryPrx = clientAdapter->createDirectProxy(stringToIdentity("IcePack/Query"));
try
{
- objectRegistry->remove(queryPrx);
+ objectRegistry->remove(queryPrx->ice_getIdentity());
}
catch(const ObjectNotExistException&)
{
@@ -264,7 +266,7 @@ IcePack::Registry::start(bool nowarn)
ObjectPrx adminPrx = adminAdapter->createDirectProxy(stringToIdentity("IcePack/Admin"));
try
{
- objectRegistry->remove(adminPrx);
+ objectRegistry->remove(adminPrx->ice_getIdentity());
}
catch(const ObjectNotExistException&)
{
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index a232d85dfac..72bb715369f 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -255,3 +255,51 @@ IceUtil::checkQuote(const string& s, string::size_type start)
}
return 0; // Not quoted.
}
+
+//
+// Match `s' against the pattern `pat'. A * in the pattern acts
+// as a wildcard: it matches any non-empty sequence of characters
+// other than a period (`.'). We match by hand here because
+// it's portable across platforms (whereas regex() isn't).
+//
+bool
+IceUtil::match(const string& s, const string& pat)
+{
+ assert(!s.empty());
+ assert(!pat.empty());
+
+ if(pat.find('*') == string::npos)
+ {
+ return s == pat;
+ }
+
+ string::size_type sIndex = 0;
+ string::size_type patIndex = 0;
+ do
+ {
+ if(pat[patIndex] == '*')
+ {
+ if(s[sIndex] == '.') // Don't allow matching x..y against x.*.y -- star matches non-empty sequence only.
+ {
+ return false;
+ }
+ while(sIndex < s.size() && s[sIndex] != '.')
+ {
+ ++sIndex;
+ }
+ patIndex++;
+ }
+ else
+ {
+ if(pat[patIndex] != s[sIndex])
+ {
+ return false;
+ }
+ ++sIndex;
+ ++patIndex;
+ }
+ }
+ while(sIndex < s.size() && patIndex < pat.size());
+
+ return sIndex == s.size() && patIndex == pat.size();
+}