private function getReplSetInfo()
{
$primary_protocol = $this->connectToReplSetPrimary();
// Make sure we have a conection to the PRIMARY
$cache_key = "mongofill:replSetInfo:{$primary_protocol->getServerHash()}:" . __FILE__;
$result = MONGOFILL_USE_APC ? apc_fetch($cache_key) : false;
if (!$result) {
// Temporarily enforce PRIMARY read because we need this collection to come from the
// PRIMARY server which we have already established a connection to.
$configured_read_preference = $this->getReadPreference();
$this->setReadPreference(static::RP_PRIMARY);
$conf = $this->selectDB('local')->selectCollection('system.replset')->findOne();
$this->readPreference = $configured_read_preference;
// Set our RP back directly, bypass setReadPreference()
// This will use the write protocol which is already established as the PRIMARY
$status = $this->selectDB('admin')->command(['replSetGetStatus' => 1]);
$result = ['ok' => 1, 'retval' => ['conf' => $conf, 'status' => $status]];
if (MONGOFILL_USE_APC) {
apc_store($cache_key, $result, self::REPL_SET_CACHE_LIFETIME);
}
}
return $result;
}