summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/Parser.cpp')
-rw-r--r--cpp/src/IceGrid/Parser.cpp1744
1 files changed, 872 insertions, 872 deletions
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index d2c90f05048..bfc95391d91 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -210,7 +210,7 @@ Parser* parser;
ParserPtr
Parser::createParser(const CommunicatorPtr& communicator, const AdminSessionPrx& session, const AdminPrx& admin,
- bool interactive)
+ bool interactive)
{
return new Parser(communicator, session, admin, interactive);
}
@@ -220,15 +220,15 @@ Parser::usage(const string& category, const string& command)
{
if(_helpCommands.find(category) == _helpCommands.end())
{
- invalidCommand("unknown category `" + category + "'");
+ invalidCommand("unknown category `" + category + "'");
}
else if(_helpCommands[category].find(command) == _helpCommands[category].end())
{
- invalidCommand("unknown command `" + category + " " + command + "'");
+ invalidCommand("unknown command `" + category + " " + command + "'");
}
else
{
- cout << _helpCommands[category][command];
+ cout << _helpCommands[category][command];
}
}
@@ -237,15 +237,15 @@ Parser::usage(const string& category, const list<string>& args)
{
if(args.empty())
{
- usage(category);
+ usage(category);
}
else if(args.size() > 1)
{
- invalidCommand("`help' requires at most 1 argument");
+ invalidCommand("`help' requires at most 1 argument");
}
else
{
- usage(category, *args.begin());
+ usage(category, *args.begin());
}
}
@@ -255,11 +255,11 @@ Parser::usage()
cout <<
"help Print this message.\n"
"exit, quit Exit this program.\n"
- "CATEGORY help Print the help section of the given CATEGORY.\n"
- "COMMAND help Print the help of the given COMMAND.\n"
- "\n"
- "List of help categories:\n"
- "\n"
+ "CATEGORY help Print the help section of the given CATEGORY.\n"
+ "COMMAND help Print the help of the given COMMAND.\n"
+ "\n"
+ "List of help categories:\n"
+ "\n"
" application: commands to manage applications\n"
" node: commands to manage nodes\n"
" registry: commands to manage registries\n"
@@ -268,7 +268,7 @@ Parser::usage()
" object: commands to manage objects\n"
" server template: commands to manage server templates\n"
" service template: commands to manage service templates\n"
- "\n";
+ "\n";
}
void
@@ -298,11 +298,11 @@ Parser::checkInterrupted()
{
if(!_interactive)
{
- Lock sync(*this);
- if(_interrupted)
- {
- throw "interrupted with Ctrl-C";
- }
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ throw "interrupted with Ctrl-C";
+ }
}
}
@@ -317,69 +317,69 @@ Parser::addApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() < 1)
{
- invalidCommand("application add", "requires at least one argument");
- return;
+ invalidCommand("application add", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- vector<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- //
- // Add the application.
- //
- ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- _admin->addApplication(app);
-
- if(!opts.isSet("no-patch"))
- {
- //
- // Patch the application.
- //
- try
- {
- _admin->patchApplication(app.name, true);
- }
- catch(const PatchException& ex)
- {
- patchFailed(ex.reasons);
- }
- }
+ StringSeq targets;
+ map<string, string> vars;
+
+ vector<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ //
+ // Add the application.
+ //
+ ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ _admin->addApplication(app);
+
+ if(!opts.isSet("no-patch"))
+ {
+ //
+ // Patch the application.
+ //
+ try
+ {
+ _admin->patchApplication(app.name, true);
+ }
+ catch(const PatchException& ex)
+ {
+ patchFailed(ex.reasons);
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -388,21 +388,21 @@ Parser::removeApplication(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("application remove", "requires exactly one argument");
- return;
+ invalidCommand("application remove", "requires exactly one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- _admin->removeApplication(name);
+ _admin->removeApplication(name);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -411,25 +411,25 @@ Parser::describeApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application describe", "requires at least one argument");
- return;
+ invalidCommand("application describe", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- Output out(cout);
- ApplicationInfo info = _admin->getApplicationInfo(name);
- ApplicationHelper helper(_communicator, info.descriptor);
- helper.print(out, info);
- out << nl;
+ Output out(cout);
+ ApplicationInfo info = _admin->getApplicationInfo(name);
+ ApplicationHelper helper(_communicator, info.descriptor);
+ helper.print(out, info);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -438,44 +438,44 @@ Parser::diffApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff" , "requires at least one argument");
- return;
+ invalidCommand("application diff" , "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
-
- ApplicationHelper newAppHelper(_communicator, newApp);
- ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
-
- Output out(cout);
- newAppHelper.printDiff(out, oldAppHelper);
- out << nl;
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
+
+ ApplicationHelper newAppHelper(_communicator, newApp);
+ ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
+
+ Output out(cout);
+ newAppHelper.printDiff(out, oldAppHelper);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -484,36 +484,36 @@ Parser::updateApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff", "requires at least one argument");
- return;
+ invalidCommand("application diff", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
+ StringSeq targets;
+ map<string, string> vars;
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
- _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
+ _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -528,33 +528,33 @@ Parser::patchApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("application patch", "requires exactly one argument");
- return;
+ invalidCommand("application patch", "requires exactly one argument");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string name = *p++;
- _admin->patchApplication(name, opts.isSet("force"));
+ vector<string>::const_iterator p = args.begin();
+ string name = *p++;
+ _admin->patchApplication(name, opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -563,12 +563,12 @@ Parser::listAllApplications()
{
try
{
- Ice::StringSeq names = _admin->getAllApplicationNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllApplicationNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -577,50 +577,50 @@ Parser::describeServerTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server template describe", "requires exactly two arguments");
- return;
+ invalidCommand("server template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
- if(q != application.descriptor.serverTemplates.end())
- {
- out << "server template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out);
- }
- else
- {
- ServerHelper(server).print(_communicator, out);
- }
- out << eb;
- out << nl;
- }
- else
- {
- error("no server template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
+ if(q != application.descriptor.serverTemplates.end())
+ {
+ out << "server template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out);
+ }
+ else
+ {
+ ServerHelper(server).print(_communicator, out);
+ }
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ error("no server template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -629,35 +629,35 @@ Parser::instantiateServerTemplate(const list<string>& args)
{
if(args.size() < 3)
{
- invalidCommand("server template instantiate", "requires at least three arguments");
- return;
+ invalidCommand("server template instantiate", "requires at least three arguments");
+ return;
}
try
{
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string application = *p++;
- string node = *p++;
- string templ = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- }
-
- ServerInstanceDescriptor desc;
- desc._cpp_template = templ;
- desc.parameterValues = vars;
- _admin->instantiateServer(application, node, desc);
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string application = *p++;
+ string node = *p++;
+ string templ = *p++;
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ }
+
+ ServerInstanceDescriptor desc;
+ desc._cpp_template = templ;
+ desc.parameterValues = vars;
+ _admin->instantiateServer(application, node, desc);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -666,42 +666,42 @@ Parser::describeServiceTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("service template describe", "requires exactly two arguments");
- return;
+ invalidCommand("service template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
- if(q != application.descriptor.serviceTemplates.end())
- {
- out << "service template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
- ServiceHelper(desc).print(_communicator, out);
- out << eb;
- out << nl;
- }
- else
- {
- invalidCommand("no service template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
+ if(q != application.descriptor.serviceTemplates.end())
+ {
+ out << "service template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
+ ServiceHelper(desc).print(_communicator, out);
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ invalidCommand("no service template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -710,28 +710,28 @@ Parser::describeNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node describe", "requires exactly one argument");
- return;
+ invalidCommand("node describe", "requires exactly one argument");
+ return;
}
try
{
- NodeInfo info = _admin->getNodeInfo(args.front());
- Output out(cout);
- out << "node `" << args.front() << "'";
- out << sb;
- out << nl << "operating system = `" << info.os << "'";
- out << nl << "host name = `" << info.hostname << "'";
- out << nl << "release = `" << info.release << "'";
- out << nl << "version = `" << info.version << "'";
- out << nl << "machine type = `" << info.machine << "'";
- out << nl << "number of processors = `" << info.nProcessors << "'";
- out << eb;
- out << nl;
+ NodeInfo info = _admin->getNodeInfo(args.front());
+ Output out(cout);
+ out << "node `" << args.front() << "'";
+ out << sb;
+ out << nl << "operating system = `" << info.os << "'";
+ out << nl << "host name = `" << info.hostname << "'";
+ out << nl << "release = `" << info.release << "'";
+ out << nl << "version = `" << info.version << "'";
+ out << nl << "machine type = `" << info.machine << "'";
+ out << nl << "number of processors = `" << info.nProcessors << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -740,24 +740,24 @@ Parser::pingNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node ping", "requires exactly one argument");
- return;
+ invalidCommand("node ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingNode(args.front()))
- {
- cout << "node is up" << endl;
- }
- else
- {
- cout << "node is down" << endl;
- }
+ if(_admin->pingNode(args.front()))
+ {
+ cout << "node is up" << endl;
+ }
+ else
+ {
+ cout << "node is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -766,18 +766,18 @@ Parser::printLoadNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node load", "requires exactly one argument");
- return;
+ invalidCommand("node load", "requires exactly one argument");
+ return;
}
try
{
- LoadInfo load = _admin->getNodeLoad(args.front());
- cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
+ LoadInfo load = _admin->getNodeLoad(args.front());
+ cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -786,17 +786,17 @@ Parser::shutdownNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node shutdown", "requires exactly one argument");
- return;
+ invalidCommand("node shutdown", "requires exactly one argument");
+ return;
}
try
{
- _admin->shutdownNode(args.front());
+ _admin->shutdownNode(args.front());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -805,12 +805,12 @@ Parser::listAllNodes()
{
try
{
- Ice::StringSeq names = _admin->getAllNodeNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllNodeNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -819,23 +819,23 @@ Parser::describeRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry describe", "requires exactly one argument");
- return;
+ invalidCommand("registry describe", "requires exactly one argument");
+ return;
}
try
{
- RegistryInfo info = _admin->getRegistryInfo(args.front());
- Output out(cout);
- out << "registry `" << args.front() << "'";
- out << sb;
- out << nl << "host name = `" << info.hostname << "'";
- out << eb;
- out << nl;
+ RegistryInfo info = _admin->getRegistryInfo(args.front());
+ Output out(cout);
+ out << "registry `" << args.front() << "'";
+ out << sb;
+ out << nl << "host name = `" << info.hostname << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -844,24 +844,24 @@ Parser::pingRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry ping", "requires exactly one argument");
- return;
+ invalidCommand("registry ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingRegistry(args.front()))
- {
- cout << "registry is up" << endl;
- }
- else
- {
- cout << "registry is down" << endl;
- }
+ if(_admin->pingRegistry(args.front()))
+ {
+ cout << "registry is up" << endl;
+ }
+ else
+ {
+ cout << "registry is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -870,24 +870,24 @@ Parser::shutdownRegistry(const list<string>& args)
{
if(args.size() > 1)
{
- invalidCommand("registry shutdown", "requires at most one argument");
- return;
+ invalidCommand("registry shutdown", "requires at most one argument");
+ return;
}
try
{
- if(args.empty())
- {
- _admin->shutdown();
- }
- else
- {
- _admin->shutdownRegistry(args.front());
- }
+ if(args.empty())
+ {
+ _admin->shutdown();
+ }
+ else
+ {
+ _admin->shutdownRegistry(args.front());
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -896,12 +896,12 @@ Parser::listAllRegistries()
{
try
{
- Ice::StringSeq names = _admin->getAllRegistryNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllRegistryNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -910,24 +910,24 @@ Parser::removeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server remove", "requires exactly one argument");
- return;
+ invalidCommand("server remove", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- NodeUpdateDescriptor nodeUpdate;
- nodeUpdate.name = info.node;
- nodeUpdate.removeServers.push_back(args.front());
- ApplicationUpdateDescriptor update;
- update.name = info.application;
- update.nodes.push_back(nodeUpdate);
- _admin->updateApplication(update);
+ ServerInfo info = _admin->getServerInfo(args.front());
+ NodeUpdateDescriptor nodeUpdate;
+ nodeUpdate.name = info.node;
+ nodeUpdate.removeServers.push_back(args.front());
+ ApplicationUpdateDescriptor update;
+ update.name = info.application;
+ update.nodes.push_back(nodeUpdate);
+ _admin->updateApplication(update);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -936,21 +936,21 @@ Parser::startServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server start", "requires exactly one argument");
- return;
+ invalidCommand("server start", "requires exactly one argument");
+ return;
}
try
{
- _admin->startServer(args.front());
+ _admin->startServer(args.front());
}
catch(const ServerStartException& ex)
{
- error("the server didn't start successfully:\n" + ex.reason);
+ error("the server didn't start successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -959,21 +959,21 @@ Parser::stopServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server stop", "requires exactly one argument");
- return;
+ invalidCommand("server stop", "requires exactly one argument");
+ return;
}
try
{
- _admin->stopServer(args.front());
+ _admin->stopServer(args.front());
}
catch(const ServerStopException& ex)
{
- error("the server didn't stop successfully:\n" + ex.reason);
+ error("the server didn't stop successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -988,31 +988,31 @@ Parser::patchServer(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("server patch", "requires exactly one argument");
- return;
+ invalidCommand("server patch", "requires exactly one argument");
+ return;
}
try
{
- _admin->patchServer(args.front(), opts.isSet("force"));
+ _admin->patchServer(args.front(), opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1021,19 +1021,19 @@ Parser::signalServer(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server signal", "requires exactly two arguments");
- return;
+ invalidCommand("server signal", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->sendSignal(server, *p);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->sendSignal(server, *p);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1043,19 +1043,19 @@ Parser::writeMessage(const list<string>& args, int fd)
{
if(args.size() != 2)
{
- invalidCommand("server stdout or server stderr", "requires exactly two arguments");
- return;
+ invalidCommand("server stdout or server stderr", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->writeMessage(server, *p, fd);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->writeMessage(server, *p, fd);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1064,28 +1064,28 @@ Parser::describeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server describe", "requires exactly one argument");
- return;
+ invalidCommand("server describe", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- Output out(cout);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out, info);
- }
- else
- {
- ServerHelper(info.descriptor).print(_communicator, out, info);
- }
- out << nl;
+ ServerInfo info = _admin->getServerInfo(args.front());
+ Output out(cout);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out, info);
+ }
+ else
+ {
+ ServerHelper(info.descriptor).print(_communicator, out, info);
+ }
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1094,60 +1094,60 @@ Parser::stateServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server state", "requires exactly one argument");
- return;
+ invalidCommand("server state", "requires exactly one argument");
+ return;
}
try
{
- ServerState state = _admin->getServerState(args.front());
- string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
- switch(state)
- {
- case Inactive:
- {
- cout << "inactive (" << enabled << ")" << endl;
- break;
- }
- case Activating:
- {
- cout << "activating (" << enabled << ")" << endl;
- break;
- }
- case Active:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case ActivationTimedOut:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case Deactivating:
- {
- cout << "deactivating (" << enabled << ")" << endl;
- break;
- }
- case Destroying:
- {
- cout << "destroying (" << enabled << ")" << endl;
- break;
- }
- case Destroyed:
- {
- cout << "destroyed (" << enabled << ")" << endl;
- break;
- }
- default:
- assert(false);
- }
+ ServerState state = _admin->getServerState(args.front());
+ string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
+ switch(state)
+ {
+ case Inactive:
+ {
+ cout << "inactive (" << enabled << ")" << endl;
+ break;
+ }
+ case Activating:
+ {
+ cout << "activating (" << enabled << ")" << endl;
+ break;
+ }
+ case Active:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case ActivationTimedOut:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case Deactivating:
+ {
+ cout << "deactivating (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroying:
+ {
+ cout << "destroying (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroyed:
+ {
+ cout << "destroyed (" << enabled << ")" << endl;
+ break;
+ }
+ default:
+ assert(false);
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1156,25 +1156,25 @@ Parser::pidServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server pid", "requires exactly one argument");
- return;
+ invalidCommand("server pid", "requires exactly one argument");
+ return;
}
try
{
- int pid = _admin->getServerPid(args.front());
- if(pid > 0)
- {
- cout << pid << endl;
- }
- else
- {
- error("server is not running");
- }
+ int pid = _admin->getServerPid(args.front());
+ if(pid > 0)
+ {
+ cout << pid << endl;
+ }
+ else
+ {
+ error("server is not running");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1183,24 +1183,24 @@ Parser::enableServer(const list<string>& args, bool enable)
{
if(args.size() != 1)
{
- if(enable)
- {
- invalidCommand("server enable", "requires exactly one argument");
- }
- else
- {
- invalidCommand("server disable", "requires exactly one argument");
- }
- return;
+ if(enable)
+ {
+ invalidCommand("server enable", "requires exactly one argument");
+ }
+ else
+ {
+ invalidCommand("server disable", "requires exactly one argument");
+ }
+ return;
}
try
{
- _admin->enableServer(args.front(), enable);
+ _admin->enableServer(args.front(), enable);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1209,12 +1209,12 @@ Parser::listAllServers()
{
try
{
- Ice::StringSeq ids = _admin->getAllServerIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllServerIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1223,32 +1223,32 @@ Parser::endpointsAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter endpoints", "requires exactly one argument");
- return;
+ invalidCommand("adapter endpoints", "requires exactly one argument");
+ return;
}
try
{
- string adapterId = args.front();
- AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
- if(adpts.size() == 1 && adpts.begin()->id == adapterId)
- {
- string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- else
- {
- for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
- {
- cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
- string endpoints = _communicator->proxyToString(p->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- }
+ string adapterId = args.front();
+ AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
+ if(adpts.size() == 1 && adpts.begin()->id == adapterId)
+ {
+ string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ else
+ {
+ for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
+ {
+ cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
+ string endpoints = _communicator->proxyToString(p->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1257,17 +1257,17 @@ Parser::removeAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter remove", "requires exactly one argument");
- return;
+ invalidCommand("adapter remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeAdapter(*args.begin());
+ _admin->removeAdapter(*args.begin());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1276,12 +1276,12 @@ Parser::listAllAdapters()
{
try
{
- Ice::StringSeq ids = _admin->getAllAdapterIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllAdapterIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1290,29 +1290,29 @@ Parser::addObject(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("object add", "requires at least one argument");
- return;
+ invalidCommand("object add", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string proxy = *p++;
+ string proxy = *p++;
- if(p != args.end())
- {
- string type = *p++;
- _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
- }
- else
- {
- _admin->addObject(_communicator->stringToProxy(proxy));
- }
+ if(p != args.end())
+ {
+ string type = *p++;
+ _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
+ }
+ else
+ {
+ _admin->addObject(_communicator->stringToProxy(proxy));
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1321,17 +1321,17 @@ Parser::removeObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object remove", "requires exactly one argument");
- return;
+ invalidCommand("object remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
+ _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1340,21 +1340,21 @@ Parser::findObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object find", "requires exactly one argument");
- return;
+ invalidCommand("object find", "requires exactly one argument");
+ return;
}
try
{
- ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->proxyToString(p->proxy) << endl;
- }
+ ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->proxyToString(p->proxy) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1363,36 +1363,36 @@ Parser::describeObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- string arg = *(args.begin());
- if(arg.find('*') == string::npos)
- {
- ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
- cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
- cout << "type = `" << info.type << "'" << endl;
- return;
- }
- else
- {
- objects = _admin->getAllObjectInfos(arg);
- }
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
- }
-
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ string arg = *(args.begin());
+ if(arg.find('*') == string::npos)
+ {
+ ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
+ cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
+ cout << "type = `" << info.type << "'" << endl;
+ return;
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos(arg);
+ }
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
+ }
+
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1401,24 +1401,24 @@ Parser::listObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- objects = _admin->getAllObjectInfos(*(args.begin()));
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
- }
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ objects = _admin->getAllObjectInfos(*(args.begin()));
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1436,184 +1436,184 @@ Parser::showFile(const string& reader, const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 2)
{
- invalidCommand(reader + " show", "requires two arguments");
- return;
+ invalidCommand(reader + " show", "requires two arguments");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string id = *p++;
- string filename = *p++;
-
- cout << reader << " `" << id << "' " << filename << ": " << flush;
- Ice::StringSeq lines;
-
- bool head = opts.isSet("head");
- bool tail = opts.isSet("tail");
- if(head && tail)
- {
- invalidCommand("can't specify both -h | --head and -t | --tail options");
- return;
- }
- int lineCount = 20;
- int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
- if(head || tail)
- {
- if(head)
- {
- istringstream is(opts.optArg("head"));
- is >> lineCount;
- }
- else
- {
- istringstream is(opts.optArg("tail"));
- is >> lineCount;
- }
- if(lineCount <= 0)
- {
- invalidCommand("invalid argument for -h | --head or -t | --tail option");
- return;
- }
- }
-
- FileIteratorPrx it;
- if(reader == "node")
- {
- if(filename == "stderr")
- {
- it = _session->openNodeStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openNodeStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid node log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "registry")
- {
- if(filename == "stderr")
- {
- it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid registry log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "server")
- {
- if(filename == "stderr")
- {
- it = _session->openServerStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openServerStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- it = _session->openServerLog(id, filename, tail ? lineCount : -1);
- }
- }
-
- bool follow = opts.isSet("follow");
- resetInterrupt();
- if(head)
- {
- if(follow)
- {
- invalidCommand("can't use -f | --follow option with -h | --head option");
- return;
- }
-
- int i = 0;
- bool eof = false;
- while(!interrupted() && !eof && i < lineCount)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
- {
- cout << endl << *p << flush;
- }
- }
- }
- else
- {
- bool eof = false;
- while(!interrupted() && !eof)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << endl << *p << flush;
- }
- }
- }
-
- if(follow)
- {
- while(!interrupted())
- {
- bool eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << *p;
- if((p + 1) != lines.end())
- {
- cout << endl;
- }
- else
- {
- cout << flush;
- }
- }
-
- if(eof)
- {
- Lock sync(*this);
- if(_interrupted)
- {
- break;
- }
- timedWait(IceUtil::Time::seconds(5));
- }
- }
- }
-
- if(lines.empty() || !lines.back().empty())
- {
- cout << endl;
- }
-
- it->destroy();
+ vector<string>::const_iterator p = args.begin();
+ string id = *p++;
+ string filename = *p++;
+
+ cout << reader << " `" << id << "' " << filename << ": " << flush;
+ Ice::StringSeq lines;
+
+ bool head = opts.isSet("head");
+ bool tail = opts.isSet("tail");
+ if(head && tail)
+ {
+ invalidCommand("can't specify both -h | --head and -t | --tail options");
+ return;
+ }
+ int lineCount = 20;
+ int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
+ if(head || tail)
+ {
+ if(head)
+ {
+ istringstream is(opts.optArg("head"));
+ is >> lineCount;
+ }
+ else
+ {
+ istringstream is(opts.optArg("tail"));
+ is >> lineCount;
+ }
+ if(lineCount <= 0)
+ {
+ invalidCommand("invalid argument for -h | --head or -t | --tail option");
+ return;
+ }
+ }
+
+ FileIteratorPrx it;
+ if(reader == "node")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openNodeStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openNodeStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid node log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "registry")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid registry log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "server")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openServerStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openServerStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ it = _session->openServerLog(id, filename, tail ? lineCount : -1);
+ }
+ }
+
+ bool follow = opts.isSet("follow");
+ resetInterrupt();
+ if(head)
+ {
+ if(follow)
+ {
+ invalidCommand("can't use -f | --follow option with -h | --head option");
+ return;
+ }
+
+ int i = 0;
+ bool eof = false;
+ while(!interrupted() && !eof && i < lineCount)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+ else
+ {
+ bool eof = false;
+ while(!interrupted() && !eof)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+
+ if(follow)
+ {
+ while(!interrupted())
+ {
+ bool eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << *p;
+ if((p + 1) != lines.end())
+ {
+ cout << endl;
+ }
+ else
+ {
+ cout << flush;
+ }
+ }
+
+ if(eof)
+ {
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ break;
+ }
+ timedWait(IceUtil::Time::seconds(5));
+ }
+ }
+ }
+
+ if(lines.empty() || !lines.back().empty())
+ {
+ cout << endl;
+ }
+
+ it->destroy();
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1640,104 +1640,104 @@ Parser::getInput(char* buf, int& result, int maxSize)
{
if(!_commands.empty())
{
- if(_commands == ";")
- {
- result = 0;
- }
- else
- {
+ if(_commands == ";")
+ {
+ result = 0;
+ }
+ else
+ {
#if defined(_MSC_VER) && !defined(_STLP_MSVC)
- // COMPILERBUG: Stupid Visual C++ defines min and max as macros
- result = _MIN(maxSize, static_cast<int>(_commands.length()));
+ // COMPILERBUG: Stupid Visual C++ defines min and max as macros
+ result = _MIN(maxSize, static_cast<int>(_commands.length()));
#else
- result = min(maxSize, static_cast<int>(_commands.length()));
+ result = min(maxSize, static_cast<int>(_commands.length()));
#endif
- strncpy(buf, _commands.c_str(), result);
- _commands.erase(0, result);
- if(_commands.empty())
- {
- _commands = ";";
- }
- }
+ strncpy(buf, _commands.c_str(), result);
+ _commands.erase(0, result);
+ if(_commands.empty())
+ {
+ _commands = ";";
+ }
+ }
}
else if(isatty(fileno(yyin)))
{
#ifdef HAVE_READLINE
const char* prompt = parser->getPrompt();
- char* line = readline(const_cast<char*>(prompt));
- if(!line)
- {
- result = 0;
- }
- else
- {
- if(*line)
- {
- add_history(line);
- }
-
- result = strlen(line) + 1;
- if(result > maxSize)
- {
- free(line);
- error("input line too long");
- result = 0;
- }
- else
- {
- strcpy(buf, line);
- strcat(buf, "\n");
- free(line);
- }
- }
+ char* line = readline(const_cast<char*>(prompt));
+ if(!line)
+ {
+ result = 0;
+ }
+ else
+ {
+ if(*line)
+ {
+ add_history(line);
+ }
+
+ result = strlen(line) + 1;
+ if(result > maxSize)
+ {
+ free(line);
+ error("input line too long");
+ result = 0;
+ }
+ else
+ {
+ strcpy(buf, line);
+ strcat(buf, "\n");
+ free(line);
+ }
+ }
#else
- cout << parser->getPrompt() << flush;
-
- string line;
- while(true)
- {
- char c = static_cast<char>(getc(yyin));
- if(c == EOF)
- {
- if(line.size())
- {
- line += '\n';
- }
- break;
- }
- line += c;
-
- if(c == '\n')
- {
- break;
- }
- }
-
- result = (int) line.length();
- if(result > maxSize)
- {
- error("input line too long");
- buf[0] = EOF;
- result = 1;
- }
- else
- {
- strcpy(buf, line.c_str());
- }
+ cout << parser->getPrompt() << flush;
+
+ string line;
+ while(true)
+ {
+ char c = static_cast<char>(getc(yyin));
+ if(c == EOF)
+ {
+ if(line.size())
+ {
+ line += '\n';
+ }
+ break;
+ }
+ line += c;
+
+ if(c == '\n')
+ {
+ break;
+ }
+ }
+
+ result = (int) line.length();
+ if(result > maxSize)
+ {
+ error("input line too long");
+ buf[0] = EOF;
+ result = 1;
+ }
+ else
+ {
+ strcpy(buf, line.c_str());
+ }
#endif
}
else
{
- if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
- {
- error("input in flex scanner failed");
- buf[0] = EOF;
- result = 1;
- }
+ if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
+ {
+ error("input in flex scanner failed");
+ buf[0] = EOF;
+ result = 1;
+ }
}
}
@@ -1760,12 +1760,12 @@ Parser::getPrompt()
if(_continue)
{
- _continue = false;
- return "(cont) ";
+ _continue = false;
+ return "(cont) ";
}
else
{
- return ">>> ";
+ return ">>> ";
}
}
@@ -1778,13 +1778,13 @@ Parser::scanPosition(const char* s)
idx = line.find("line");
if(idx != string::npos)
{
- line.erase(0, idx + 4);
+ line.erase(0, idx + 4);
}
idx = line.find_first_not_of(" \t\r#");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
_currentLine = atoi(line.c_str()) - 1;
@@ -1792,24 +1792,24 @@ Parser::scanPosition(const char* s)
idx = line.find_first_of(" \t\r");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
idx = line.find_first_not_of(" \t\r\"");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
- idx = line.find_first_of(" \t\r\"");
- if(idx != string::npos)
- {
- _currentFile = line.substr(0, idx);
- line.erase(0, idx + 1);
- }
- else
- {
- _currentFile = line;
- }
+ idx = line.find_first_of(" \t\r\"");
+ if(idx != string::npos)
+ {
+ _currentFile = line.substr(0, idx);
+ line.erase(0, idx + 1);
+ }
+ else
+ {
+ _currentFile = line;
+ }
}
}
@@ -1840,31 +1840,31 @@ Parser::patchFailed(const Ice::StringSeq& reasons)
out << "the patch failed on some nodes:\n";
for(Ice::StringSeq::const_iterator p = reasons.begin(); p != reasons.end(); ++p)
{
- string reason = *p;
- string::size_type beg = 0;
- string::size_type end = reason.find_first_of("\n");
- if(end == string::npos)
- {
- end = reason.size();
- }
- out << "- " << reason.substr(beg, end - beg);
- out.inc();
- while(end < reason.size())
- {
- beg = end + 1;
- end = reason.find_first_of("\n", beg);
- if(end == string::npos)
- {
- end = reason.size();
- }
- out.newline();
- out << reason.substr(beg, end - beg);
- }
- out.dec();
- if(p + 1 != reasons.end())
- {
- out.newline();
- }
+ string reason = *p;
+ string::size_type beg = 0;
+ string::size_type end = reason.find_first_of("\n");
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out << "- " << reason.substr(beg, end - beg);
+ out.inc();
+ while(end < reason.size())
+ {
+ beg = end + 1;
+ end = reason.find_first_of("\n", beg);
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out.newline();
+ out << reason.substr(beg, end - beg);
+ }
+ out.dec();
+ if(p + 1 != reasons.end())
+ {
+ out.newline();
+ }
}
warning(os.str());
}
@@ -1874,11 +1874,11 @@ Parser::error(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
}
else
{
- cerr << "error: " << s << endl;
+ cerr << "error: " << s << endl;
}
_errors++;
}
@@ -1894,11 +1894,11 @@ Parser::warning(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
}
else
{
- cerr << "warning: " << s << endl;
+ cerr << "warning: " << s << endl;
}
}
@@ -1929,7 +1929,7 @@ Parser::parse(FILE* file, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1957,7 +1957,7 @@ Parser::parse(const std::string& commands, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1965,9 +1965,9 @@ Parser::parse(const std::string& commands, bool debug)
}
Parser::Parser(const CommunicatorPtr& communicator,
- const AdminSessionPrx& session,
- const AdminPrx& admin,
- bool interactive) :
+ const AdminSessionPrx& session,
+ const AdminPrx& admin,
+ bool interactive) :
_communicator(communicator),
_session(session),
_admin(admin),
@@ -1976,11 +1976,11 @@ Parser::Parser(const CommunicatorPtr& communicator,
{
for(int i = 0; _commandsHelp[i][0]; i++)
{
- const string category = _commandsHelp[i][0];
- const string cmd = _commandsHelp[i][1];
- const string help = _commandsHelp[i][2];
- _helpCommands[category][""] += help;
- _helpCommands[category][cmd] += help;
+ const string category = _commandsHelp[i][0];
+ const string cmd = _commandsHelp[i][1];
+ const string help = _commandsHelp[i][2];
+ _helpCommands[category][""] += help;
+ _helpCommands[category][cmd] += help;
}
}
@@ -1989,81 +1989,81 @@ Parser::exception(const Ice::Exception& ex)
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(const ApplicationNotExistException& ex)
{
- error("couldn't find application `" + ex.name + "'");
+ error("couldn't find application `" + ex.name + "'");
}
catch(const NodeNotExistException& ex)
{
- error("couldn't find node `" + ex.name + "'");
+ error("couldn't find node `" + ex.name + "'");
}
catch(const ServerNotExistException& ex)
{
- error("couldn't find server `" + ex.id + "'");
+ error("couldn't find server `" + ex.id + "'");
}
catch(const AdapterNotExistException& ex)
{
- error("couldn't find adapter `" + ex.id + "'");
+ error("couldn't find adapter `" + ex.id + "'");
}
catch(const ObjectExistsException& ex)
{
- error("object `" + _communicator->identityToString(ex.id) + "' already exists");
+ error("object `" + _communicator->identityToString(ex.id) + "' already exists");
}
catch(const DeploymentException& ex)
{
- ostringstream s;
- s << ex << ":\n" << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
}
catch(const PatchException& ex)
{
- if(ex.reasons.size() == 1)
- {
- ostringstream s;
- s << ex << ":\n" << ex.reasons[0];
- error(s.str());
- }
- else
- {
- patchFailed(ex.reasons);
- }
+ if(ex.reasons.size() == 1)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reasons[0];
+ error(s.str());
+ }
+ else
+ {
+ patchFailed(ex.reasons);
+ }
}
catch(const BadSignalException& ex)
{
- ostringstream s;
- s << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex.reason;
+ error(s.str());
}
catch(const NodeUnreachableException& ex)
{
- error("node `" + ex.name + "' couldn't be reached:\n" + ex.reason);
+ error("node `" + 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");
+ error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
}
catch(const FileNotAvailableException& ex)
{
- error("couldn't access file:\n" + ex.reason);
+ error("couldn't access file:\n" + ex.reason);
}
catch(const IceXML::ParserException& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
catch(const Ice::LocalException& ex)
{
- ostringstream s;
- s << "couldn't reach the IceGrid registry:\n" << ex;
- error(s.str());
+ ostringstream s;
+ s << "couldn't reach the IceGrid registry:\n" << ex;
+ error(s.str());
}
catch(const Ice::Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}