diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-02-29 15:51:11 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-02-29 16:39:54 +0800 |
commit | fb4132881dde7c9b135d713a06a3b64db1f706db (patch) | |
tree | 8a037e9d4cae7ed15360ab0878d14b32ac3150a4 /cpp/src/IceStorm/Parser.cpp | |
parent | fixing mode on php/config/Make.rules.mak (diff) | |
download | ice-fb4132881dde7c9b135d713a06a3b64db1f706db.tar.bz2 ice-fb4132881dde7c9b135d713a06a3b64db1f706db.tar.xz ice-fb4132881dde7c9b135d713a06a3b64db1f706db.zip |
Merge HA IceStorm branch.
- http://bugzilla/bugzilla/show_bug.cgi?id=2706
- http://bugzilla/bugzilla/show_bug.cgi?id=2705
Diffstat (limited to 'cpp/src/IceStorm/Parser.cpp')
-rw-r--r-- | cpp/src/IceStorm/Parser.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index 58c8d6c0976..74cb847255b 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -10,6 +10,7 @@ #include <IceUtil/DisableWarnings.h> #include <Ice/Ice.h> #include <IceStorm/Parser.h> +#include <IceStorm/IceStormInternal.h> #include <algorithm> #ifdef HAVE_READLINE @@ -94,6 +95,7 @@ Parser::usage() " manager, or in the given INSTANCE-NAME.\n" "current [INSTANCE-NAME] Display the current topic manager, or change it to\n" " INSTANCE-NAME.\n" + "replica [INSTANCE-NAME] Display replication information for the given INSTANCE-NAME.\n" ; } @@ -263,6 +265,85 @@ Parser::topics(const list<string>& args) } void +Parser::replica(const list<string>& args) +{ + if(args.size() > 1) + { + error("`replica' requires at most one argument (type `help' for more info)"); + return; + } + + try + { + TopicManagerPrx m; + if(args.size() == 0) + { + m = _defaultManager; + } + else + { + m = findManagerByCategory(args.front()); + } + TopicManagerInternalPrx manager = TopicManagerInternalPrx::uncheckedCast(m); + IceStormElection::NodePrx node = manager->getReplicaNode(); + if(!node) + { + error("This topic is not replicated"); + } + IceStormElection::NodeInfoSeq nodes = node->nodes(); + cout << "replica count: " << nodes.size() << endl; + for(IceStormElection::NodeInfoSeq::const_iterator p = nodes.begin(); p != nodes.end(); ++p) + { + try + { + IceStormElection::QueryInfo info = p->n->query(); + cout << p->id << ": id: " << info.id << endl; + cout << p->id << ": coord: " << info.coord << endl; + cout << p->id << ": group name: " << info.group << endl; + cout << p->id << ": state: "; + switch(info.state) + { + case IceStormElection::NodeStateInactive: + cout << "inactive"; + break; + case IceStormElection::NodeStateElection: + cout << "election"; + break; + case IceStormElection::NodeStateReorganization: + cout << "reorganization"; + break; + case IceStormElection::NodeStateNormal: + cout << "normal"; + break; + default: + cout << "unknown"; + } + cout << endl; + cout << p->id << ": group: "; + for(IceStormElection::GroupInfoSeq::const_iterator q = info.up.begin(); q != info.up.end(); ++q) + { + if(q != info.up.begin()) + { + cout << ","; + } + cout << q->id; + } + cout << endl; + cout << p->id << ": max: " << info.max << endl; + } + catch(const Exception& ex) + { + cout << p->id << ": " << ex.ice_name() << endl; + } + } + } + catch(const Exception& ex) + { + exception(ex); + } +} + +void Parser::current(const list<string>& args) { if(args.empty()) |