diff options
author | Jason Carey <jcarey@argv.me> | 2019-05-13 18:23:12 -0400 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2019-05-28 15:44:50 -0400 |
commit | 6aab87a22ec4bd89c8ef6495eeaded0829ccff7f (patch) | |
tree | 73b40abb367e1adf11cddce1bf211823c50723f8 /src/mongo/client/remote_command_targeter_mock.cpp | |
parent | 31e9ec1aad0a27a0ad0f0cb731c2fdcd22805c41 (diff) | |
download | mongo-6aab87a22ec4bd89c8ef6495eeaded0829ccff7f.tar.gz |
SERVER-41134 Add RSM::findHostsWithMaxWait
Add support for a new method on the ReplicaSetMonitor, which finds all
acceptable hosts for a read preference (rather than just a single host).
This should use existing selection logic to return the host that would
be returned by findHostWithMaxWait in the [0]th element
Diffstat (limited to 'src/mongo/client/remote_command_targeter_mock.cpp')
-rw-r--r-- | src/mongo/client/remote_command_targeter_mock.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/mongo/client/remote_command_targeter_mock.cpp b/src/mongo/client/remote_command_targeter_mock.cpp index 4cec97a246d..164b1e593b3 100644 --- a/src/mongo/client/remote_command_targeter_mock.cpp +++ b/src/mongo/client/remote_command_targeter_mock.cpp @@ -55,11 +55,24 @@ ConnectionString RemoteCommandTargeterMock::connectionString() { StatusWith<HostAndPort> RemoteCommandTargeterMock::findHost(OperationContext* opCtx, const ReadPreferenceSetting& readPref) { - return _findHostReturnValue; + if (!_findHostReturnValue.isOK()) { + return _findHostReturnValue.getStatus(); + } + + return _findHostReturnValue.getValue()[0]; } SemiFuture<HostAndPort> RemoteCommandTargeterMock::findHostWithMaxWait( const ReadPreferenceSetting& readPref, Milliseconds maxTime) { + if (!_findHostReturnValue.isOK()) { + return _findHostReturnValue.getStatus(); + } + + return _findHostReturnValue.getValue()[0]; +} + +SemiFuture<std::vector<HostAndPort>> RemoteCommandTargeterMock::findHostsWithMaxWait( + const ReadPreferenceSetting& readPref, Milliseconds maxWait) { return _findHostReturnValue; } @@ -79,6 +92,15 @@ void RemoteCommandTargeterMock::setConnectionStringReturnValue(const ConnectionS } void RemoteCommandTargeterMock::setFindHostReturnValue(StatusWith<HostAndPort> returnValue) { + if (!returnValue.isOK()) { + _findHostReturnValue = returnValue.getStatus(); + } else { + _findHostReturnValue = std::vector{returnValue.getValue()}; + } +} + +void RemoteCommandTargeterMock::setFindHostsReturnValue( + StatusWith<std::vector<HostAndPort>> returnValue) { _findHostReturnValue = std::move(returnValue); } |