-
public class HostsObject to encapsulate primary host name and shuffled fallback host names. Methods on this class are safe to be called from any thread.
-
-
Field Summary
Fields Modifier and Type Field Description private final StringprimaryHost
-
Constructor Summary
Constructors Constructor Description Hosts(String primaryHost, String defaultHost, ClientOptions options)Create Hosts object
-
Method Summary
Modifier and Type Method Description StringgetPrimaryHost()Get primary host name synchronized voidsetPreferredHost(String prefHost, boolean temporary)set preferred hostname, which might not be the primary synchronized StringgetPreferredHost()Get preferred host name (taking into account any affinity to a fallback: see RSC15f) synchronized StringgetFallback(String lastHost)Get next fallback host if any synchronized intfallbackHostsRemaining(String candidateHost)-
-
Constructor Detail
-
Hosts
Hosts(String primaryHost, String defaultHost, ClientOptions options)
Create Hosts object- Parameters:
primaryHost- the primary hostname, null if not configureddefaultHost- the default hostname that the primary hostname mustmatch for fallback to occuroptions- ClientOptions to get environment and fallbackHosts fromThe fallback and environment processing here is used when the Hostsobject is used by a ConnectionManager (for a realtime connection) or byan HttpCore for a rest connection.
-
-
Method Detail
-
getPrimaryHost
String getPrimaryHost()
Get primary host name
-
setPreferredHost
synchronized void setPreferredHost(String prefHost, boolean temporary)
set preferred hostname, which might not be the primary
-
getPreferredHost
synchronized String getPreferredHost()
Get preferred host name (taking into account any affinity to a fallback: see RSC15f)
-
getFallback
synchronized String getFallback(String lastHost)
Get next fallback host if any
-
fallbackHostsRemaining
synchronized int fallbackHostsRemaining(String candidateHost)
-
-
-
-