public final class RouteSelector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RouteSelector.Selection
A set of selected Routes.
|
Modifier and Type | Field and Description |
---|---|
private Address |
address |
private Call |
call |
private EventListener |
eventListener |
private java.util.List<java.net.InetSocketAddress> |
inetSocketAddresses |
private int |
nextProxyIndex |
private java.util.List<Route> |
postponedRoutes |
private java.util.List<java.net.Proxy> |
proxies |
private RouteDatabase |
routeDatabase |
Constructor and Description |
---|
RouteSelector(Address address,
RouteDatabase routeDatabase,
Call call,
EventListener eventListener) |
Modifier and Type | Method and Description |
---|---|
void |
connectFailed(Route failedRoute,
java.io.IOException failure)
Clients should invoke this method when they encounter a connectivity failure on a connection
returned by this route selector.
|
(package private) static java.lang.String |
getHostString(java.net.InetSocketAddress socketAddress)
Obtain a "host" from an
InetSocketAddress . |
boolean |
hasNext()
Returns true if there's another set of routes to attempt.
|
private boolean |
hasNextProxy()
Returns true if there's another proxy to try.
|
RouteSelector.Selection |
next() |
private java.net.Proxy |
nextProxy()
Returns the next proxy to try.
|
private void |
resetNextInetSocketAddress(java.net.Proxy proxy)
Prepares the socket addresses to attempt for the current proxy or host.
|
private void |
resetNextProxy(HttpUrl url,
java.net.Proxy proxy)
Prepares the proxy servers to try.
|
private final Address address
private final RouteDatabase routeDatabase
private final Call call
private final EventListener eventListener
private java.util.List<java.net.Proxy> proxies
private int nextProxyIndex
private java.util.List<java.net.InetSocketAddress> inetSocketAddresses
private final java.util.List<Route> postponedRoutes
public RouteSelector(Address address, RouteDatabase routeDatabase, Call call, EventListener eventListener)
public boolean hasNext()
public RouteSelector.Selection next() throws java.io.IOException
java.io.IOException
public void connectFailed(Route failedRoute, java.io.IOException failure)
private void resetNextProxy(HttpUrl url, java.net.Proxy proxy)
private boolean hasNextProxy()
private java.net.Proxy nextProxy() throws java.io.IOException
java.io.IOException
private void resetNextInetSocketAddress(java.net.Proxy proxy) throws java.io.IOException
java.io.IOException
static java.lang.String getHostString(java.net.InetSocketAddress socketAddress)
InetSocketAddress
. This returns a string containing either an
actual host name or a numeric IP address.