use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class ClusterDescriptionTest method testSortingOfAll.
@Test
@SuppressWarnings("deprecation")
public void testSortingOfAll() throws UnknownHostException {
ClusterDescription description = new ClusterDescription(MULTIPLE, UNKNOWN, asList(builder().state(CONNECTING).address(new ServerAddress("loc:27019")).build(), builder().state(CONNECTING).address(new ServerAddress("loc:27018")).build(), builder().state(CONNECTING).address(new ServerAddress("loc:27017")).build()));
Iterator<ServerDescription> iter = description.getAll().iterator();
assertEquals(new ServerAddress("loc:27017"), iter.next().getAddress());
assertEquals(new ServerAddress("loc:27018"), iter.next().getAddress());
assertEquals(new ServerAddress("loc:27019"), iter.next().getAddress());
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class ClusterDescriptionTest method setUp.
@Before
public void setUp() throws IOException {
TagSet tags1 = new TagSet(asList(new Tag("foo", "1"), new Tag("bar", "2"), new Tag("baz", "1")));
TagSet tags2 = new TagSet(asList(new Tag("foo", "1"), new Tag("bar", "2"), new Tag("baz", "2")));
TagSet tags3 = new TagSet(asList(new Tag("foo", "1"), new Tag("bar", "3"), new Tag("baz", "3")));
primary = builder().state(CONNECTED).address(new ServerAddress("localhost", 27017)).ok(true).type(REPLICA_SET_PRIMARY).tagSet(tags1).build();
secondary = builder().state(CONNECTED).address(new ServerAddress("localhost", 27018)).ok(true).type(REPLICA_SET_SECONDARY).tagSet(tags2).build();
otherSecondary = builder().state(CONNECTED).address(new ServerAddress("otherhost", 27019)).ok(true).type(REPLICA_SET_SECONDARY).tagSet(tags3).build();
uninitiatedMember = builder().state(CONNECTED).address(new ServerAddress("localhost", 27020)).ok(true).type(REPLICA_SET_OTHER).build();
notOkMember = builder().state(CONNECTED).address(new ServerAddress("localhost", 27021)).ok(false).build();
List<ServerDescription> nodeList = asList(primary, secondary, otherSecondary, uninitiatedMember, notOkMember);
cluster = new ClusterDescription(MULTIPLE, REPLICA_SET, nodeList);
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class X509AuthenticatorNoUserNameTest method before.
@Before
public void before() {
connection = new TestInternalConnection(new ServerId(new ClusterId(), new ServerAddress("localhost", 27017)));
connectionDescriptionThreeTwo = new ConnectionDescription(new ConnectionId(new ServerId(new ClusterId(), new ServerAddress())), new ServerVersion(3, 2), ServerType.STANDALONE, 1000, 16000, 48000);
connectionDescriptionThreeFour = new ConnectionDescription(new ConnectionId(new ServerId(new ClusterId(), new ServerAddress())), new ServerVersion(3, 4), ServerType.STANDALONE, 1000, 16000, 48000);
credential = MongoCredential.createMongoX509Credential("CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US");
subject = new X509Authenticator(this.credential);
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class X509AuthenticatorUnitTest method before.
@Before
public void before() {
connection = new TestInternalConnection(new ServerId(new ClusterId(), new ServerAddress("localhost", 27017)));
connectionDescription = new ConnectionDescription(new ServerId(new ClusterId(), new ServerAddress()));
credential = MongoCredential.createMongoX509Credential("CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US");
subject = new X509Authenticator(this.credential);
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class LatencyMinimizingServerSelectorTest method testZeroLatencyDifferentialTolerance.
@Test
public void testZeroLatencyDifferentialTolerance() throws UnknownHostException {
LatencyMinimizingServerSelector selector = new LatencyMinimizingServerSelector(0, TimeUnit.NANOSECONDS);
ServerDescription primary = ServerDescription.builder().state(CONNECTED).address(new ServerAddress()).ok(true).type(ServerType.REPLICA_SET_PRIMARY).roundTripTime(10, TimeUnit.NANOSECONDS).build();
ServerDescription secondaryOne = ServerDescription.builder().state(CONNECTED).address(new ServerAddress("localhost:27018")).ok(true).type(ServerType.REPLICA_SET_SECONDARY).roundTripTime(11, TimeUnit.NANOSECONDS).build();
assertEquals(Arrays.asList(primary), selector.select(new ClusterDescription(MULTIPLE, REPLICA_SET, Arrays.asList(primary, secondaryOne))));
}
Aggregations