MongoClient::connectToReplSet PHP Метод

connectToReplSet() приватный Метод

Attempts to connect to the MongoDB replSet and retrieve the replSet status, updating the host list with the proper host list from the replSet isMaster() command.
private connectToReplSet ( )
    private function connectToReplSet()
    {
        $repl_set_info = $this->getReplSetInfo();
        // Get replset info from the PRIMARY
        // This will fail to get info if server is not using a replica set, but that's fine
        if ($repl_set_info['ok'] != 1 || !$repl_set_info['retval']['conf'] || !$repl_set_info['retval']['status']) {
            // If we're trying to use a replica set, this is fatal
            $msg = "Unable to get replica set config & status for host {$host}";
            throw new MongoConnectionException($msg);
        } else {
            $prunedMembers = array();
            foreach ($repl_set_info['retval']['status']['members'] as $member) {
                // We only care about hosts in our host list which have already have been updated
                // with the valid list from isMaster() and won't include arbiters/hidden members
                if (isset($this->hosts[$member['name']])) {
                    $this->hosts[$member['name']]['health'] = $member['health'];
                    $this->hosts[$member['name']]['state'] = $member['state'];
                    $prunedMembers[] = $member;
                }
            }
            // We don't care about members that aren't part of our host list as we can't read from or write to them
            $repl_set_info['retval']['status']['members'] = $prunedMembers;
            $this->replSetStatus = $repl_set_info['retval']['status'];
            $this->replSetConf = $repl_set_info['retval']['conf'];
        }
    }