change "Getdatabase" code for Exchange 2010SP2 so that it accepts a database

group name of DAG\MailboxDatabase to turn off the load-balancing and instead
use a fixed database.
The default behaviour of load-balancing mailboxes between all Provsioning-Enabled
mailbox databases of the DAG-Group is still present and functioning.
This commit is contained in:
VoosW 2012-10-29 19:35:27 +01:00
parent 98bab06e96
commit 7c85eb643f

View file

@ -607,15 +607,42 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogStart("GetDatabase");
ExchangeLog.LogInfo("DAG: " + dagName);
//Get Dag Servers
// this part of code handles mailboxnames like in the old 2007 provider
// check if DAG is in reality DAG\mailboxdatabase
string dagNameDAG = string.Empty;
string dagNameMBX = string.Empty;
bool isFixedDatabase = false;
if (dagName.Contains("\\"))
{
// split the two parts and extract DAG-Name and mailboxdatabase-name
string[] parts = dagName.Split(new char[] { '\\' }, 2, StringSplitOptions.None);
dagNameDAG = parts[0];
dagNameMBX = parts[1];
// check that we realy have a database name
if (!String.IsNullOrEmpty(dagNameMBX))
{
isFixedDatabase = true;
}
}
else
{
// there is no mailboxdatabase-name use the loadbalancing-code
dagNameDAG = dagName;
isFixedDatabase = false;
}
//Get Dag Servers - with the name of the database availability group
Collection<PSObject> dags = null;
Command cmd = new Command("Get-DatabaseAvailabilityGroup");
cmd.Parameters.Add("Identity", dagName);
cmd.Parameters.Add("Identity", dagNameDAG);
dags = ExecuteShellCommand(runSpace, cmd);
if (htBbalancer == null)
htBbalancer = new Hashtable();
// use fully qualified dagName for loadbalancer. Thus if there are two services and one of them
// contains only the DAG, the "fixed" database could also be used in loadbalancing. If you do not want this,
// set either IsExcludedFromProvisioning or IsSuspendedFromProvisioning - it is not evaluated for fixed databases
if (htBbalancer[dagName] == null)
htBbalancer.Add(dagName, 0);
@ -628,6 +655,8 @@ namespace WebsitePanel.Providers.HostedSolution
{
System.Collections.Generic.List<string> lstDatabase = new System.Collections.Generic.List<string>();
if (!isFixedDatabase) // "old" loadbalancing code
{
foreach (object objServer in servers)
{
Collection<PSObject> databases = null;
@ -660,6 +689,25 @@ namespace WebsitePanel.Providers.HostedSolution
}
}
}
}
else // new fixed database code
{
Collection<PSObject> databases = null;
cmd = new Command("Get-MailboxDatabase");
cmd.Parameters.Add("Identity", dagNameMBX);
databases = ExecuteShellCommand(runSpace, cmd);
// do not check "IsExcludedFromProvisioning" or "IsSuspended", just check if it is a member of the DAG
foreach (PSObject objDatabase in databases)
{
string dagSetting = ObjToString(GetPSObjectProperty(objDatabase, "MasterServerOrAvailabilityGroup"));
if (dagNameDAG.Equals(dagSetting, StringComparison.OrdinalIgnoreCase))
{
lstDatabase.Add(dagNameMBX);
ExchangeLog.LogInfo("AddFixedDatabase: " + dagNameMBX);
}
}
}
int balancer = (int)htBbalancer[dagName];
balancer++;