Add database settings tab (#2201)

This commit is contained in:
Barbara Valdez
2023-08-31 14:25:57 -07:00
committed by GitHub
parent 5f17826359
commit 3ba514c652
4 changed files with 251 additions and 2 deletions

View File

@@ -64,7 +64,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll, AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
NumaNodes = prototype.NumaNodes, NumaNodes = prototype.NumaNodes,
AuthenticationMode = prototype.AuthenticationMode, AuthenticationMode = prototype.AuthenticationMode,
LoginAuditing = prototype.LoginAuditing LoginAuditing = prototype.LoginAuditing,
CheckCompressBackup = prototype.CheckCompressBackup,
CheckBackupChecksum = prototype.CheckBackupChecksum,
DataLocation = prototype.DataLocation,
LogLocation = prototype.LogLocation,
BackupLocation = prototype.BackupLocation
}; };
} }
var context = new ServerViewContext(requestParams); var context = new ServerViewContext(requestParams);

View File

@@ -38,6 +38,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
public List<NumaNode> NumaNodes { get; set; } public List<NumaNode> NumaNodes { get; set; }
public ServerLoginMode AuthenticationMode { get; set; } public ServerLoginMode AuthenticationMode { get; set; }
public AuditLevel LoginAuditing { get; set; } public AuditLevel LoginAuditing { get; set; }
public bool CheckCompressBackup { get; set; }
public bool CheckBackupChecksum { get; set; }
public string DataLocation { get; set; }
public string LogLocation { get; set; }
public string BackupLocation { get; set; }
} }
public class NumericServerProperty public class NumericServerProperty

View File

