public static boolean isOnline(Host host) throws IOException { return host.getState() != HostState.OFFLINE; }
public HostState getStateSafe() { HostState state; try { state = host.getState(); } catch (IOException e) { LOG.error("Offline watcher failed to get state, counting as OFFLINE. Exception: ", e); state = HostState.OFFLINE; } return state; }
boolean isOffline() { try { return HostState.OFFLINE.equals(host.getState()); } catch (IOException e) { return false; } }
boolean isServing() { try { return HostState.SERVING.equals(host.getState()); } catch (IOException e) { return false; } }
public static Set<Host> getHostsInState(Ring ring, HostState state) throws IOException { Set<Host> results = new HashSet<Host>(); for (Host host : ring.getHosts()) { if (host.getState() == state) { results.add(host); } } return results; }
public static boolean isServing(Host host) throws IOException { return HostState.SERVING.equals(host.getState()); }
public static boolean isIdle(Host host) throws IOException { return HostState.IDLE.equals(host.getState()); }
public static long computeUpdateETA(Host host) { try { if (host.getState() != HostState.UPDATING) { return -1; } String etaString = host.getStatistic(UPDATE_ETA_STATISTIC_KEY); if (etaString != null) { return Long.parseLong(etaString); } else { return -1; } } catch (IOException e) { return -1; } }
protected void waitUntilHost(final HostState state, final Host host) throws InterruptedException { WaitUntil.orDie(() -> { try { return state.equals(host.getState()); } catch (IOException e) { throw new RuntimeException(e); } }); }
private static String formatHostListTooltip(String title, Set<Host> hosts) throws IOException { if (hosts.size() == 0) { return "-"; } else { TreeSet<Host> sortedHosts = new TreeSet<Host>(hosts); StringBuilder content = new StringBuilder(); for (Host host : sortedHosts) { content.append("<div class='" + hostStateToClass(host.getState()) + "'>"); content.append(host.getAddress().toString()); content.append("</div>"); } return htmlTooltip(Integer.toString(hosts.size()), title, content.toString()); } }
public HostConnection(Host host, int tryLockTimeoutMs, int establishConnectionTimeoutMs, int queryTimeoutMs, int bulkQueryTimeoutMs) throws IOException { this.host = host; this.tryLockTimeoutMs = tryLockTimeoutMs; this.establishConnectionTimeoutMs = establishConnectionTimeoutMs; this.queryTimeoutMs = queryTimeoutMs; this.bulkQueryTimeoutMs = bulkQueryTimeoutMs; host.setStateChangeListener(this); onWatchedNodeChange(host.getState()); }
private static boolean isServingAndAboutToServe(Host host) throws IOException { return host.getState().equals(HostState.SERVING) && host.getCurrentCommand() == null && host.getCommandQueue().size() == 0; }
public static boolean isServingOnlyUpToDateOrMoreRecent(RingGroup ringGroup, List<DomainAndVersion> domainVersions) throws IOException { for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDateOrMoreRecent(host, domainVersions)) { return false; } } } return true; }
public static boolean isServingOnlyUpToDate(RingGroup ringGroup) throws IOException { DomainGroup domainGroup = ringGroup.getDomainGroup(); for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDate(host, domainGroup)) { return false; } } } return true; }
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; }
public static ServingStatusAggregator computeServingStatusAggregator(Host host, DomainGroup domainGroup) throws IOException { ServingStatusAggregator result = new ServingStatusAggregator(); for (HostDomain hostDomain : host.getAssignedDomains()) { DomainAndVersion domainVersion = domainGroup.getDomainVersion(hostDomain.getDomain()); // Ignore domains that are not relevant if (domainVersion != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { // Check if partition is served and up to date boolean servedAndUpToDate = host.getState() == HostState.SERVING && partition.getCurrentDomainVersion() != null && partition.getCurrentDomainVersion().equals(domainVersion.getVersionNumber()); // Aggregate counts result.add(hostDomain.getDomain(), partition.getPartitionNumber(), servedAndUpToDate); } } } } return result; }
+ ", isUpToDate: " + isUpToDate + ", isFullyServing: " + isFullyServing + ", state: " + host.getState() );