@Test public void multipleHostsTest() throws ConnectionException { Map<String, String> properties = new HashMap<String, String>(); properties.put(HOST.getOptionName(), SERVER_IP_LIST); properties.put(PORT.getOptionName(), SERVER_PORT_LIST); ConnectorClusterConfig wrongConfig = new ConnectorClusterConfig(CLUSTER_NAME, null, properties); MongoClientConfiguration config = new MongoClientConfiguration(wrongConfig); assertTrue("There must be 2 seeds", config.getSeeds().size() == 2); assertEquals("The port is not the expected", 2700, config.getSeeds().get(0).getPort()); assertEquals("The port is not the expected", 2701, config.getSeeds().get(1).getPort()); }
public List<ServerAddress> getSeeds() throws ConnectionException { ArrayList<ServerAddress> seeds = new ArrayList<ServerAddress>(); String[] hosts = configurationManager.recoverConfigurationValue(HOST); String[] ports = configurationManager.recoverConfigurationValue(PORT); if (hosts.length < 1 || (hosts.length != ports.length)) { throw new ConnectionException("invalid address"); } else { for (int i = 0; i < hosts.length; i++) { try { seeds.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i]))); } catch (NumberFormatException e) { throw new ConnectionException("wrong port format " + ports[i], e); } catch (UnknownHostException e) { throw new ConnectionException("connection failed with" + hosts[i], e); } } } return seeds; }
MongoClientConfiguration { public List<ServerAddress> getSeeds() throws ConnectionException { ArrayList<ServerAddress> seeds = new ArrayList<ServerAddress>(); String[] hosts = configurationManager.recoverConfigurationValue(HOST); String[] ports = configurationManager.recoverConfigurationValue(PORT); if (hosts.length < 1 || (hosts.length != ports.length)) { throw new ConnectionException("invalid address"); } else { for (int i = 0; i < hosts.length; i++) { try { seeds.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i]))); } catch (NumberFormatException e) { throw new ConnectionException("wrong port format " + ports[i], e); } catch (UnknownHostException e) { throw new ConnectionException("connection failed with" + hosts[i], e); } } } return seeds; } }
MongoClientConfiguration { public List<ServerAddress> getSeeds() throws ConnectionException { ArrayList<ServerAddress> seeds = new ArrayList<ServerAddress>(); String[] hosts = configurationManager.recoverConfigurationValue(HOST); String[] ports = configurationManager.recoverConfigurationValue(PORT); if (hosts.length < 1 || (hosts.length != ports.length)) { throw new ConnectionException("invalid address"); } else { for (int i = 0; i < hosts.length; i++) { try { seeds.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i]))); } catch (NumberFormatException e) { throw new ConnectionException("wrong port format " + ports[i], e); } catch (UnknownHostException e) { throw new ConnectionException("connection failed with" + hosts[i], e); } } } return seeds; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); }
MongoClientConfiguration { public List<ServerAddress> getSeeds() throws ConnectionException { ArrayList<ServerAddress> seeds = new ArrayList<ServerAddress>(); String[] hosts = configurationManager.recoverConfigurationValue(HOST); String[] ports = configurationManager.recoverConfigurationValue(PORT); if (hosts.length < 1 || (hosts.length != ports.length)) { throw new ConnectionException("invalid address"); } else { for (int i = 0; i < hosts.length; i++) { try { seeds.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i]))); } catch (NumberFormatException e) { throw new ConnectionException("wrong port format " + ports[i], e); } catch (UnknownHostException e) { throw new ConnectionException("connection failed with" + hosts[i], e); } } } return seeds; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); MongoClientOptions getMongoClientOptions(); List<ServerAddress> getSeeds(); }
MongoClientConfiguration { public List<ServerAddress> getSeeds() throws ConnectionException { ArrayList<ServerAddress> seeds = new ArrayList<ServerAddress>(); String[] hosts = configurationManager.recoverConfigurationValue(HOST); String[] ports = configurationManager.recoverConfigurationValue(PORT); if (hosts.length < 1 || (hosts.length != ports.length)) { throw new ConnectionException("invalid address"); } else { for (int i = 0; i < hosts.length; i++) { try { seeds.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i]))); } catch (NumberFormatException e) { throw new ConnectionException("wrong port format " + ports[i], e); } catch (UnknownHostException e) { throw new ConnectionException("connection failed with" + hosts[i], e); } } } return seeds; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); MongoClientOptions getMongoClientOptions(); List<ServerAddress> getSeeds();  }