public class FailoverRestClient extends RestClientBase
RestClient
implementation that supports talking to a cluster of
SMILA services and can do failover to another node if the current node is not reachable anymore.
Create the client with a list of "host:port" strings. The client will talk to the first of those nodes as long as it
is reachable. Then it will failover to the second node. It will not switch back to the first node if it becomes
available again. It will also not distribute request to available nodes to provide load-balancing.
Restriction: if the request contains an InputStream to provide request content, then the request cannot be retried on
another node if the InputStream has been already read during the last failed attempt, though there may still be other
nodes available for retry. So if possible don't use stream requests if you require that all nodes are tried.DEFAULT_HOSTANDPORT
Constructor and Description |
---|
FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts)
Talk to the given SMILA servers.
|
FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts,
ClientConnectionManager connectionManager)
Talk to given SMILA server, using a given connection manager.
|
FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts,
int maxTotalConnections,
int maxConnectionsPerHost)
Talk to the given SMILA server, using a non-default connection configuration.
|
FailoverRestClient(java.lang.String... hostsAndPorts)
Talk to the given SMILA servers.
|
asMap, buildPathAndQuery, createConnectErrorMessage, createUrl, delete, delete, doRequest, doRequestWithHeaderReponse, get, get, getBulk, getHostAndPort, invoke, invoke, invoke, invoke, invokeAsMap, post, post, post, post, post, postWithResponseHeader, put, put, setAuthParameters, setClientParameter, setRequestExecutor, setRequestFactory, setResultHandler, shutdown
public FailoverRestClient(java.lang.String... hostsAndPorts)
hostsAndPorts
- list of hosts and ports of SMILA services, in format "host:port". Don't include a trailing slash ("/").public FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts)
hostsAndPorts
- list of hosts and ports of SMILA services, in format "host:port". Don't include a trailing slash ("/").public FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts, int maxTotalConnections, int maxConnectionsPerHost)
hostsAndPorts
- list of hosts and ports of SMILA services, in format "host:port". Don't include a trailing slash ("/").maxTotalConnections
- maximum number of total HTTP connectionsmaxConnectionsPerHost
- maximum number of connections per hostpublic FailoverRestClient(java.util.List<java.lang.String> hostsAndPorts, ClientConnectionManager connectionManager)
hostsAndPorts
- list of hosts and ports of SMILA services, in format "host:port". Don't include a trailing slash ("/").connectionManager
- an initialized Apache HttpClient connection manager.