@Test public void noServersTest() { Janus janus = new Janus( VIP_TEST, new ConstServerList(VIP_TEST), new RandomLoadBalancer(), new ServerStatsFactory(ServerStats.class,new MetricRegistry()) ); Assert.assertNull(janus.getServer()); }
public ServerStats getServer() { updateServerList(); Collection<ServerStats> serverStats = servers.values(); List<ServerStats> availableServerStats = new ArrayList<>(serverStats.size()); for (ServerStats s : serverStats) { if (s.getServerInstance().isAvailable()) { availableServerStats.add(s); } } if (availableServerStats.isEmpty()) { return null; } return loadBalancer.choose(availableServerStats); }
Janus { public ServerStats getServer() { updateServerList(); Collection<ServerStats> serverStats = servers.values(); List<ServerStats> availableServerStats = new ArrayList<>(serverStats.size()); for (ServerStats s : serverStats) { if (s.getServerInstance().isAvailable()) { availableServerStats.add(s); } } if (availableServerStats.isEmpty()) { return null; } return loadBalancer.choose(availableServerStats); } }
Janus { public ServerStats getServer() { updateServerList(); Collection<ServerStats> serverStats = servers.values(); List<ServerStats> availableServerStats = new ArrayList<>(serverStats.size()); for (ServerStats s : serverStats) { if (s.getServerInstance().isAvailable()) { availableServerStats.add(s); } } if (availableServerStats.isEmpty()) { return null; } return loadBalancer.choose(availableServerStats); } Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory);  Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory, long refreshInterval); }
Janus { public ServerStats getServer() { updateServerList(); Collection<ServerStats> serverStats = servers.values(); List<ServerStats> availableServerStats = new ArrayList<>(serverStats.size()); for (ServerStats s : serverStats) { if (s.getServerInstance().isAvailable()) { availableServerStats.add(s); } } if (availableServerStats.isEmpty()) { return null; } return loadBalancer.choose(availableServerStats); } Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory);  Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory, long refreshInterval); void setRefreshInterval(long refreshInterval); long getRefreshInterval(); String getServiceName(); ServerStats getServer(); static Builder builder(String serviceName); }
Janus { public ServerStats getServer() { updateServerList(); Collection<ServerStats> serverStats = servers.values(); List<ServerStats> availableServerStats = new ArrayList<>(serverStats.size()); for (ServerStats s : serverStats) { if (s.getServerInstance().isAvailable()) { availableServerStats.add(s); } } if (availableServerStats.isEmpty()) { return null; } return loadBalancer.choose(availableServerStats); } Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory);  Janus(String serviceName, ServerList serverList, LoadBalancer loadBalancer, StatsFactory statsFactory, long refreshInterval); void setRefreshInterval(long refreshInterval); long getRefreshInterval(); String getServiceName(); ServerStats getServer(); static Builder builder(String serviceName); static final String REFRESH_INTERVAL_IN_MILLIS; static final long DEFAULT_REFRESH_INTERVAL_IN_MILLIS; }