summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Grammar.y24
-rw-r--r--cpp/src/IceGrid/Parser.cpp45
-rw-r--r--cpp/src/IceGrid/Parser.h1
-rw-r--r--cpp/src/IceGrid/Scanner.l2
-rw-r--r--cpp/src/IceGrid/ServerI.cpp29
5 files changed, 92 insertions, 9 deletions
diff --git a/cpp/src/IceGrid/Grammar.y b/cpp/src/IceGrid/Grammar.y
index 1fea5321f65..7f6bdc0342f 100644
--- a/cpp/src/IceGrid/Grammar.y
+++ b/cpp/src/IceGrid/Grammar.y
@@ -60,6 +60,8 @@ yyerror(const char* s)
%token ICE_GRID_STDOUT
%token ICE_GRID_STDERR
%token ICE_GRID_DESCRIBE
+%token ICE_GRID_PROPERTIES
+%token ICE_GRID_PROPERTY
%token ICE_GRID_STATE
%token ICE_GRID_PID
%token ICE_GRID_ENDPOINTS
@@ -375,6 +377,22 @@ command
{
parser->usage("server", "pid");
}
+| ICE_GRID_SERVER ICE_GRID_PROPERTIES strings ';'
+{
+ parser->propertiesServer($3, false);
+}
+| ICE_GRID_SERVER ICE_GRID_PROPERTIES ICE_GRID_HELP ';'
+{
+ parser->usage("server", "properties");
+}
+| ICE_GRID_SERVER ICE_GRID_PROPERTY strings ';'
+{
+ parser->propertiesServer($3, true);
+}
+| ICE_GRID_SERVER ICE_GRID_PROPERTY ICE_GRID_HELP ';'
+{
+ parser->usage("server", "property");
+}
| ICE_GRID_SERVER ICE_GRID_ENABLE strings ';'
{
parser->enableServer($3, true);
@@ -649,6 +667,12 @@ keyword
| ICE_GRID_PID
{
}
+| ICE_GRID_PROPERTIES
+{
+}
+| ICE_GRID_PROPERTY
+{
+}
| ICE_GRID_ENDPOINTS
{
}
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 35ab0cbf548..1f684e13c5e 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -127,6 +127,12 @@ static const char* _commandsHelp[][3] = {
{ "server", "describe",
"server describe ID Describe server ID.\n"
},
+{ "server", "properties",
+"server properties ID Get the runtime properties of server ID.\n"
+},
+{ "server", "property",
+"server property ID NAME Get the runtime property NAME of server ID.\n"
+},
{ "server", "state",
"server state ID Get the state of server ID.\n"
},
@@ -1197,6 +1203,41 @@ Parser::pidServer(const list<string>& args)
}
void
+Parser::propertiesServer(const list<string>& args, bool single)
+{
+ if(single && args.size() != 2)
+ {
+ invalidCommand("server property", "requires exactly two arguments");
+ return;
+ }
+ else if(!single && args.size() != 1)
+ {
+ invalidCommand("server properties", "requires exactly one argument");
+ return;
+ }
+
+ try
+ {
+ Ice::PropertyDict properties = _admin->getServerProperties(args.front());
+ if(single)
+ {
+ cout << properties[*(++args.begin())] << endl;
+ }
+ else
+ {
+ for(Ice::PropertyDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
+ {
+ cout << p->first << "=" << p->second << endl;
+ }
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ exception(ex);
+ }
+}
+
+void
Parser::enableServer(const list<string>& args, bool enable)
{
if(args.size() != 1)
@@ -2048,6 +2089,10 @@ Parser::exception(const Ice::Exception& ex)
{
error("registry `" + ex.name + "' couldn't be reached:\n" + ex.reason);
}
+ catch(const ServerUnreachableException& ex)
+ {
+ error("server `" + ex.name + "' couldn't be reached:\n" + ex.reason);
+ }
catch(const AccessDeniedException& ex)
{
error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
diff --git a/cpp/src/IceGrid/Parser.h b/cpp/src/IceGrid/Parser.h
index a57de7b589a..e5d6706e880 100644
--- a/cpp/src/IceGrid/Parser.h
+++ b/cpp/src/IceGrid/Parser.h
@@ -100,6 +100,7 @@ public:
void stateServer(const std::list<std::string>&);
void enableServer(const std::list<std::string>&, bool);
void pidServer(const std::list<std::string>&);
+ void propertiesServer(const std::list<std::string>&, bool);
void listAllServers(const std::list<std::string>&);
void endpointsAdapter(const std::list<std::string>&);
diff --git a/cpp/src/IceGrid/Scanner.l b/cpp/src/IceGrid/Scanner.l
index 276b1b4f0ae..8f78cea0757 100644
--- a/cpp/src/IceGrid/Scanner.l
+++ b/cpp/src/IceGrid/Scanner.l
@@ -246,6 +246,8 @@ initScanner()
keywordMap["list"] = ICE_GRID_LIST;
keywordMap["shutdown"] = ICE_GRID_SHUTDOWN;
keywordMap["describe"] = ICE_GRID_DESCRIBE;
+ keywordMap["properties"] = ICE_GRID_PROPERTIES;
+ keywordMap["property"] = ICE_GRID_PROPERTY;
keywordMap["state"] = ICE_GRID_STATE;
keywordMap["pid"] = ICE_GRID_PID;
keywordMap["endpoints"] = ICE_GRID_ENDPOINTS;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index f7dcfa7ea67..9e4a26302f4 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -748,22 +748,33 @@ ServerI::getProperties(const Ice::Current&) const
Ice::ProcessPrx process = 0;
{
Lock sync(*this);
- checkDestroyed();
//
- // Wait for _process to be set
+ // Wait for _process to be set if the server is being activated.
//
- while(_desc->processRegistered && _process == 0)
+ while(_desc->processRegistered && _process == 0 && _state > Inactive && _state < Deactivating)
{
wait();
- checkDestroyed();
}
- process = _process;
- }
- if(process == 0)
- {
- throw ServerUnreachableException(_id, "no Admin object");
+ checkDestroyed();
+ if(!_process)
+ {
+ if(_desc->processRegistered && _state == Inactive)
+ {
+ throw ServerUnreachableException(_id, "server is not active");
+ }
+ else if(_desc->processRegistered && _state >= Deactivating)
+ {
+ throw ServerUnreachableException(_id, "server is deactivating");
+ }
+ else
+ {
+ throw ServerUnreachableException(_id, "no Admin object");
+ }
+ }
+
+ process = _process;
}
try