void SyncClusterConnection::_connect(const std::string& hostStr) {
    log() << "SyncClusterConnection connecting to [" << hostStr << "]" << endl;
    const HostAndPort host(hostStr);
    DBClientConnection* c;
    if (connectionHook) {
        c = new DBClientConnection(
            true,  // auto reconnect
            0,     // socket timeout
        [this, host](const executor::RemoteCommandResponse& isMasterReply) {
            return connectionHook(host, isMasterReply);
        });
    } else {
        c = new DBClientConnection(true);
    }

    c->setRequestMetadataWriter(getRequestMetadataWriter());
    c->setReplyMetadataReader(getReplyMetadataReader());
    c->setSoTimeout(_socketTimeout);
    Status status = c->connect(host);
    if (!status.isOK()) {
        log() << "SyncClusterConnection connect fail to: " << hostStr << causedBy(status);
        if (status == ErrorCodes::IncompatibleCatalogManager) {
            // Make sure to propagate IncompatibleCatalogManager errors to trigger catalog manager
            // swapping.
            uassertStatusOK(status);
        }
    }
    _connAddresses.push_back(hostStr);
    _conns.push_back(c);
}
示例#2
0
void SyncClusterConnection::_connect(const std::string& host) {
    log() << "SyncClusterConnection connecting to [" << host << "]" << endl;
    DBClientConnection* c = new DBClientConnection(true);
    c->setRequestMetadataWriter(getRequestMetadataWriter());
    c->setReplyMetadataReader(getReplyMetadataReader());
    c->setSoTimeout(_socketTimeout);
    string errmsg;
    if (!c->connect(HostAndPort(host), errmsg))
        log() << "SyncClusterConnection connect fail to: " << host << " errmsg: " << errmsg << endl;
    _connAddresses.push_back(host);
    _conns.push_back(c);
}