mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
rs
This commit is contained in:
parent
cad5f3e5a5
commit
51c11bc0ce
@ -110,7 +110,8 @@ namespace mongo {
|
||||
inline void raiseError(int code , const char *msg) {
|
||||
LastError *le = lastError.get();
|
||||
if ( le == 0 ) {
|
||||
DEV log() << "warning: lastError==0 can't report:" << msg << '\n';
|
||||
/* might be intentional (non-user thread) */
|
||||
DEV log() << "warning dev: lastError==0 won't report:" << msg << '\n';
|
||||
} else if ( le->disabled ) {
|
||||
log() << "lastError disabled, can't report: " << msg << endl;
|
||||
} else {
|
||||
|
@ -106,17 +106,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void ReplSet::Consensus::electSelf() {
|
||||
static mutex m;
|
||||
{
|
||||
scoped_lock lk(m);
|
||||
if( inprog ) return;
|
||||
inprog = true;
|
||||
}
|
||||
try { _electSelf(); } catch(...) { }
|
||||
{
|
||||
scoped_lock lk(m);
|
||||
inprog = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,7 +97,6 @@ namespace mongo {
|
||||
ReplSetHealthPoll() {}
|
||||
string name() { return "ReplSetHealthPoll"; }
|
||||
void doWork() {
|
||||
mongo::lastError.initThread();
|
||||
RSMember mem = m;
|
||||
RSMember old = mem;
|
||||
try {
|
||||
@ -120,7 +119,8 @@ namespace mongo {
|
||||
|
||||
be cfg = info["config"];
|
||||
if( cfg.ok() ) {
|
||||
ReplSetConfig::receivedNewConfig(cfg.Obj());
|
||||
// received a new config
|
||||
theReplSet->mgr->send(cfg.Obj().copy());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -52,10 +52,7 @@ namespace mongo {
|
||||
|
||||
/** called as the health threads get new results */
|
||||
void ReplSet::Manager::checkNewState() {
|
||||
static mongo::mutex m;
|
||||
{
|
||||
scoped_lock lk(m);
|
||||
|
||||
const Member *p = _rs->currentPrimary();
|
||||
const Member *p2 = findOtherPrimary();
|
||||
try { p2 = findOtherPrimary(); }
|
||||
@ -101,8 +98,18 @@ namespace mongo {
|
||||
}
|
||||
|
||||
bool ReplSet::Manager::got(const any& msg) {
|
||||
assert( CheckNewState == any_cast<Messages>(msg) );
|
||||
checkNewState();
|
||||
if( msg.type() == typeid(Messages) ) {
|
||||
assert( CheckNewState == any_cast<Messages>(msg) );
|
||||
checkNewState();
|
||||
}
|
||||
else if( msg.type() == typeid(BSONObj) ) {
|
||||
log() << "replSet todo finish code in replset manager: call receivedNewConfig" << rsLog;
|
||||
BSONObj o = any_cast<BSONObj>(msg);
|
||||
log() << "replSet " << o.toString() << rsLog;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
replica set notes
|
||||
|
||||
health.h
|
||||
struct HealthOptions
|
||||
requestHeartbeat()
|
||||
|
||||
health.cpp
|
||||
startHealthThreads()
|
||||
requestHeartbeat()
|
||||
cmd replSetHeartbeat
|
||||
FeedbackThread calls requestHeartbeat
|
||||
|
||||
|
||||
|
||||
|
||||
optimes
|
||||
|
||||
|
||||
a1
|
||||
a2
|
||||
a3
|
||||
a4
|
||||
a5
|
@ -209,7 +209,11 @@ namespace mongo {
|
||||
startupStatus = STARTED;
|
||||
}
|
||||
|
||||
/* forked as a thread during startup */
|
||||
/* forked as a thread during startup
|
||||
it can run quite a while looking for config. but once found,
|
||||
a separate thread takes over as ReplSet::Manager, and this thread
|
||||
terminates.
|
||||
*/
|
||||
void startReplSets() {
|
||||
Client::initThread("startReplSets");
|
||||
try {
|
||||
@ -221,9 +225,9 @@ namespace mongo {
|
||||
(theReplSet = new ReplSet(cmdLine.replSet))->go();
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
log() << "replSet Caught exception in management thread: " << e.what() << rsLog;
|
||||
log() << "replSet caught exception in startReplSets thread: " << e.what() << rsLog;
|
||||
if( theReplSet )
|
||||
theReplSet->fatal();
|
||||
theReplSet->fatal(); // concurrency: this maybe should be a message.
|
||||
}
|
||||
cc().shutdown();
|
||||
}
|
||||
|
@ -84,10 +84,9 @@ namespace mongo {
|
||||
|
||||
class Consensus {
|
||||
ReplSet &rs;
|
||||
bool inprog;
|
||||
void _electSelf();
|
||||
public:
|
||||
Consensus(ReplSet *t) : rs(*t),inprog(false) { }
|
||||
Consensus(ReplSet *t) : rs(*t) { }
|
||||
int totalVotes() const;
|
||||
bool aMajoritySeemsToBeUp() const;
|
||||
void electSelf();
|
||||
|
Loading…
Reference in New Issue
Block a user