Class ReplicationServerGroup
Base class used to implement load balancing features.
Namespace: MySql.Data.MySqlClient.Replication
Assembly: MySql.Data.dll
Version: 9.2.0
Syntax
public abstract class ReplicationServerGroup
Constructors
ReplicationServerGroup(String, Int32)
Declaration
public ReplicationServerGroup(string name, int retryTime)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The group name. |
System. |
retryTime | The number of seconds to perform a retry. |
Fields
servers
List of servers available for replication.
Declaration
protected List<ReplicationServer> servers
Field Value
Type | Description |
---|---|
System. |
Properties
Name
Gets the group name.
Declaration
public string Name { get; protected set; }
Property Value
Type | Description |
---|---|
System. |
RetryTime
Gets the retry time between connections to failed servers.
Declaration
public int RetryTime { get; protected set; }
Property Value
Type | Description |
---|---|
System. |
Servers
Gets the server list in the group.
Declaration
protected IList<ReplicationServer> Servers { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
AddServer(String, Boolean, String)
Adds a server into the group.
Declaration
protected ReplicationServer AddServer(string name, bool isSource, string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The server name. |
System. |
isSource | A flag indicating if the server to add is source or replica. |
System. |
connectionString | The connection string used by this server. |
Returns
Type | Description |
---|---|
Replication |
A Replication |
GetServer(Boolean)
Must be implemented. Defines the next server for a custom load balancing implementation.
Declaration
protected abstract ReplicationServer GetServer(bool isSource)
Parameters
Type | Name | Description |
---|---|---|
System. |
isSource | Defines if the server to return is a source or any. |
Returns
Type | Description |
---|---|
Replication |
The next server based on the load balancing implementation. Null if no available server is found. |
GetServer(Boolean, MySqlConnectionStringBuilder)
Defines the next server for a custom load balancing implementation.
Declaration
protected virtual ReplicationServer GetServer(bool isSource, MySqlConnectionStringBuilder settings)
Parameters
Type | Name | Description |
---|---|---|
System. |
isSource | Defines if the server to return is a source or any. |
My |
settings | Currently not being used. |
Returns
Type | Description |
---|---|
Replication |
The next server based on the load balancing implementation. Null if no available server is found. |
GetServer(String)
Gets a server by name.
Declaration
protected ReplicationServer GetServer(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The server name. |
Returns
Type | Description |
---|---|
Replication |
The replication server. |
HandleFailover(ReplicationServer)
Handles a failed connection to a server.
Declaration
protected virtual void HandleFailover(ReplicationServer server)
Parameters
Type | Name | Description |
---|---|---|
Replication |
server | The failed server. |
Remarks
This method can be overrided to implement a custom failover handling.
HandleFailover(ReplicationServer, Exception)
Handles a failed connection to a server.
Declaration
protected virtual void HandleFailover(ReplicationServer server, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Replication |
server | The failed server. |
System. |
exception | The exception that caused the failover. |
RemoveServer(String)
Removes a server from the group.
Declaration
protected void RemoveServer(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The server name. |