@Test public void throwsIfNodeUnrecognized() { assertThatThrownBy(() -> RedirectRetryTargeter.create(URL_3, ImmutableList.of(URL_1))) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Local server not found in the list of cluster URLs."); }
public static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls) { Preconditions.checkArgument(clusterUrls.contains(localServer), "Local server not found in the list of cluster URLs.", SafeArg.of("localServer", localServer), SafeArg.of("clusterUrls", clusterUrls)); if (clusterUrls.size() == 1) { return new RedirectRetryTargeter(ImmutableList.of()); } List<URL> otherServers = clusterUrls.stream() .filter(url -> !Objects.equals(localServer, url)) .collect(Collectors.toList()); return new RedirectRetryTargeter(otherServers); }
RedirectRetryTargeter { public static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls) { Preconditions.checkArgument(clusterUrls.contains(localServer), "Local server not found in the list of cluster URLs.", SafeArg.of("localServer", localServer), SafeArg.of("clusterUrls", clusterUrls)); if (clusterUrls.size() == 1) { return new RedirectRetryTargeter(ImmutableList.of()); } List<URL> otherServers = clusterUrls.stream() .filter(url -> !Objects.equals(localServer, url)) .collect(Collectors.toList()); return new RedirectRetryTargeter(otherServers); } }
RedirectRetryTargeter { public static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls) { Preconditions.checkArgument(clusterUrls.contains(localServer), "Local server not found in the list of cluster URLs.", SafeArg.of("localServer", localServer), SafeArg.of("clusterUrls", clusterUrls)); if (clusterUrls.size() == 1) { return new RedirectRetryTargeter(ImmutableList.of()); } List<URL> otherServers = clusterUrls.stream() .filter(url -> !Objects.equals(localServer, url)) .collect(Collectors.toList()); return new RedirectRetryTargeter(otherServers); } private  RedirectRetryTargeter(List<URL> otherServers); }
RedirectRetryTargeter { public static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls) { Preconditions.checkArgument(clusterUrls.contains(localServer), "Local server not found in the list of cluster URLs.", SafeArg.of("localServer", localServer), SafeArg.of("clusterUrls", clusterUrls)); if (clusterUrls.size() == 1) { return new RedirectRetryTargeter(ImmutableList.of()); } List<URL> otherServers = clusterUrls.stream() .filter(url -> !Objects.equals(localServer, url)) .collect(Collectors.toList()); return new RedirectRetryTargeter(otherServers); } private  RedirectRetryTargeter(List<URL> otherServers); static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls); Optional<URL> redirectRequest(Optional<HostAndPort> leaderHint); }
RedirectRetryTargeter { public static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls) { Preconditions.checkArgument(clusterUrls.contains(localServer), "Local server not found in the list of cluster URLs.", SafeArg.of("localServer", localServer), SafeArg.of("clusterUrls", clusterUrls)); if (clusterUrls.size() == 1) { return new RedirectRetryTargeter(ImmutableList.of()); } List<URL> otherServers = clusterUrls.stream() .filter(url -> !Objects.equals(localServer, url)) .collect(Collectors.toList()); return new RedirectRetryTargeter(otherServers); } private  RedirectRetryTargeter(List<URL> otherServers); static RedirectRetryTargeter create(URL localServer, List<URL> clusterUrls); Optional<URL> redirectRequest(Optional<HostAndPort> leaderHint);  }