Operations: Server: How to reoder database members?
ReorderDatabaseMembersOperation allows you to change the order of nodes in the Database Group Topology.
Syntax
public ReorderDatabaseMembersOperation(string database, List<string> order)
Parameters | ||
---|---|---|
database | string | Name of a database to operate on |
order | List<string> | List of node tags of all existing nodes in the database group, listed in the exact order that you wish to have. Throws ArgumentException is the reordered list doesn't correspond to the existing nodes of the database group |
Example I
// Assume that the current order of database group nodes is : ["A", "B", "C"]
// Change the order of database group nodes to : ["C", "A", "B"]
store.Maintenance.Server.Send(new ReorderDatabaseMembersOperation("Northwind",
new List<string>
{
"C", "A", "B"
}));
Example II
// Get the current DatabaseTopology from database record
var topology = store.Maintenance.Server.Send(new GetDatabaseRecordOperation("Northwind")).Topology;
// Reverse the order of database group nodes
topology.Members.Reverse();
store.Maintenance.Server.Send(new ReorderDatabaseMembersOperation("Northwind", topology.Members));