Package io.ably.lib.transport
Class Hosts
- java.lang.Object
-
- io.ably.lib.transport.Hosts
-
public class Hosts extends java.lang.ObjectObject to encapsulate primary host name and shuffled fallback host names. Methods on this class are safe to be called from any thread.
-
-
Constructor Summary
Constructors Constructor Description Hosts(java.lang.String primaryHost, java.lang.String defaultHost, ClientOptions options)Create Hosts object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfallbackHostsRemaining(java.lang.String candidateHost)java.lang.StringgetFallback(java.lang.String lastHost)Get next fallback host if anyjava.lang.StringgetPreferredHost()Get preferred host name (taking into account any affinity to a fallback: see RSC15f)java.lang.StringgetPrimaryHost()Get primary host namevoidsetPreferredHost(java.lang.String prefHost, boolean temporary)set preferred hostname, which might not be the primary
-
-
-
Constructor Detail
-
Hosts
public Hosts(java.lang.String primaryHost, java.lang.String defaultHost, ClientOptions options) throws AblyExceptionCreate Hosts object- Parameters:
primaryHost- the primary hostname, null if not configureddefaultHost- the default hostname that the primary hostname must match for fallback to occuroptions- 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 Detail
-
setPreferredHost
public void setPreferredHost(java.lang.String prefHost, boolean temporary)set preferred hostname, which might not be the primary
-
getPrimaryHost
public java.lang.String getPrimaryHost()
Get primary host name
-
getPreferredHost
public java.lang.String getPreferredHost()
Get preferred host name (taking into account any affinity to a fallback: see RSC15f)
-
getFallback
public java.lang.String getFallback(java.lang.String lastHost)
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
public int fallbackHostsRemaining(java.lang.String candidateHost)
-
-