Class UpstreamServer
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LoopbackUpstreamServer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe amount of seconds to wait for a retry when an attempt to re-resolve an address, after its TTL expired, fails.static final InetAddressContains the IPv4 localhost address 127.0.0.1.static final InetAddressContains the IPv6 localhost address ::1.static final Collection<String> An immutable collection representing support for all protocols.static final Collection<String> An immutable collection containing the single default supported procotol,HTTP/1.1, used if no protocols are passed in the constructor. -
Constructor Summary
ConstructorsConstructorDescriptionCreates anUpstreamServerinstance with no parameters set, and protocols set toPROTOCOLS_ALL.UpstreamServer(InetAddress address, int plainPort, int securePort) Creates anUpstreamServerinstance.UpstreamServer(InetAddress address, int addressTTL, int plainPort, int securePort, Collection<String> protocols) Creates anUpstreamServerinstance.UpstreamServer(InetAddress address, int addressTTL, int plainPort, int securePort, Collection<String> protocols, String clientImplOverride) Creates anUpstreamServerinstance.UpstreamServer(InetAddress address, int plainPort, int securePort, Collection<String> protocols) Creates anUpstreamServerinstance.UpstreamServer(InetAddress address, int addressTTL, InetAddress localAddress, int plainPort, int securePort, Collection<String> protocols, String clientImplOverride) Creates anUpstreamServerinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the address of thisUpstreamServer.intReturns the number of seconds to cache a resolvedInetAddress.Returns an override for the client manager namespace to use to connect to this server.Returns the local address of thisUpstreamServer.intReturns the port on which thisUpstreamServerlistens for plaintext connections.intReturns the port on which thisUpstreamServerlistens for encrypted connections.Returns the unmodifiable list of protocol names thisUpstreamServersupports, in the order of preference (from high to low).inthashCode()booleanisProtocolSupported(String proto) Returnstrueif thisUpstreamServerwas configured to support the given protocol name.toString()
-
Field Details
-
PROTOCOLS_DEFAULT
An immutable collection containing the single default supported procotol,HTTP/1.1, used if no protocols are passed in the constructor. -
PROTOCOLS_ALL
An immutable collection representing support for all protocols. -
LOCALHOST_IPV4
Contains the IPv4 localhost address 127.0.0.1.- Since:
- 3.11.1
-
LOCALHOST_IPV6
Contains the IPv6 localhost address ::1.- Since:
- 3.11.1
-
addressNegativeTTL
public static final int addressNegativeTTLThe amount of seconds to wait for a retry when an attempt to re-resolve an address, after its TTL expired, fails. If-1(the default), the same as the (positive) TTL configured for anUpstreamServer.- Since:
- 3.10.3
-
-
Constructor Details
-
UpstreamServer
public UpstreamServer()Creates anUpstreamServerinstance with no parameters set, and protocols set toPROTOCOLS_ALL.This may be used by plugins to create "virtual" upstream servers, where the plugin returns this instance of an
UpstreamServerinselectUpstreamServerand then responds to requests with that upstream server. When anUpstreamServerwith address set tonullis selected for a request, all request events are run normally as if the request is being proxied, but no upstream connection actually exists. Any handler must respond in theonHTTPRequestEndedevent or before, otherwise an error is returned.- Since:
- 3.7.2
-
UpstreamServer
Creates anUpstreamServerinstance.- Parameters:
address- The address of the serverplainPort- The port on which the server listens for plaintext connections.-1means there is no such portsecurePort- The port on which the server listens for encrypted connections.-1means there is no such port
-
UpstreamServer
public UpstreamServer(InetAddress address, int plainPort, int securePort, Collection<String> protocols) Creates anUpstreamServerinstance.- Parameters:
address- The address of the serverplainPort- The port on which the server listens for plaintext connections.-1means there is no such portsecurePort- The port on which the server listens for encrypted connections.-1means there is no such portprotocols- The list of protocol names the server supports- Since:
- 3.3.1
-
UpstreamServer
public UpstreamServer(InetAddress address, int addressTTL, int plainPort, int securePort, Collection<String> protocols) Creates anUpstreamServerinstance.- Parameters:
address- The address of the serveraddressTTL- The time in seconds to cache a resolved address. SeegetAddressTTL()plainPort- The port on which the server listens for plaintext connections.-1means there is no such portsecurePort- The port on which the server listens for encrypted connections.-1means there is no such portprotocols- The list of protocol names the server supports. Ifnull, the default set is used- Since:
- 3.4.1
-
UpstreamServer
public UpstreamServer(InetAddress address, int addressTTL, int plainPort, int securePort, Collection<String> protocols, String clientImplOverride) Creates anUpstreamServerinstance.- Parameters:
address- The address of the serveraddressTTL- The time in seconds to cache a resolved address. SeegetAddressTTL()plainPort- The port on which the server listens for plaintext connections.-1means there is no such portsecurePort- The port on which the server listens for encrypted connections.-1means there is no such portprotocols- The list of protocol names the server supports. Ifnull, the default set is usedclientImplOverride- If notnull, overrides the client manager namespace to use to connect to this server- Since:
- 3.10.2
-
UpstreamServer
public UpstreamServer(InetAddress address, int addressTTL, InetAddress localAddress, int plainPort, int securePort, Collection<String> protocols, String clientImplOverride) Creates anUpstreamServerinstance.- Parameters:
address- The address of the serveraddressTTL- The time in seconds to cache a resolved address. SeegetAddressTTL()localAddress- The local address to use to connect to the serverplainPort- The port on which the server listens for plaintext connections.-1means there is no such portsecurePort- The port on which the server listens for encrypted connections.-1means there is no such portprotocols- The list of protocol names the server supports. Ifnull, the default set is usedclientImplOverride- If notnull, overrides the client manager namespace to use to connect to this server- Throws:
IllegalArgumentException- IfaddressandlocalAddressare both given but they do not have the same type- Since:
- 3.10.4
-
-
Method Details
-
getAddress
Returns the address of thisUpstreamServer. May benull.If
addressTTLwas set in the constructor, this method may re-resolve the configuredaddressif necessary.- Returns:
- The address of this
UpstreamServer
-
getLocalAddress
Returns the local address of thisUpstreamServer. May benull.- Returns:
- The local address to use to connect to this
UpstreamServer - Since:
- 3.10.4
-
getAddressTTL
public int getAddressTTL()Returns the number of seconds to cache a resolvedInetAddress. After this time expires, the address is re-resolved usingInetAddress.getByName(java.lang.String).-1means there is no timeout. Note that theInetAddressimplementation may also cache name resolutions internally (seeInetAddress).This only applies to the remote address.
- Returns:
- The address TTL in seconds
-
getPlainPort
public int getPlainPort()Returns the port on which thisUpstreamServerlistens for plaintext connections.-1means there is no such port.- Returns:
- The plaintext port
-
getSecurePort
public int getSecurePort()Returns the port on which thisUpstreamServerlistens for encrypted connections.-1means there is no such port.- Returns:
- The encrypted port
-
isProtocolSupported
Returnstrueif thisUpstreamServerwas configured to support the given protocol name.- Parameters:
proto- The name of the protocol- Returns:
trueif the given protocol is supported- Since:
- 3.3.1
-
getSupportedProcotols
Returns the unmodifiable list of protocol names thisUpstreamServersupports, in the order of preference (from high to low).This list may be identity equal to
PROTOCOLS_ALL(containing anullelement), indicating thisUpstreamServerwas configured to support all protocols.- Returns:
- The list of procotols
- Since:
- 3.9.1
-
getClientImplOverride
Returns an override for the client manager namespace to use to connect to this server. Ifnull, the default implementation should be used.- Returns:
- ID of the client manager
- Since:
- 3.10.2
-
hashCode
public int hashCode() -
equals
-
toString
-