@@ -356,7 +356,66 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{ {
this.currentState.LoginAuditing = value; this.currentState.LoginAuditing = value;
} }
}
public bool CheckBackupChecksum
{
get
{
return this.currentState.CheckBackupChecksum;
}
set
{
this.currentState.CheckBackupChecksum = value;
}
}
public bool CheckCompressBackup
{
get
{
return this.currentState.CheckCompressBackup;
}
set
{
this.currentState.CheckCompressBackup = value;
}
}
public string DataLocation
{
get
{
return this.currentState.DataLocation;
}
set
{
this.currentState.DataLocation = value;
}
}
public string LogLocation
{
get
{
return this.currentState.LogLocation;
}
set
{
this.currentState.LogLocation = value;
}
}
public string BackupLocation
{
get
{
return this.currentState.BackupLocation;
}
set
{
this.currentState.BackupLocation = value;
}
} }
#endregion #endregion
@@ -431,6 +490,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{ {
server.Alter(); server.Alter();
} }
if (UpdateDBSettingsValues(this.dataContainer.Server))
{
server.Settings.Alter();
}
if (UpdateBackupConfig(this.dataContainer.Server))
{
server.Configuration.Alter();
}
} }
} }
@@ -472,6 +541,48 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
return alterServer; return alterServer;
} }
public bool UpdateBackupConfig(Server server)
{
bool alterServer = false;
if (this.currentState.CheckBackupChecksum != this.originalState.CheckBackupChecksum)
{
server.Configuration.DefaultBackupChecksum.ConfigValue = this.currentState.CheckBackupChecksum ? 1 : 0;
alterServer = true;
}
if (this.currentState.CheckCompressBackup != this.originalState.CheckCompressBackup)
{
server.Configuration.DefaultBackupCompression.ConfigValue = this.currentState.CheckCompressBackup ? 1 : 0;
alterServer = true;
}
return alterServer;
}
public bool UpdateDBSettingsValues(Server server)
{
bool alterServer = false;
if (this.currentState.DataLocation != this.originalState.DataLocation)
{
server.Settings.DefaultFile = this.currentState.DataLocation;
alterServer = true;
}
if (this.currentState.LogLocation != this.originalState.LogLocation)
{
server.Settings.DefaultLog = this.currentState.LogLocation;
alterServer = true;
}
if (this.currentState.BackupLocation != this.originalState.BackupLocation)
{
server.Settings.BackupDirectory = this.currentState.BackupLocation;
alterServer = true;
}
return alterServer;
}
private bool CheckCPUAffinityBeforeIO(SMO.Server smoServer) private bool CheckCPUAffinityBeforeIO(SMO.Server smoServer)
{ {
for (int i = 0; i < this.NumaNodes.Count; i++) for (int i = 0; i < this.NumaNodes.Count; i++)
@@ -650,6 +761,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.NumaNodes = serverInfo.NumaNodes.ToList(); this.NumaNodes = serverInfo.NumaNodes.ToList();
this.AuthenticationMode = serverInfo.AuthenticationMode; this.AuthenticationMode = serverInfo.AuthenticationMode;
this.LoginAuditing = serverInfo.LoginAuditing; this.LoginAuditing = serverInfo.LoginAuditing;
this.CheckBackupChecksum = serverInfo.CheckBackupChecksum;
this.CheckCompressBackup = serverInfo.CheckCompressBackup;
this.DataLocation = serverInfo.DataLocation;
this.LogLocation = serverInfo.LogLocation;
this.BackupLocation = serverInfo.BackupLocation;
} }
/// <summary> /// <summary>
@@ -687,6 +803,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
private List<NumaNode> numaNodes = new List<NumaNode>(); private List<NumaNode> numaNodes = new List<NumaNode>();
private ServerLoginMode authenticationMode = ServerLoginMode.Integrated; private ServerLoginMode authenticationMode = ServerLoginMode.Integrated;
private AuditLevel loginAuditing = AuditLevel.None; private AuditLevel loginAuditing = AuditLevel.None;
private bool checkCompressBackup = false;
private bool checkBackupChecksum = false;
private string dataLocation = String.Empty;
private string logLocation = String.Empty;
private string backupLocation = String.Empty;
private bool initialized = false; private bool initialized = false;
private Server server; private Server server;
@@ -1307,7 +1428,114 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.affinityManagerProcessorMask = value; this.affinityManagerProcessorMask = value;
} }
} }
public bool CheckBackupChecksum
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.checkBackupChecksum;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("CheckBackupChecksum"));
}
this.checkBackupChecksum = value;
}
}
public bool CheckCompressBackup
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.checkCompressBackup;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("CheckCompressBackup"));
}
this.checkCompressBackup = value;
}
}
public string DataLocation
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.dataLocation;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("DataLocation"));
}
this.dataLocation = value;
}
}
public string LogLocation
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.logLocation;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("LogLocation"));
}
this.logLocation = value;
}
}
public string BackupLocation
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.backupLocation;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("BackupLocation"));
}
this.backupLocation = value;
}
}
#endregion #endregion
/// <summary> /// <summary>
@@ -1337,7 +1565,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.minMemory = new NumericServerProperty(); this.minMemory = new NumericServerProperty();
this.maxMemory = new NumericServerProperty(); this.maxMemory = new NumericServerProperty();
this.NumaNodes = new List<NumaNode>(); this.NumaNodes = new List<NumaNode>();
LoadData(); LoadData();
} }
@@ -1374,6 +1601,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
result.numaNodes = this.numaNodes; result.numaNodes = this.numaNodes;
result.authenticationMode = this.authenticationMode; result.authenticationMode = this.authenticationMode;
result.loginAuditing = this.loginAuditing; result.loginAuditing = this.loginAuditing;
result.checkBackupChecksum = this.checkBackupChecksum;
result.checkCompressBackup = this.checkCompressBackup;
result.dataLocation = this.dataLocation;
result.logLocation = this.logLocation;
result.backupLocation = this.backupLocation;
result.server = this.server; result.server = this.server;
return result; return result;
} }
@@ -1415,6 +1647,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
GetAutoProcessorsAffinity(); GetAutoProcessorsAffinity();
this.authenticationMode = server.LoginMode; this.authenticationMode = server.LoginMode;
this.loginAuditing = server.AuditLevel; this.loginAuditing = server.AuditLevel;
this.checkBackupChecksum = this.configService.GetServerSmoConfig(server, this.configService.BackupChecksumDefaultPropertyNumber).ConfigValue == 1;
this.checkCompressBackup = this.configService.GetServerSmoConfig(server, this.configService.BackupCompressionDefaultPropertyNumber).ConfigValue == 1;
this.dataLocation = server.Settings.DefaultFile;
this.logLocation = server.Settings.DefaultLog;
this.backupLocation = server.Settings.BackupDirectory;
} }
private void LoadMemoryProperties() private void LoadMemoryProperties()

View File

@@ -24,6 +24,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
private static readonly Lazy<ServerConfigService> instance = new Lazy<ServerConfigService>(() => new ServerConfigService()); private static readonly Lazy<ServerConfigService> instance = new Lazy<ServerConfigService>(() => new ServerConfigService());
public readonly int MaxServerMemoryPropertyNumber = 1544; public readonly int MaxServerMemoryPropertyNumber = 1544;
public readonly int MinServerMemoryPropertyNumber = 1543; public readonly int MinServerMemoryPropertyNumber = 1543;
public readonly int BackupCompressionDefaultPropertyNumber = 1579;
public readonly int BackupChecksumDefaultPropertyNumber = 1584;
/// <summary> /// <summary>
/// Gets the singleton instance object /// Gets the singleton instance object