bool ReplicationCoordinatorImpl::canAcceptWritesForDatabase(StringData dbName) {
|
// _canAcceptNonLocalWrites is always true for standalone nodes, always false for nodes
|
// started with --slave, and adjusted based on primary+drain state in replica sets.
|
//
|
// That is, stand-alone nodes, non-slave nodes and drained replica set primaries can always
|
// accept writes. Similarly, writes are always permitted to the "local" database. Finally,
|
// in the event that a node is started with --slave and --master, we allow writes unless the
|
// master/slave system has set the replAllDead flag.
|
if (_canAcceptNonLocalWrites) {
|
return true;
|
}
|
if (dbName == kLocalDB) {
|
return true;
|
}
|
return !replAllDead && _settings.isMaster();
|
}
|