Package io.ably.lib.transport
Class Hosts
java.lang.Object
io.ably.lib.transport.Hosts
Object to encapsulate primary host name and shuffled fallback host names.
Methods on this class are safe to be called from any thread.
-
Constructor Summary
ConstructorDescriptionHosts
(String primaryHost, String defaultHost, ClientOptions options) Create Hosts object -
Method Summary
Modifier and TypeMethodDescriptionint
fallbackHostsRemaining
(String candidateHost) getFallback
(String lastHost) Get next fallback host if anyGet preferred host name (taking into account any affinity to a fallback: see RSC15f)Get primary host namevoid
setPreferredHost
(String prefHost, boolean temporary) set preferred hostname, which might not be the primary
-
Constructor Details
-
Hosts
Create Hosts object- Parameters:
-
primaryHost
- the primary hostname, null if not configured -
defaultHost
- the default hostname that the primary hostname must match for fallback to occur -
options
- ClientOptions to get environment and fallbackHosts from The fallback and environment processing here is used when the Hosts object is used by a ConnectionManager (for a realtime connection) or by an HttpCore for a rest connection. The case where the Hosts object is used by an HttpCore that is being used by a ConnectionManager goes through this code, but the results are ignored because ConnectionManager then calls setHost() and fallback is not used. - Throws:
AblyException
-
-
Method Details
-
setPreferredHost
set preferred hostname, which might not be the primary -
getPrimaryHost
Get primary host name -
getPreferredHost
Get preferred host name (taking into account any affinity to a fallback: see RSC15f) -
getFallback
Get next fallback host if any- Parameters:
-
lastHost
- - Returns:
- Successor host that can be used as a fallback. null, if there is no successor fallback available.
-
fallbackHostsRemaining
-