mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Server properties fixes (#2225)
* get the backup compression value directly from server * get max memory values directly from server and fix conditions * format document
This commit is contained in:
@@ -33,9 +33,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
|
|
||||||
private ServerPrototypeData currentState;
|
private ServerPrototypeData currentState;
|
||||||
private ServerPrototypeData originalState;
|
private ServerPrototypeData originalState;
|
||||||
|
|
||||||
private ConfigProperty serverMinMemoryProperty;
|
|
||||||
private ConfigProperty serverMaxMemoryProperty;
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Trace support
|
#region Trace support
|
||||||
@@ -615,8 +612,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
this.configService = new ServerConfigService();
|
this.configService = new ServerConfigService();
|
||||||
this.currentState = new ServerPrototypeData(context, context.Server, this.configService);
|
this.currentState = new ServerPrototypeData(context, context.Server, this.configService);
|
||||||
this.originalState = (ServerPrototypeData)this.currentState.Clone();
|
this.originalState = (ServerPrototypeData)this.currentState.Clone();
|
||||||
this.serverMaxMemoryProperty = this.configService.GetServerSmoConfig(context.Server, this.configService.MaxServerMemoryPropertyNumber);
|
|
||||||
this.serverMinMemoryProperty = this.configService.GetServerSmoConfig(context.Server, this.configService.MinServerMemoryPropertyNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -632,43 +627,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
if (this.dataContainer.Server != null)
|
if (this.dataContainer.Server != null)
|
||||||
{
|
{
|
||||||
Server server = this.dataContainer.Server;
|
Server server = this.dataContainer.Server;
|
||||||
bool alterServerConfig = false;
|
|
||||||
bool sendCPUAffinityBeforeIO = false;
|
|
||||||
bool sendIOAffinityBeforeCPU = false;
|
|
||||||
bool sentCpuAffinity = false;
|
|
||||||
|
|
||||||
sendCPUAffinityBeforeIO = this.CheckCPUAffinityBeforeIO(server);
|
|
||||||
sendIOAffinityBeforeCPU = this.CheckIOAffinityBeforeCPU(server);
|
|
||||||
alterServerConfig = this.CheckIOAffinityTsqlGenerated(server);
|
|
||||||
if (!sendIOAffinityBeforeCPU)
|
|
||||||
{
|
|
||||||
SendDataForKJ(server);
|
|
||||||
sentCpuAffinity = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alterServerConfig)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
server.Configuration.Alter((sendCPUAffinityBeforeIO && sendIOAffinityBeforeCPU));
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
server.Configuration.Refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sentCpuAffinity)
|
|
||||||
{
|
|
||||||
SendDataForKJ(server);
|
|
||||||
}
|
|
||||||
this.currentState.AffinityManagerProcessorMask.Clear();
|
|
||||||
this.currentState.AffinityManagerIOMask.Clear();
|
|
||||||
|
|
||||||
if (UpdateMemoryValues(this.dataContainer.Server))
|
if (UpdateMemoryValues(this.dataContainer.Server))
|
||||||
{
|
{
|
||||||
server.Configuration.Alter(true);
|
server.Configuration.Alter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProcessorsValues(this.dataContainer.Server);
|
||||||
|
|
||||||
if (UpdateSecurityValues(this.dataContainer.Server))
|
if (UpdateSecurityValues(this.dataContainer.Server))
|
||||||
{
|
{
|
||||||
server.Alter();
|
server.Alter();
|
||||||
@@ -702,19 +668,55 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
if (this.currentState.MinMemory.Value != this.originalState.MinMemory.Value)
|
if (this.currentState.MinMemory.Value != this.originalState.MinMemory.Value)
|
||||||
{
|
{
|
||||||
changesMade = true;
|
changesMade = true;
|
||||||
ConfigProperty serverConfig = this.configService.GetServerSmoConfig(server, this.configService.MinServerMemoryPropertyNumber);
|
server.Configuration.MinServerMemory.ConfigValue = this.currentState.MinMemory.Value;
|
||||||
serverConfig.ConfigValue = this.currentState.MinMemory.Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.MaxMemory.Value != this.originalState.MaxMemory.Value)
|
if (this.currentState.MaxMemory.Value != this.originalState.MaxMemory.Value)
|
||||||
{
|
{
|
||||||
changesMade = true;
|
changesMade = true;
|
||||||
ConfigProperty serverConfig = this.configService.GetServerSmoConfig(server, this.configService.MaxServerMemoryPropertyNumber);
|
server.Configuration.MaxServerMemory.ConfigValue = this.currentState.MaxMemory.Value;
|
||||||
serverConfig.ConfigValue = this.currentState.MaxMemory.Value;
|
|
||||||
}
|
}
|
||||||
return changesMade;
|
return changesMade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateProcessorsValues(Server server)
|
||||||
|
{
|
||||||
|
bool alterServerConfig = false;
|
||||||
|
bool sendCPUAffinityBeforeIO = false;
|
||||||
|
bool sendIOAffinityBeforeCPU = false;
|
||||||
|
bool sentCpuAffinity = false;
|
||||||
|
if (this.currentState.AutoProcessorAffinityIOMaskForAll != this.originalState.AutoProcessorAffinityIOMaskForAll ||
|
||||||
|
this.currentState.AutoProcessorAffinityMaskForAll != this.originalState.AutoProcessorAffinityMaskForAll)
|
||||||
|
{
|
||||||
|
sendCPUAffinityBeforeIO = this.CheckCPUAffinityBeforeIO(server);
|
||||||
|
sendIOAffinityBeforeCPU = this.CheckIOAffinityBeforeCPU(server);
|
||||||
|
alterServerConfig = this.CheckIOAffinityTsqlGenerated(server);
|
||||||
|
if (!sendIOAffinityBeforeCPU)
|
||||||
|
{
|
||||||
|
SendDataForKJ(server);
|
||||||
|
sentCpuAffinity = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alterServerConfig)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server.Configuration.Alter((sendCPUAffinityBeforeIO && sendIOAffinityBeforeCPU));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
server.Configuration.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sentCpuAffinity)
|
||||||
|
{
|
||||||
|
SendDataForKJ(server);
|
||||||
|
}
|
||||||
|
this.currentState.AffinityManagerProcessorMask.Clear();
|
||||||
|
this.currentState.AffinityManagerIOMask.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool UpdateSecurityValues(Server server)
|
public bool UpdateSecurityValues(Server server)
|
||||||
{
|
{
|
||||||
bool alterServer = false;
|
bool alterServer = false;
|
||||||
@@ -796,13 +798,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.BlockedProcThreshold != this.originalState.BlockedProcThreshold)
|
if (this.currentState.BlockedProcThreshold.Value != this.originalState.BlockedProcThreshold.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.BlockedProcessThreshold.ConfigValue = this.currentState.BlockedProcThreshold.Value;
|
server.Configuration.BlockedProcessThreshold.ConfigValue = this.currentState.BlockedProcThreshold.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.CursorThreshold != this.originalState.CursorThreshold)
|
if (this.currentState.CursorThreshold.Value != this.originalState.CursorThreshold.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.CursorThreshold.ConfigValue = this.currentState.CursorThreshold.Value;
|
server.Configuration.CursorThreshold.ConfigValue = this.currentState.CursorThreshold.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
@@ -844,25 +846,25 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.CostThresholdParallelism != this.originalState.CostThresholdParallelism)
|
if (this.currentState.CostThresholdParallelism.Value != this.originalState.CostThresholdParallelism.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.CostThresholdForParallelism.ConfigValue = this.currentState.CostThresholdParallelism.Value;
|
server.Configuration.CostThresholdForParallelism.ConfigValue = this.currentState.CostThresholdParallelism.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.Locks != this.originalState.Locks)
|
if (this.currentState.Locks.Value != this.originalState.Locks.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.Locks.ConfigValue = this.currentState.Locks.Value;
|
server.Configuration.Locks.ConfigValue = this.currentState.Locks.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.MaxDegreeParallelism != this.originalState.MaxDegreeParallelism)
|
if (this.currentState.MaxDegreeParallelism.Value != this.originalState.MaxDegreeParallelism.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.MaxDegreeOfParallelism.ConfigValue = this.currentState.MaxDegreeParallelism.Value;
|
server.Configuration.MaxDegreeOfParallelism.ConfigValue = this.currentState.MaxDegreeParallelism.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentState.QueryWait != this.originalState.QueryWait)
|
if (this.currentState.QueryWait.Value != this.originalState.QueryWait.Value)
|
||||||
{
|
{
|
||||||
server.Configuration.QueryWait.ConfigValue = this.currentState.QueryWait.Value;
|
server.Configuration.QueryWait.ConfigValue = this.currentState.QueryWait.Value;
|
||||||
alterServer = true;
|
alterServer = true;
|
||||||
@@ -1134,9 +1136,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
private bool isYukonOrLater = false;
|
private bool isYukonOrLater = false;
|
||||||
private bool isSqlServer64Bit;
|
private bool isSqlServer64Bit;
|
||||||
private bool isIOAffinitySupported = false;
|
private bool isIOAffinitySupported = false;
|
||||||
|
|
||||||
ConfigProperty serverMaxMemoryProperty;
|
|
||||||
ConfigProperty serverMinMemoryProperty;
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
@@ -2187,8 +2186,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
this.isSqlServer64Bit = (this.server.Edition.Contains("(64 - bit)"));
|
this.isSqlServer64Bit = (this.server.Edition.Contains("(64 - bit)"));
|
||||||
this.affinityManagerIOMask = new AffinityManager();
|
this.affinityManagerIOMask = new AffinityManager();
|
||||||
this.affinityManagerProcessorMask = new AffinityManager();
|
this.affinityManagerProcessorMask = new AffinityManager();
|
||||||
this.serverMaxMemoryProperty = this.configService.GetServerSmoConfig(server, this.configService.MaxServerMemoryPropertyNumber);
|
|
||||||
this.serverMinMemoryProperty = this.configService.GetServerSmoConfig(server, this.configService.MinServerMemoryPropertyNumber);
|
|
||||||
this.minMemory = new NumericServerProperty();
|
this.minMemory = new NumericServerProperty();
|
||||||
this.maxMemory = new NumericServerProperty();
|
this.maxMemory = new NumericServerProperty();
|
||||||
this.blockedProcThreshold = new NumericServerProperty();
|
this.blockedProcThreshold = new NumericServerProperty();
|
||||||
@@ -2292,13 +2289,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
}
|
}
|
||||||
private void LoadMemoryProperties()
|
private void LoadMemoryProperties()
|
||||||
{
|
{
|
||||||
this.maxMemory.Value = serverMaxMemoryProperty.ConfigValue;
|
this.maxMemory.Value = server.Configuration.MaxServerMemory.ConfigValue;
|
||||||
this.maxMemory.MaximumValue = serverMaxMemoryProperty.Maximum;
|
this.maxMemory.MaximumValue = server.Configuration.MaxServerMemory.Maximum;
|
||||||
this.maxMemory.MinimumValue = serverMaxMemoryProperty.Minimum;
|
this.maxMemory.MinimumValue = server.Configuration.MaxServerMemory.Minimum;
|
||||||
|
|
||||||
this.minMemory.Value = serverMinMemoryProperty.ConfigValue;
|
this.minMemory.Value = server.Configuration.MinServerMemory.ConfigValue;
|
||||||
this.minMemory.MaximumValue = serverMinMemoryProperty.Maximum;
|
this.minMemory.MaximumValue = server.Configuration.MinServerMemory.Maximum;
|
||||||
this.minMemory.MinimumValue = serverMinMemoryProperty.Minimum;
|
this.minMemory.MinimumValue = server.Configuration.MinServerMemory.Minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadProcessorsProperties()
|
private void LoadProcessorsProperties()
|
||||||
@@ -2366,7 +2363,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.fullTextUpgradeOption = server.FullTextService.CatalogUpgradeOption.ToString();
|
this.fullTextUpgradeOption = server.FullTextService.CatalogUpgradeOption.ToString();
|
||||||
} catch
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
this.fullTextUpgradeOption = String.Empty;
|
this.fullTextUpgradeOption = String.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user