def get_config_server(self, force=False):
if force or not self.config_server:
configdb_uri = self.get_configdb_hosts()
try:
logging.info("Found sharding config server: %s" % configdb_uri)
if self.db.uri.hosts() == configdb_uri.hosts():
self.config_db = self.db
logging.debug("Re-using seed connection to config server(s)")
else:
self.config_db = DB(configdb_uri, self.config, True)
if self.config_db.is_replset():
self.config_server = Replset(self.config, self.config_db)
else:
self.config_server = {'host': configdb_uri.hosts()}
self.config_db.close()
except Exception, e:
logging.fatal("Unable to locate config servers using %s: %s!" % (self.db.uri, e))
raise OperationError(e)
return self.config_server
评论列表
文章目录