bool DataReplicatorExternalStateMock::shouldStopFetching(const HostAndPort& source,
                                                         const rpc::ReplSetMetadata& metadata) {
    lastSyncSourceChecked = source;
    syncSourceLastOpTime = metadata.getLastOpVisible();
    syncSourceHasSyncSource = metadata.getSyncSourceIndex() != -1;
    return shouldStopFetchingResult;
}
bool DataReplicatorExternalStateImpl::shouldStopFetching(const HostAndPort& source,
                                                         const rpc::ReplSetMetadata& metadata) {
    // Re-evaluate quality of sync target.
    if (_replicationCoordinator->shouldChangeSyncSource(source, metadata)) {
        LOG(1) << "Canceling oplog query because we have to choose a sync source. Current source: "
               << source << ", OpTime " << metadata.getLastOpVisible()
               << ", its sync source index:" << metadata.getSyncSourceIndex();
        return true;
    }
    return false;
}
예제 #3
0
bool DataReplicatorExternalStateMock::shouldStopFetching(
    const HostAndPort& source,
    const rpc::ReplSetMetadata& replMetadata,
    boost::optional<rpc::OplogQueryMetadata> oqMetadata) {
    lastSyncSourceChecked = source;

    // If OplogQueryMetadata was provided, use its values, otherwise use the ones in
    // ReplSetMetadata.
    if (oqMetadata) {
        syncSourceLastOpTime = oqMetadata->getLastOpApplied();
        syncSourceHasSyncSource = oqMetadata->getSyncSourceIndex() != -1;
    } else {
        syncSourceLastOpTime = replMetadata.getLastOpVisible();
        syncSourceHasSyncSource = replMetadata.getSyncSourceIndex() != -1;
    }
    return shouldStopFetchingResult;
}
bool DataReplicatorExternalStateImpl::shouldStopFetching(
    const HostAndPort& source,
    const rpc::ReplSetMetadata& replMetadata,
    boost::optional<rpc::OplogQueryMetadata> oqMetadata) {
    // Re-evaluate quality of sync target.
    if (_replicationCoordinator->shouldChangeSyncSource(source, replMetadata, oqMetadata)) {
        // If OplogQueryMetadata was provided, its values were used to determine if we should
        // change sync sources.
        if (oqMetadata) {
            log() << "Canceling oplog query due to OplogQueryMetadata. We have to choose a new "
                     "sync source. Current source: "
                  << source << ", OpTime " << oqMetadata->getLastOpApplied()
                  << ", its sync source index:" << oqMetadata->getSyncSourceIndex();

        } else {
            log() << "Canceling oplog query due to ReplSetMetadata. We have to choose a new sync "
                     "source. Current source: "
                  << source << ", OpTime " << replMetadata.getLastOpVisible()
                  << ", its sync source index:" << replMetadata.getSyncSourceIndex();
        }
        return true;
    }
    return false;
}