static HostResolver create(HeliosClient client) throws InterruptedException, ExecutionException { final ResolverConfig currentConfig = ResolverConfig.getCurrentConfig(); final Name[] path; if (currentConfig != null) { final Name[] possiblePath = currentConfig.searchPath(); if (possiblePath != null) { path = possiblePath; } else { path = EMPTY_PATH; } } else { path = EMPTY_PATH; } return new HostResolver(Sets.newHashSet(client.listHosts().get()), path); }
final HostResolver resolver = HostResolver.create(client); final List<String> resolved = resolver.getSortedMatches(host); if (!resolved.isEmpty()) { out.println("We didn't find your hostname, but we did find some possible matches for you:"
String resolveName(final String host) { // passed FQDN, all set if (allHosts.contains(host)) { return host; } final List<String> matches = findPrefixMatches(host); if (matches.isEmpty()) { return host; // no pfx matches, let it fail upstream } if (matches.size() == 1) { return matches.iterator().next(); } final List<ScoredHost> scored = scoreMatches(matches); final List<ScoredHost> sorted = sortScoredHosts(scored); final List<String> minScoreHosts = findMatchesWithLowestScore(sorted); if (minScoreHosts.size() > 1) { // ambiguous, just return it and let it fail upstream return host; } return minScoreHosts.get(0); }
public List<String> getSortedMatches(final String hostName) { final List<String> matches = findPrefixMatches(hostName); final List<ScoredHost> scored = scoreMatches(matches); final List<ScoredHost> sorted = sortScoredHosts(scored); final ImmutableList.Builder<String> builder = ImmutableList.builder(); for (final ScoredHost host : sorted) { builder.add(host.host); } return builder.build(); }
final HostResolver resolver = HostResolver.create(client); final String host = resolver.resolveName(candidateHost);
public List<String> getSortedMatches(final String hostName) { final List<String> matches = findPrefixMatches(hostName); final List<ScoredHost> scored = scoreMatches(matches); final List<ScoredHost> sorted = sortScoredHosts(scored); final ImmutableList.Builder<String> builder = ImmutableList.builder(); for (final ScoredHost host : sorted) { builder.add(host.host); } return builder.build(); }
final HostResolver resolver = HostResolver.create(client); final String host = resolver.resolveName(candidateHost); resolvedHosts.add(host); if (!json) {
String resolveName(final String host) { // passed FQDN, all set if (allHosts.contains(host)) { return host; } final List<String> matches = findPrefixMatches(host); if (matches.isEmpty()) { return host; // no pfx matches, let it fail upstream } if (matches.size() == 1) { return matches.iterator().next(); } final List<ScoredHost> scored = scoreMatches(matches); final List<ScoredHost> sorted = sortScoredHosts(scored); final List<String> minScoreHosts = findMatchesWithLowestScore(sorted); if (minScoreHosts.size() > 1) { // ambiguous, just return it and let it fail upstream return host; } return minScoreHosts.get(0); }
final HostResolver resolver = HostResolver.create(client); final String host = resolver.resolveName(candidateHost);
final HostResolver resolver = HostResolver.create(client); final List<String> resolved = resolver.getSortedMatches(host); if (!resolved.isEmpty()) { out.println("We didn't find your hostname, but we did find some possible matches for you:"
static HostResolver create(HeliosClient client) throws InterruptedException, ExecutionException { final ResolverConfig currentConfig = ResolverConfig.getCurrentConfig(); final Name[] path; if (currentConfig != null) { final Name[] possiblePath = currentConfig.searchPath(); if (possiblePath != null) { path = possiblePath; } else { path = EMPTY_PATH; } } else { path = EMPTY_PATH; } return new HostResolver(Sets.newHashSet(client.listHosts().get()), path); }
final HostResolver resolver = HostResolver.create(client); final String host = resolver.resolveName(candidateHost); resolvedHosts.add(host); if (!json) {