Package com.mysql.cj.conf.url
Class ReplicationConnectionUrl
java.lang.Object
com.mysql.cj.conf.ConnectionUrl
com.mysql.cj.conf.url.ReplicationConnectionUrl
- All Implemented Interfaces:
DatabaseUrlContainer
public class ReplicationConnectionUrl 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 ReplicationConnectionUrl(ConnectionUrlParser connStrParser, java.util.Properties info)Constructs an instance ofReplicationConnectionUrl, performing all the required initializations.ReplicationConnectionUrl(java.util.List<HostInfo> sources, java.util.List<HostInfo> replicas, java.util.Map<java.lang.String,java.lang.String> properties)Constructs an instance of aReplicationConnectionUrlbased on a list of source hosts, a list of replica hosts and a global set of properties instead of connection string parsing. -
Method Summary
Modifier and Type Method Description java.util.List<HostInfo>getHostsList(HostsListView view)Returns a list of the hosts in this connection URL, filtered for the given view.HostInfogetReplicaHostOrSpawnIsolated(java.lang.String hostPortPair)Returns an existing replica host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.java.util.List<HostInfo>getReplicaHostsListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs in the corresponding hosts list.java.util.List<java.lang.String>getReplicasListAsHostPortPairs()Returns a list of this connection URL replica hosts in the form of host:port pairs.HostInfogetSourceHostOrSpawnIsolated(java.lang.String hostPortPair)Returns an existing source host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.java.util.List<HostInfo>getSourceHostsListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs in the corresponding hosts list.java.util.List<java.lang.String>getSourcesListAsHostPortPairs()Returns a list of this connection URL source hosts in the form of host:port pairs.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, getHostsListFromDnsSrv, getMainHost, getOriginalProperties, getPropertiesFromConfigFiles, getType, hostsCount, injectPerTypeProperties, preprocessPerTypeHostProperties, replaceLegacyPropertyValues, setupPropertiesTransformer, toString
-
Constructor Details
-
ReplicationConnectionUrl
Constructs an instance ofReplicationConnectionUrl, performing all the required initializations.- Parameters:
connStrParser- aConnectionUrlParserinstance containing the parsed version of the original connection stringinfo- the connection arguments map
-
ReplicationConnectionUrl
public ReplicationConnectionUrl(java.util.List<HostInfo> sources, java.util.List<HostInfo> replicas, java.util.Map<java.lang.String,java.lang.String> properties)Constructs an instance of aReplicationConnectionUrlbased on a list of source hosts, a list of replica hosts and a global set of properties instead of connection string parsing.ConnectionUrlinstances created by this process are not cached.- Parameters:
sources- the source hosts list to use in this connection stringreplicas- the replica hosts list to use in this connection stringproperties- the properties common to all hosts
-
-
Method Details
-
getHostsList
Returns a list of the hosts in this connection URL, filtered for the given view.- Overrides:
getHostsListin classConnectionUrl- Parameters:
view- the type of the view to use in the returned list of hosts.- Returns:
- the hosts list from this connection URL, filtered for the given view.
-
getSourceHostOrSpawnIsolated
Returns an existing source host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.- Parameters:
hostPortPair- the host:port part to search for- Returns:
- the existing host info or a new independent one
-
getSourcesListAsHostPortPairs
public java.util.List<java.lang.String> getSourcesListAsHostPortPairs()Returns a list of this connection URL source hosts in the form of host:port pairs.- Returns:
- a list of this connection URL source hosts in the form of host:port pairs
-
getSourceHostsListFromHostPortPairs
public java.util.List<HostInfo> getSourceHostsListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs in the corresponding hosts list. 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
-
getReplicaHostOrSpawnIsolated
Returns an existing replica host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.- Parameters:
hostPortPair- the host:port part to search for- Returns:
- the existing host info or a new independent one
-
getReplicasListAsHostPortPairs
public java.util.List<java.lang.String> getReplicasListAsHostPortPairs()Returns a list of this connection URL replica hosts in the form of host:port pairs.- Returns:
- a list of this connection URL replica hosts in the form of host:port pairs
-
getReplicaHostsListFromHostPortPairs
public java.util.List<HostInfo> getReplicaHostsListFromHostPortPairs(java.util.Collection<java.lang.String> hostPortPairs)Returns the list ofHostInfoinstances that matches the given collection of host:port pairs in the corresponding hosts list. 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
-