StatusWith<int> validateConfigForInitiate(ReplicationCoordinatorExternalState* externalState, const ReplSetConfig& newConfig, ServiceContext* ctx) { Status status = newConfig.validate(); if (!status.isOK()) { return StatusWith<int>(status); } status = newConfig.checkIfWriteConcernCanBeSatisfied(newConfig.getDefaultWriteConcern()); if (!status.isOK()) { return status.withContext( "Found invalid default write concern in 'getLastErrorDefaults' field"); } status = validateArbiterPriorities(newConfig); if (!status.isOK()) { return StatusWith<int>(status); } if (newConfig.getConfigVersion() != 1) { return StatusWith<int>(ErrorCodes::NewReplicaSetConfigurationIncompatible, str::stream() << "Configuration used to initiate a replica set must " << " have version 1, but found " << newConfig.getConfigVersion()); } return findSelfInConfigIfElectable(externalState, newConfig, ctx); }
StatusWith<int> validateConfigForReconfig(ReplicationCoordinatorExternalState* externalState, const ReplSetConfig& oldConfig, const ReplSetConfig& newConfig, ServiceContext* ctx, bool force) { Status status = newConfig.validate(); if (!status.isOK()) { return StatusWith<int>(status); } status = newConfig.checkIfWriteConcernCanBeSatisfied(newConfig.getDefaultWriteConcern()); if (!status.isOK()) { return status.withContext( "Found invalid default write concern in 'getLastErrorDefaults' field"); } status = validateOldAndNewConfigsCompatible(oldConfig, newConfig); if (!status.isOK()) { return StatusWith<int>(status); } status = validateArbiterPriorities(newConfig); if (!status.isOK()) { return StatusWith<int>(status); } if (force) { return findSelfInConfig(externalState, newConfig, ctx); } return findSelfInConfigIfElectable(externalState, newConfig, ctx); }
StatusWith<int> validateConfigForStartUp(ReplicationCoordinatorExternalState* externalState, const ReplSetConfig& newConfig, ServiceContext* ctx) { Status status = newConfig.validate(); if (!status.isOK()) { return StatusWith<int>(status); } return findSelfInConfig(externalState, newConfig, ctx); }