コード例 #1
0
 @Test
 public void testSortingOfAll() throws UnknownHostException {
   ClusterDescription description =
       new ClusterDescription(
           Multiple,
           Unknown,
           Arrays.asList(
               ServerDescription.builder()
                   .state(Connecting)
                   .address(new ServerAddress("loc:27019"))
                   .build(),
               ServerDescription.builder()
                   .state(Connecting)
                   .address(new ServerAddress("loc:27018"))
                   .build(),
               ServerDescription.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());
 }
コード例 #2
0
 @Override
 public List<ServerDescription> choose(final ClusterDescription clusterDescription) {
   return getServersWithAcceptableLatencyDifference(
       clusterDescription.getAll(), getBestPingTimeNanos(clusterDescription.getAll()));
 }
コード例 #3
0
 @Test
 public void testEmptySet() {
   ClusterDescription description =
       new ClusterDescription(Multiple, Unknown, Collections.<ServerDescription>emptyList());
   assertTrue(description.getAll().isEmpty());
 }