本文整理汇总了C++中MemberState::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ MemberState::toString方法的具体用法?C++ MemberState::toString怎么用?C++ MemberState::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberState
的用法示例。
在下文中一共展示了MemberState::toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _summarizeStatus
void ReplSetImpl::_summarizeStatus(BSONObjBuilder& b) const {
vector<BSONObj> v;
const Member *_self = this->_self;
verify( _self );
MemberState myState = box.getState();
const HostAndPort syncTarget = BackgroundSync::get()->getSyncTarget();
// add self
{
BSONObjBuilder bb;
bb.append("_id", (int) _self->id());
bb.append("name", _self->fullName());
bb.append("health", 1.0);
bb.append("state", (int)myState.s);
bb.append("stateStr", myState.toString());
bb.append("uptime", (unsigned)(time(0) - serverGlobalParams.started));
if (!_self->config().arbiterOnly) {
bb.appendTimestamp("optime", lastOpTimeWritten.asDate());
bb.appendDate("optimeDate", lastOpTimeWritten.getSecs() * 1000LL);
}
int maintenance = _maintenanceMode;
if (maintenance) {
bb.append("maintenanceMode", maintenance);
}
if ( !syncTarget.empty() &&
(myState != MemberState::RS_PRIMARY) &&
(myState != MemberState::RS_REMOVED) ) {
bb.append("syncingTo", syncTarget.toString());
}
if (theReplSet) {
string s = theReplSet->hbmsg();
if( !s.empty() )
bb.append("infoMessage", s);
if (myState == MemberState::RS_PRIMARY) {
bb.appendTimestamp("electionTime", theReplSet->getElectionTime().asDate());
bb.appendDate("electionDate", theReplSet->getElectionTime().getSecs() * 1000LL);
}
}
bb.append("self", true);
v.push_back(bb.obj());
}
Member *m =_members.head();
while( m ) {
BSONObjBuilder bb;
bb.append("_id", (int) m->id());
bb.append("name", m->fullName());
double h = m->hbinfo().health;
bb.append("health", h);
bb.append("state", (int) m->state().s);
if( h == 0 ) {
// if we can't connect the state info is from the past and could be confusing to show
bb.append("stateStr", "(not reachable/healthy)");
}
else {
bb.append("stateStr", m->state().toString());
}
bb.append("uptime", (unsigned) (m->hbinfo().upSince ? (time(0)-m->hbinfo().upSince) : 0));
if (!m->config().arbiterOnly) {
bb.appendTimestamp("optime", m->hbinfo().opTime.asDate());
bb.appendDate("optimeDate", m->hbinfo().opTime.getSecs() * 1000LL);
}
bb.appendTimeT("lastHeartbeat", m->hbinfo().lastHeartbeat);
bb.appendTimeT("lastHeartbeatRecv", m->hbinfo().lastHeartbeatRecv);
bb.append("pingMs", m->hbinfo().ping);
string s = m->lhb();
if( !s.empty() )
bb.append("lastHeartbeatMessage", s);
if (m->hbinfo().authIssue) {
bb.append("authenticated", false);
}
string syncingTo = m->hbinfo().syncingTo;
if (!syncingTo.empty()) {
bb.append("syncingTo", syncingTo);
}
if (m->state() == MemberState::RS_PRIMARY) {
bb.appendTimestamp("electionTime", m->hbinfo().electionTime.asDate());
bb.appendDate("electionDate", m->hbinfo().electionTime.getSecs() * 1000LL);
}
v.push_back(bb.obj());
m = m->next();
}
sort(v.begin(), v.end());
b.append("set", name());
b.appendTimeT("date", time(0));
b.append("myState", myState.s);
if ( !syncTarget.empty() &&
(myState != MemberState::RS_PRIMARY) &&
(myState != MemberState::RS_REMOVED) ) {
b.append("syncingTo", syncTarget.toString());
//.........这里部分代码省略.........
示例2: _summarizeStatus
void ReplSetImpl::_summarizeStatus(BSONObjBuilder& b) const {
vector<BSONObj> v;
const Member *_self = this->_self;
verify( _self );
MemberState myState = box.getState();
// add self
{
BSONObjBuilder bb;
bb.append("_id", (int) _self->id());
bb.append("name", _self->fullName());
bb.append("health", 1.0);
bb.append("state", (int)myState.s);
bb.append("stateStr", myState.toString());
bb.append("uptime", (unsigned)(time(0) - cmdLine.started));
if (!_self->config().arbiterOnly) {
GTID lastLive;
GTID lastUnapplied;
GTID minLive;
GTID minUnapplied;
gtidManager->getGTIDs(
&lastLive,
&lastUnapplied,
&minLive,
&minUnapplied
);
bb.appendDate("optimeDate", gtidManager->getCurrTimestamp());
bb.append("lastGTID", lastLive.toString());
bb.append("lastUnappliedGTID", lastUnapplied.toString());
bb.append("minLiveGTID", minLive.toString());
bb.append("minUnappliedGTID", minUnapplied.toString());
bb.append("oplogVersion", ReplSetConfig::OPLOG_VERSION);
}
int maintenance = _maintenanceMode;
if (maintenance) {
bb.append("maintenanceMode", maintenance);
}
if (theReplSet) {
string s = theReplSet->hbmsg();
if( !s.empty() )
bb.append("errmsg", s);
}
bb.append("self", true);
v.push_back(bb.obj());
}
Member *m =_members.head();
while( m ) {
BSONObjBuilder bb;
bb.append("_id", (int) m->id());
bb.append("name", m->fullName());
double h = m->hbinfo().health;
bb.append("health", h);
bb.append("state", (int) m->state().s);
if( h == 0 ) {
// if we can't connect the state info is from the past and could be confusing to show
bb.append("stateStr", "(not reachable/healthy)");
}
else {
bb.append("stateStr", m->state().toString());
}
bb.append("uptime", (unsigned) (m->hbinfo().upSince ? (time(0)-m->hbinfo().upSince) : 0));
if (!m->config().arbiterOnly) {
bb.appendDate("optimeDate", m->hbinfo().opTime);
bb.append("lastGTID", m->hbinfo().gtid.toString());
bb.append("lastUnappliedGTID", m->hbinfo().lastUnappliedGTID.toString());
bb.append("minLiveGTID", m->hbinfo().minLiveGTID.toString());
bb.append("minUnappliedGTID", m->hbinfo().minUnappliedGTID.toString());
bb.append("oplogVersion", m->hbinfo().oplogVersion);
}
bb.appendTimeT("lastHeartbeat", m->hbinfo().lastHeartbeat);
bb.appendTimeT("lastHeartbeatRecv", m->getLastRecvHeartbeat());
bb.append("pingMs", m->hbinfo().ping);
string s = m->lhb();
if( !s.empty() )
bb.append("lastHeartbeatMessage", s);
if (m->hbinfo().authIssue) {
bb.append("authenticated", false);
}
string syncingTo = m->hbinfo().syncingTo;
if (!syncingTo.empty()) {
bb.append("syncingTo", syncingTo);
}
v.push_back(bb.obj());
m = m->next();
}
sort(v.begin(), v.end());
b.append("set", name());
b.appendTimeT("date", time(0));
b.append("myState", myState.s);
const Member *syncTarget = BackgroundSync::get()->getSyncTarget();
if ( syncTarget &&
(myState != MemberState::RS_PRIMARY) &&
//.........这里部分代码省略.........
示例3: _summarizeStatus
void ReplSetImpl::_summarizeStatus(BSONObjBuilder& b) const {
vector<BSONObj> v;
const Member *_self = this->_self;
verify( _self );
MemberState myState = box.getState();
// add self
{
BSONObjBuilder bb;
bb.append("_id", (int) _self->id());
bb.append("name", _self->fullName());
bb.append("health", 1.0);
bb.append("state", (int)myState.s);
bb.append("stateStr", myState.toString());
bb.append("uptime", (unsigned)(time(0) - cmdLine.started));
if (!_self->config().arbiterOnly) {
bb.appendTimestamp("optime", lastOpTimeWritten.asDate());
bb.appendDate("optimeDate", lastOpTimeWritten.getSecs() * 1000LL);
}
int maintenance = _maintenanceMode;
if (maintenance) {
bb.append("maintenanceMode", maintenance);
}
if (theReplSet) {
string s = theReplSet->hbmsg();
if( !s.empty() )
bb.append("errmsg", s);
}
bb.append("self", true);
v.push_back(bb.obj());
}
Member *m =_members.head();
while( m ) {
BSONObjBuilder bb;
bb.append("_id", (int) m->id());
bb.append("name", m->fullName());
double h = m->hbinfo().health;
bb.append("health", h);
bb.append("state", (int) m->state().s);
if( h == 0 ) {
// if we can't connect the state info is from the past and could be confusing to show
bb.append("stateStr", "(not reachable/healthy)");
}
else {
bb.append("stateStr", m->state().toString());
}
bb.append("uptime", (unsigned) (m->hbinfo().upSince ? (time(0)-m->hbinfo().upSince) : 0));
if (!m->config().arbiterOnly) {
bb.appendTimestamp("optime", m->hbinfo().opTime.asDate());
bb.appendDate("optimeDate", m->hbinfo().opTime.getSecs() * 1000LL);
}
bb.appendTimeT("lastHeartbeat", m->hbinfo().lastHeartbeat);
bb.append("pingMs", m->hbinfo().ping);
string s = m->lhb();
if( !s.empty() )
bb.append("errmsg", s);
if (m->hbinfo().authIssue) {
bb.append("authenticated", false);
}
v.push_back(bb.obj());
m = m->next();
}
sort(v.begin(), v.end());
b.append("set", name());
b.appendTimeT("date", time(0));
b.append("myState", myState.s);
const Member *syncTarget = _currentSyncTarget;
if ( syncTarget &&
(myState != MemberState::RS_PRIMARY) &&
(myState != MemberState::RS_SHUNNED) ) {
b.append("syncingTo", syncTarget->fullName());
}
b.append("members", v);
if( replSetBlind )
b.append("blind",true); // to avoid confusion if set...normally never set except for testing.
}