Package com.mysql.cj.conf.url
Class LoadBalanceConnectionUrl
java.lang.Object
com.mysql.cj.conf.ConnectionUrl
com.mysql.cj.conf.url.LoadBalanceConnectionUrl
- All Implemented Interfaces:
DatabaseUrlContainer
public class LoadBalanceConnectionUrl extends ConnectionUrl
-
Nested Class Summary
Nested classes/interfaces inherited from class com.mysql.cj.conf.ConnectionUrl
ConnectionUrl.HostsCardinality, ConnectionUrl.Type -
Field Summary
Fields inherited from class com.mysql.cj.conf.ConnectionUrl
DEFAULT_HOST, DEFAULT_PORT, hosts, originalConnStr, originalDatabase, properties, type -
Constructor Summary
Constructors Constructor Description LoadBalanceConnectionUrl(ConnectionUrlParser connStrParser, java.util.Properties info)Constructs an instance ofLoadBalanceConnectionUrl, performing all the required initializations and validations.LoadBalanceConnectionUrl(java.util.List<HostInfo> hosts, java.util.Map<java.lang.String,java.lang.String> properties)Constructs an instance of aLoadBalanceConnectionUrlbased on a list of hosts and a global set of properties instead of connection string parsing. -
Method Summary
Modifier and Type Method Description java.util.List<java.lang.String>getHostInfoListAsHostPortPairs()Returns a list of this connection URL hosts in the form of host:port pairs.java.util.List<HostInfo>getHostInfoListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs.protected voidinjectPerTypeProperties(java.util.Map<java.lang.String,java.lang.String> props)Injects additional properties into the connection arguments while it's being constructed.Methods inherited from class com.mysql.cj.conf.ConnectionUrl
acceptsUrl, buildHostInfo, collectHostsInfo, collectProperties, expandPropertiesFromConfigFiles, fixHostInfo, fixProtocolDependencies, getConnectionArgumentsAsProperties, getConnectionUrlInstance, getDatabase, getDatabaseUrl, getDefaultHost, getDefaultPassword, getDefaultPort, getDefaultUser, getHostOrSpawnIsolated, getHostOrSpawnIsolated, getHostsList, getHostsList, getHostsListFromDnsSrv, getMainHost, getOriginalProperties, getPropertiesFromConfigFiles, getType, hostsCount, preprocessPerTypeHostProperties, replaceLegacyPropertyValues, setupPropertiesTransformer, toString
-
Constructor Details
-
LoadBalanceConnectionUrl
Constructs an instance ofLoadBalanceConnectionUrl, performing all the required initializations and validations. A load-balanced connection cannot deal with multiple hosts with same host:port.- Parameters:
connStrParser- aConnectionUrlParserinstance containing the parsed version of the original connection stringinfo- the connection arguments map
-
LoadBalanceConnectionUrl
public LoadBalanceConnectionUrl(java.util.List<HostInfo> hosts, java.util.Map<java.lang.String,java.lang.String> properties)Constructs an instance of aLoadBalanceConnectionUrlbased on a list of hosts and a global set of properties instead of connection string parsing.ConnectionUrlinstances created by this process are not cached.- Parameters:
hosts- the hosts list to use in this connection URLproperties- the properties common to all hosts
-
-
Method Details
-
injectPerTypeProperties
protected void injectPerTypeProperties(java.util.Map<java.lang.String,java.lang.String> props)Injects additional properties into the connection arguments while it's being constructed.- Overrides:
injectPerTypePropertiesin classConnectionUrl- Parameters:
props- the properties already containing all known connection arguments
-
getHostInfoListAsHostPortPairs
public java.util.List<java.lang.String> getHostInfoListAsHostPortPairs()Returns a list of this connection URL hosts in the form of host:port pairs.- Returns:
- a list of this connection URL hosts in the form of host:port pairs
-
getHostInfoListFromHostPortPairs
public java.util.List<HostInfo> getHostInfoListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs. Isolated host info elements are spawned for the missing elements.- Parameters:
hostPortPairs- a list of host:port pairs- Returns:
- a list of
HostInfoinstances corresponding to the given host:port pairs
-