use of com.mongodb.internal.selector.LatencyMinimizingServerSelector in project mongo-java-driver by mongodb.
the class ServerSelectionSelectionTest method shouldPassAllOutcomes.
@Test
public void shouldPassAllOutcomes() {
// skip this test because the driver prohibits maxStaleness or tagSets with mode of primary at a much lower level
assumeTrue(!description.equals("max-staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.json"));
ServerSelector serverSelector = null;
List<ServerDescription> suitableServers = buildServerDescriptions(definition.getArray("suitable_servers", new BsonArray()));
List<ServerDescription> selectedServers = null;
try {
serverSelector = getServerSelector();
selectedServers = serverSelector.select(clusterDescription);
if (error) {
fail("Should have thrown exception");
}
} catch (MongoConfigurationException e) {
if (!error) {
fail("Should not have thrown exception: " + e);
}
return;
}
assertServers(selectedServers, suitableServers);
ServerSelector latencyBasedServerSelector = new CompositeServerSelector(asList(serverSelector, new LatencyMinimizingServerSelector(15, TimeUnit.MILLISECONDS)));
List<ServerDescription> inLatencyWindowServers = buildServerDescriptions(definition.getArray("in_latency_window"));
List<ServerDescription> latencyBasedSelectedServers = latencyBasedServerSelector.select(clusterDescription);
assertServers(latencyBasedSelectedServers, inLatencyWindowServers);
}
use of com.mongodb.internal.selector.LatencyMinimizingServerSelector in project mongo-java-driver by mongodb.
the class CompositeServerSelectorTest method shouldApplyServerSelectorsInOrder.
@Test
public void shouldApplyServerSelectorsInOrder() {
selector = new CompositeServerSelector(asList(new ReadPreferenceServerSelector(secondary()), new LatencyMinimizingServerSelector(15, MILLISECONDS)));
assertEquals(selector.select(new ClusterDescription(MULTIPLE, REPLICA_SET, asList(first, second, third))), asList(second, third));
}
Aggregations