for (Host host : ring.getHostsSorted()) { if (ringGroupConductorMode != RingGroupConductorMode.PROACTIVE || Hosts.isOnline(host)) {
protected HostData getHostData(Host host) throws IOException { HostData data = new HostData(); data.address = host.getAddress(); data.isOnline = Hosts.isOnline(host); data.state = host.getState(); data.statisticsString = host.getStatistic(Hosts.RUNTIME_STATISTICS_KEY); data.statisticsJson = getRuntimeStatsString(host); return data; }
if (Hosts.isOnline(host)) { throw new RuntimeException("Could not start a partition server for host " + host + " since it is already online.");
@Test public void testSetState() throws Exception { ZkHost host = ZkHost.create(getZk(), coordinator, getRoot(), ADDRESS, null, Collections.emptyList()); assertEquals(HostState.OFFLINE, host.getState()); assertFalse(Hosts.isOnline(host)); host.setState(HostState.IDLE); waitUntilHost(HostState.IDLE, host); assertEquals(HostState.IDLE, host.getState()); assertTrue(Hosts.isOnline(host)); host.setState(HostState.OFFLINE); waitUntilHost(HostState.OFFLINE, host); assertEquals(HostState.OFFLINE, host.getState()); assertFalse(Hosts.isOnline(host)); host.close(); }
@Test public void testCreateAndLoad() throws Exception { final ZkHost host = ZkHost.create(getZk(), coordinator, getRoot(), ADDRESS, null, Collections.emptyList()); assertEquals(ADDRESS, host.getAddress()); assertEquals(0, host.getCommandQueue().size()); assertNull(host.getCurrentCommand()); assertEquals(HostState.OFFLINE, host.getState()); assertFalse(Hosts.isOnline(host)); host.setEphemeralStatistic("a", "A"); host.setEphemeralStatistic("b", "B"); WaitUntil.orDie(() -> { try { return "A".equals(host.getStatistic("a")) && "B".equals(host.getStatistic("b")); } catch (IOException e) { throw new RuntimeException(e); } }); assertEquals("A", host.getStatistic("a")); assertEquals("B", host.getStatistic("b")); assertNull(host.getStatistic("c")); host.setAddress(OTHER_ADDRESS); WaitUntil.orDie(() -> host.getAddress().equals(OTHER_ADDRESS)); assertEquals(OTHER_ADDRESS, host.getAddress()); }