mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Removing migration code and packages from sts (#1864)
* Removing migration code and packages from sts * Removing condition
This commit is contained in:
@@ -27,9 +27,6 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageExtensibility;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.Metadata;
|
||||
#if INCLUDE_MIGRATION
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration;
|
||||
#endif
|
||||
using Microsoft.SqlTools.ServiceLayer.ModelManagement;
|
||||
using Microsoft.SqlTools.ServiceLayer.NotebookConvert;
|
||||
using Microsoft.SqlTools.ServiceLayer.ObjectManagement;
|
||||
@@ -162,11 +159,6 @@ namespace Microsoft.SqlTools.ServiceLayer
|
||||
NotebookConvertService.Instance.InitializeService(serviceHost);
|
||||
serviceProvider.RegisterSingleService(NotebookConvertService.Instance);
|
||||
|
||||
#if INCLUDE_MIGRATION
|
||||
MigrationService.Instance.InitializeService(serviceHost);
|
||||
serviceProvider.RegisterSingleService(MigrationService.Instance);
|
||||
#endif
|
||||
|
||||
TableDesignerService.Instance.InitializeService(serviceHost);
|
||||
serviceProvider.RegisterSingleService(TableDesignerService.Instance);
|
||||
|
||||
|
||||
@@ -21,30 +21,18 @@
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition="'$(BUILD_DOTNET_TOOL)' == 'true'">
|
||||
<PropertyGroup>
|
||||
<PackageId>Microsoft.SqlServer.SqlToolsServiceLayer.Tool</PackageId>
|
||||
<PackageVersion>1.3.0</PackageVersion>
|
||||
<PackageDescription>.NET client SQL Tools Service application, usable as a dotnet tool. This package is intended to be used by internal applications only and should not be referenced directly.</PackageDescription>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>$(AssemblyName)</ToolCommandName>
|
||||
<PackageOutputPath>./nupkg</PackageOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**/*.cs" Exclude="**/obj/**/*.cs;Migration/**/*.cs" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<DefineConstants>$(DefineConstants);INCLUDE_MIGRATION</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SqlServer.Migration.Assessment" />
|
||||
<Compile Include="**/*.cs" Exclude="**/obj/**/*.cs" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<PropertyGroup Condition="'$(BUILD_DOTNET_TOOL)' == 'true'">
|
||||
<PackageId>Microsoft.SqlServer.SqlToolsServiceLayer.Tool</PackageId>
|
||||
<PackageVersion>1.3.0</PackageVersion>
|
||||
<PackageDescription>.NET client SQL Tools Service application, usable as a dotnet tool. This package is intended to be used by internal applications only and should not be referenced directly.</PackageDescription>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>$(AssemblyName)</ToolCommandName>
|
||||
<PackageOutputPath>./nupkg</PackageOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**/*.cs" Exclude="**/obj/**/*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Storage.Blobs" />
|
||||
@@ -56,9 +44,6 @@
|
||||
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Assessment" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Migration.Logins" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Migration.Tde" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Management.SmoMetadataProvider" />
|
||||
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Management.SqlParser" />
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the certificate migration progress event
|
||||
/// </summary>
|
||||
public class CertificateMigrationProgressParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Database name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Message related to the success status. true should describe a positive outcome. false should have an error.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Result of migration
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a certificate migration request. This should be register at the client.
|
||||
/// </summary>
|
||||
public class CertificateMigrationProgressEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Name and parameters for the event definition.
|
||||
/// </summary>
|
||||
public static readonly
|
||||
EventType<CertificateMigrationProgressParams> Type =
|
||||
EventType<CertificateMigrationProgressParams>.Create("migration/tdemigrationprogress");
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the certificate migration operation
|
||||
/// </summary>
|
||||
public class CertificateMigrationParams
|
||||
{
|
||||
/// <summary>
|
||||
/// List of databses to migrate the certificates
|
||||
/// </summary>
|
||||
public List<string> EncryptedDatabases { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Source connection string to the server
|
||||
/// </summary>
|
||||
public string SourceSqlConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Target subscription id
|
||||
/// </summary>
|
||||
public string TargetSubscriptionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Target resource group name
|
||||
/// </summary>
|
||||
public string TargetResourceGroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Target manages instance name
|
||||
/// </summary>
|
||||
public string TargetManagedInstanceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Place where certificates will be exported
|
||||
/// </summary>
|
||||
public string NetworkSharePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Domain for the user credentials able to read from the shared path
|
||||
/// </summary>
|
||||
public string NetworkShareDomain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Username for the credentials able to read from the shared path
|
||||
/// </summary>
|
||||
public string NetworkShareUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Password for the credentials able to read from the shared path
|
||||
/// </summary>
|
||||
public string NetworkSharePassword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Access token for the ARM client
|
||||
/// </summary>
|
||||
public string AccessToken { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Result for the certificate migration operation
|
||||
/// </summary>
|
||||
public class CertificateMigrationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// List of the status of each certificate migration result attempted.
|
||||
/// </summary>
|
||||
public List<CertificateMigrationEntryResult> MigrationStatuses { get; set; } = new List<CertificateMigrationEntryResult>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Result for an individual database certificate migration
|
||||
/// </summary>
|
||||
public class CertificateMigrationEntryResult
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the database this result represent
|
||||
/// </summary>
|
||||
public string DbName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The result of the migration.
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description of the success status or the error message encountered when the migration was not successful
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Certificate migration request definition
|
||||
/// </summary>
|
||||
public class CertificateMigrationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Name, parameter and return type for the certicate migration operation
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<CertificateMigrationParams, CertificateMigrationResult> Type =
|
||||
RequestType<CertificateMigrationParams, CertificateMigrationResult>.Create("migration/tdemigration");
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models;
|
||||
using Microsoft.SqlServer.Migration.SkuRecommendation.Models.Sql;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class GetSkuRecommendationsParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Folder from which collected performance data will be read from
|
||||
/// </summary>
|
||||
public string DataFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Interval at which collected performance data was originally queried at, in seconds
|
||||
/// </summary>
|
||||
public int PerfQueryIntervalInSec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of target platforms to consider when generating recommendations
|
||||
/// </summary>
|
||||
public List<string> TargetPlatforms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the SQL instance to generate recommendations for
|
||||
/// </summary>
|
||||
public string TargetSqlInstance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Target percentile to use when performing perf data aggregation
|
||||
/// </summary>
|
||||
public int TargetPercentile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scaling ("comfort") factor when evalulating performance requirements
|
||||
/// </summary>
|
||||
public int ScalingFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Start time of collected data points to consider
|
||||
///
|
||||
/// TO-DO: do we really need this? it's pretty safe to assume that most users would want us to evaluate all the collected data and not just part of it
|
||||
/// </summary>
|
||||
public string StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// End time of collected data points to consider
|
||||
///
|
||||
/// TO-DO: do we really need this? it's pretty safe to assume that most users would want us to evaluate all the collected data and not just part of it
|
||||
/// </summary>
|
||||
public string EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to consider preview SKUs when generating SKU recommendations
|
||||
/// </summary>
|
||||
public bool IncludePreviewSkus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of databases to consider when generating recommendations
|
||||
/// </summary>
|
||||
public List<string> DatabaseAllowList { get; set; }
|
||||
}
|
||||
|
||||
public class GetSkuRecommendationsResult
|
||||
{
|
||||
/// <summary>
|
||||
/// List of SQL DB recommendation results, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> SqlDbRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL DB recommendations took to generate, in milliseconds. Equal to -1 if SQL DB recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long SqlDbRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of SQL MI recommendation results, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> SqlMiRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL MI recommendations took to generate, in milliseconds. Equal to -1 if SQL MI recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long SqlMiRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of SQL VM recommendation results, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> SqlVmRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL VM recommendations took to generate, in milliseconds. Equal to -1 if SQL VM recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long SqlVmRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of SQL DB recommendation results generated by the elastic model, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> ElasticSqlDbRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL DB recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL DB elastic recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long ElasticSqlDbRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of SQL MI recommendation results generated by the elastic model, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> ElasticSqlMiRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL MI recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL MI elastic recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long ElasticSqlMiRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of SQL VM recommendation results generated by the elastic model, if applicable
|
||||
/// </summary>
|
||||
public List<SkuRecommendationResult> ElasticSqlVmRecommendationResults { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long the SQL VM recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL VM elastic recommendations are not applicable.
|
||||
/// </summary>
|
||||
public long ElasticSqlVmRecommendationDurationInMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SQL instance requirements, representing an aggregated view of the performance requirements of the source instance
|
||||
/// </summary>
|
||||
public SqlInstanceRequirements InstanceRequirements { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File paths where the recommendation reports were saved
|
||||
/// </summary>
|
||||
public List<string> SkuRecommendationReportPaths { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File paths where the recommendation reports generated by the elastic model were saved
|
||||
/// </summary>
|
||||
public List<string> ElasticSkuRecommendationReportPaths { get; set; }
|
||||
}
|
||||
|
||||
// Helper class containing recommendation results, durations, and report paths, which is recommendation model-agnostic
|
||||
internal class RecommendationResultSet {
|
||||
internal List<SkuRecommendationResult> sqlDbResults;
|
||||
internal List<SkuRecommendationResult> sqlMiResults;
|
||||
internal List<SkuRecommendationResult> sqlVmResults;
|
||||
internal long sqlDbDurationInMs;
|
||||
internal long sqlMiDurationInMs;
|
||||
internal long sqlVmDurationInMs;
|
||||
internal string sqlDbReportPath;
|
||||
internal string sqlMiReportPath;
|
||||
internal string sqlVmReportPath;
|
||||
|
||||
// Create a new empty RecommendationResultSet
|
||||
internal RecommendationResultSet()
|
||||
{
|
||||
this.sqlDbResults = new List<SkuRecommendationResult>();
|
||||
this.sqlMiResults = new List<SkuRecommendationResult>();
|
||||
this.sqlVmResults = new List<SkuRecommendationResult>();
|
||||
this.sqlDbDurationInMs = -1;
|
||||
this.sqlMiDurationInMs = -1;
|
||||
this.sqlVmDurationInMs = -1;
|
||||
this.sqlDbReportPath = "";
|
||||
this.sqlMiReportPath = "";
|
||||
this.sqlVmReportPath = "";
|
||||
}
|
||||
}
|
||||
|
||||
public class GetSkuRecommendationsRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<GetSkuRecommendationsParams, GetSkuRecommendationsResult> Type =
|
||||
RequestType<GetSkuRecommendationsParams, GetSkuRecommendationsResult>.Create("migration/getskurecommendations");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item returned by SQL Assessment RPC methods
|
||||
/// </summary>
|
||||
public class ImpactedObjectInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ImpactDetail { get; set; }
|
||||
public string ObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item returned by SQL Assessment RPC methods
|
||||
/// </summary>
|
||||
public class MigrationAssessmentInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets assessment ruleset version.
|
||||
/// </summary>
|
||||
public string RulesetVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets assessment ruleset name
|
||||
/// </summary>
|
||||
public string RulesetName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets assessment ruleset name
|
||||
/// </summary>
|
||||
public string RuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the assessed object's name.
|
||||
/// </summary>
|
||||
public string TargetType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the database name.
|
||||
/// </summary>
|
||||
public string DatabaseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the server name.
|
||||
/// </summary>
|
||||
public string ServerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets check's ID.
|
||||
/// </summary>
|
||||
public string CheckId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets tags assigned to this item.
|
||||
/// </summary>
|
||||
public string[] Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a display name for this item.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a brief description of the item's purpose.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="string"/> containing
|
||||
/// an link to a page providing detailed explanation
|
||||
/// of the best practice.
|
||||
/// </summary>
|
||||
public string HelpLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="string"/> indicating
|
||||
/// severity level assigned to this items.
|
||||
/// Values are: "Information", "Warning", "Critical".
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public string AppliesToMigrationTargetPlatform { get; set; }
|
||||
|
||||
public string IssueCategory { get; set; }
|
||||
|
||||
public ImpactedObjectInfo[] ImpactedObjects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This flag is set if the assessment result is a blocker for migration to Target Platform.
|
||||
/// </summary>
|
||||
public bool DatabaseRestoreFails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.Models;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class MigrationAssessmentsParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Owner URI
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of databases to assess
|
||||
/// </summary>
|
||||
public string[] Databases { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folder path to XEvents files to be assessed, if applicable. Empty string to disable XEvents assessment.
|
||||
/// </summary>
|
||||
public string XEventsFilesFolderPath { get; set; }
|
||||
}
|
||||
|
||||
public class MigrationAssessmentResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Errors that happen while running the assessment
|
||||
/// </summary>
|
||||
public ErrorModel[] Errors { get; set; }
|
||||
/// <summary>
|
||||
/// Result of the assessment
|
||||
/// </summary>
|
||||
public ServerAssessmentProperties AssessmentResult { get; set; }
|
||||
/// <summary>
|
||||
/// Start time of the assessment
|
||||
/// </summary>
|
||||
public string StartTime { get; set; }
|
||||
/// <summary>
|
||||
/// End time of the assessment
|
||||
/// </summary>
|
||||
public string EndedTime { get; set; }
|
||||
/// <summary>
|
||||
/// Contains the raw assessment response
|
||||
/// </summary>
|
||||
public ISqlMigrationAssessmentModel RawAssessmentResult { get; set; }
|
||||
/// <summary>
|
||||
/// File path where the assessment report was saved
|
||||
/// </summary>
|
||||
public string AssessmentReportPath { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retreive metadata for the table described in the TableMetadataParams value
|
||||
/// </summary>
|
||||
public class MigrationAssessmentsRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<MigrationAssessmentsParams, MigrationAssessmentResult> Type =
|
||||
RequestType<MigrationAssessmentsParams, MigrationAssessmentResult>.Create("migration/getassessments");
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.TargetAssessment.Models;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class ServerAssessmentProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the server
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Cpu cores for the server host
|
||||
/// </summary>
|
||||
public long CpuCoreCount { get; set; }
|
||||
/// <summary>
|
||||
/// Server host physical memory size
|
||||
/// </summary>
|
||||
public double PhysicalServerMemory { get; set; }
|
||||
/// <summary>
|
||||
/// Host operating system of the SQL server
|
||||
/// </summary>
|
||||
public string ServerHostPlatform { get; set; }
|
||||
/// <summary>
|
||||
/// Version of the SQL server
|
||||
/// </summary>
|
||||
public string ServerVersion { get; set; }
|
||||
/// <summary>
|
||||
/// SQL server engine edition
|
||||
/// </summary>
|
||||
public string ServerEngineEdition { get; set; }
|
||||
/// <summary>
|
||||
/// SQL server edition
|
||||
/// </summary>
|
||||
public string ServerEdition { get; set; }
|
||||
/// <summary>
|
||||
/// We use this flag to indicate if the SQL server is part of the failover cluster
|
||||
/// </summary>
|
||||
public bool IsClustered { get; set; }
|
||||
/// <summary>
|
||||
/// Returns the total number of dbs assessed
|
||||
/// </summary>
|
||||
public long NumberOfUserDatabases { get; set; }
|
||||
/// <summary>
|
||||
/// Returns the assessment status
|
||||
/// </summary>
|
||||
public int SqlAssessmentStatus { get; set; }
|
||||
/// <summary>
|
||||
/// Count of Dbs assessed
|
||||
/// </summary>
|
||||
public long AssessedDatabaseCount{get; set;}
|
||||
/// <summary>
|
||||
/// Give assessed server stats for SQL MI compatibility
|
||||
/// </summary>
|
||||
public IServerTargetReadiness SQLManagedInstanceTargetReadiness { get; set; }
|
||||
/// <summary>
|
||||
/// Server assessment results
|
||||
/// </summary>
|
||||
public MigrationAssessmentInfo[] Items { get; set; }
|
||||
/// <summary>
|
||||
/// Server assessment errors
|
||||
/// </summary>
|
||||
public ErrorModel[] Errors { get; set; }
|
||||
/// <summary>
|
||||
/// List of databases that are assessed
|
||||
/// </summary>
|
||||
public DatabaseAssessmentProperties[] Databases { get; set; }
|
||||
}
|
||||
|
||||
public class DatabaseAssessmentProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the database
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Compatibility level of the database
|
||||
/// </summary>
|
||||
public string CompatibilityLevel { get; set; }
|
||||
/// <summary>
|
||||
/// Size of the database
|
||||
/// </summary>
|
||||
public double DatabaseSize { get; set; }
|
||||
/// <summary>
|
||||
/// Flag that indicates if the database is replicated
|
||||
/// </summary>
|
||||
public bool IsReplicationEnabled { get; set; }
|
||||
/// <summary>
|
||||
/// Time taken for assessing the database
|
||||
/// </summary>
|
||||
public double AssessmentTimeInMilliseconds { get; set; }
|
||||
/// <summary>
|
||||
/// Database Assessment Results
|
||||
/// </summary>
|
||||
public MigrationAssessmentInfo[] Items { get; set; }
|
||||
/// <summary>
|
||||
/// Database assessment errors
|
||||
/// </summary>
|
||||
public ErrorModel[] Errors {get; set;}
|
||||
/// <summary>
|
||||
/// Flags that indicate if the database is ready for migration
|
||||
/// </summary>
|
||||
public IDatabaseTargetReadiness SQLManagedInstanceTargetReadiness { get; set; }
|
||||
}
|
||||
|
||||
public class ErrorModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of the assessment error
|
||||
/// </summary>
|
||||
public string ErrorId { get; set; }
|
||||
/// <summary>
|
||||
/// Error message
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
/// <summary>
|
||||
/// Summary of the Error
|
||||
/// </summary>
|
||||
public string ErrorSummary { get; set; }
|
||||
/// <summary>
|
||||
/// Possible causes for the error
|
||||
/// </summary>
|
||||
public string PossibleCauses { get; set; }
|
||||
/// <summary>
|
||||
/// Possible mitigation for the error
|
||||
/// </summary>
|
||||
public string Guidance { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class StartPerfDataCollectionParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Uri identifier for the connection
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folder from which collected performance data will be written to
|
||||
/// </summary>
|
||||
public string DataFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Interval at which performance data will be collected, in seconds
|
||||
/// </summary>
|
||||
public int PerfQueryIntervalInSec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Interval at which static (common) data will be collected, in seconds
|
||||
/// </summary>
|
||||
public int StaticQueryIntervalInSec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of iterations of performance data collection to run before aggregating and saving to disk
|
||||
/// </summary>
|
||||
public int NumberOfIterations { get; set; }
|
||||
}
|
||||
|
||||
public class StopPerfDataCollectionParams
|
||||
{
|
||||
// TO-DO: currently stop data collection doesn't require any parameters
|
||||
}
|
||||
|
||||
public class RefreshPerfDataCollectionParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The last time data collection status was refreshed
|
||||
/// </summary>
|
||||
public DateTime LastRefreshedTime { get; set; }
|
||||
}
|
||||
|
||||
public class StartPerfDataCollectionResult
|
||||
{
|
||||
/// <summary>
|
||||
/// The time data collection started
|
||||
/// </summary>
|
||||
public DateTime DateTimeStarted { get; set; }
|
||||
}
|
||||
|
||||
public class StopPerfDataCollectionResult
|
||||
{
|
||||
/// <summary>
|
||||
/// The time data collection stopped
|
||||
/// </summary>
|
||||
public DateTime DateTimeStopped { get; set; }
|
||||
}
|
||||
|
||||
public class RefreshPerfDataCollectionResult
|
||||
{
|
||||
/// <summary>
|
||||
/// List of status messages captured during data collection
|
||||
/// </summary>
|
||||
public List<string> Messages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of error messages captured during data collection
|
||||
/// </summary>
|
||||
public List<string> Errors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last time data collecton status was refreshed
|
||||
/// </summary>
|
||||
public DateTime RefreshTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not data collection is currently running
|
||||
/// </summary>
|
||||
public bool IsCollecting { get; set; }
|
||||
}
|
||||
|
||||
public class StartPerfDataCollectionRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartPerfDataCollectionParams, StartPerfDataCollectionResult> Type =
|
||||
RequestType<StartPerfDataCollectionParams, StartPerfDataCollectionResult>.Create("migration/startperfdatacollection");
|
||||
}
|
||||
|
||||
public class StopPerfDataCollectionRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StopPerfDataCollectionParams, StopPerfDataCollectionResult> Type =
|
||||
RequestType<StopPerfDataCollectionParams, StopPerfDataCollectionResult>.Create("migration/stopperfdatacollection");
|
||||
}
|
||||
|
||||
public class RefreshPerfDataCollectionRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<RefreshPerfDataCollectionParams, RefreshPerfDataCollectionResult> Type =
|
||||
RequestType<RefreshPerfDataCollectionParams, RefreshPerfDataCollectionResult>.Create("migration/refreshperfdatacollection");
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlServer.DataCollection.Common.Contracts.OperationsInfrastructure;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the steps in login migration.
|
||||
/// </summary>
|
||||
public enum LoginMigrationStep
|
||||
{
|
||||
/// <summary>
|
||||
/// Run pre-migration validations
|
||||
/// </summary>
|
||||
StartValidations,
|
||||
|
||||
/// <summary>
|
||||
/// Step to hash passwords and migrate logins
|
||||
/// </summary>
|
||||
MigrateLogins,
|
||||
|
||||
/// <summary>
|
||||
/// Step to establish users and logins from source to target
|
||||
/// </summary>
|
||||
EstablishUserMapping,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Step to migrate server roles
|
||||
/// </summary>
|
||||
MigrateServerRoles,
|
||||
|
||||
/// <summary>
|
||||
/// Step to establish roles
|
||||
/// </summary>
|
||||
EstablishServerRoleMapping,
|
||||
|
||||
/// <summary>
|
||||
/// Step to map all the grant/deny permissions for logins
|
||||
/// </summary>
|
||||
SetLoginPermissions,
|
||||
|
||||
/// <summary>
|
||||
/// Step to map all server roles grant/deny permissions
|
||||
/// </summary>
|
||||
SetServerRolePermissions
|
||||
}
|
||||
|
||||
public class StartLoginMigrationParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Connection string to connect to source
|
||||
/// </summary>
|
||||
public string SourceConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Connection string to connect to target
|
||||
/// </summary>
|
||||
public string TargetConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of logins to migrate
|
||||
/// </summary>
|
||||
public List<string> LoginList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Azure active directory domain name (required for Windows Auth)
|
||||
/// </summary>
|
||||
public string AADDomainName{ get; set; }
|
||||
}
|
||||
|
||||
public class LoginMigrationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Start time of the assessment
|
||||
/// </summary>
|
||||
public IDictionary<string, IEnumerable<ReportableException>> ExceptionMap { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The login migration step that just completed
|
||||
/// </summary>
|
||||
public LoginMigrationStep CompletedStep { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How long this step took
|
||||
/// </summary>
|
||||
public string ElapsedTime{ get; set; }
|
||||
}
|
||||
|
||||
public class StartLoginMigrationRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult> Type =
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult>.Create("migration/startloginmigration");
|
||||
}
|
||||
|
||||
public class ValidateLoginMigrationRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult> Type =
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult>.Create("migration/validateloginmigration");
|
||||
}
|
||||
|
||||
public class MigrateLoginsRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult> Type =
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult>.Create("migration/migratelogins");
|
||||
}
|
||||
|
||||
public class EstablishUserMappingRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult> Type =
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult>.Create("migration/establishusermapping");
|
||||
}
|
||||
public class MigrateServerRolesAndSetPermissionsRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult> Type =
|
||||
RequestType<StartLoginMigrationParams, LoginMigrationResult>.Create("migration/migrateserverrolesandsetpermissions");
|
||||
}
|
||||
|
||||
public class LoginMigrationNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<LoginMigrationResult> Type =
|
||||
EventType<LoginMigrationResult>.Create("migration/loginmigrationnotification");
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class ValidateNetworkFileShareRequestParams
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class ValidateNetworkFileShareRequest
|
||||
{
|
||||
public static readonly RequestType<ValidateNetworkFileShareRequestParams, bool> Type = RequestType<ValidateNetworkFileShareRequestParams, bool>.Create("migration/validateNetworkFileShare");
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class ValidateWindowsAccountRequestParams
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class ValidateWindowsAccountRequest
|
||||
{
|
||||
public static readonly RequestType<ValidateWindowsAccountRequestParams, bool> Type = RequestType<ValidateWindowsAccountRequestParams, bool>.Create("migration/validateWindowsAccount");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure.Core;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Temp token creadentials to interact with ArmClient class.
|
||||
/// The token passed to this class should be a newly request token, because this class doesn't renew the token.
|
||||
/// Once MSAL is rolled out on ADS, we will implement a way to use the same ADS token cache configured by ADS.
|
||||
/// </summary>
|
||||
internal class StaticTokenCredential : TokenCredential
|
||||
{
|
||||
private readonly AccessToken _token;
|
||||
|
||||
/// <summary>
|
||||
/// Build credentials using a token that will not change.
|
||||
/// </summary>
|
||||
/// <param name="accessToken">Newly created token that should last for the duration of the whole operation.</param>
|
||||
public StaticTokenCredential(string accessToken) => _token = new AccessToken(
|
||||
accessToken: accessToken,
|
||||
expiresOn: DateTimeOffset.Now.AddHours(1)); //Default to an hour, the current duration of a newly create token.
|
||||
|
||||
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
|
||||
=> _token;
|
||||
|
||||
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
|
||||
=> new ValueTask<AccessToken>(_token);
|
||||
}
|
||||
}
|
||||
@@ -1,384 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlServer.DataCollection.Common.Contracts.Advisor;
|
||||
using Microsoft.SqlServer.DataCollection.Common.Contracts.ErrorHandling;
|
||||
using Microsoft.SqlServer.DataCollection.Common.Contracts.SqlQueries;
|
||||
using Microsoft.SqlServer.DataCollection.Common.ErrorHandling;
|
||||
using Microsoft.SqlServer.Migration.SkuRecommendation;
|
||||
using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller to manage the collection, aggregation, and persistence of SQL performance and static data for SKU recommendation.
|
||||
/// </summary>
|
||||
public class SqlDataQueryController : IDisposable
|
||||
{
|
||||
// Timers to control performance and static data collection intervals
|
||||
private IList<System.Timers.Timer> timers = new List<System.Timers.Timer>() { };
|
||||
private int perfQueryIntervalInSec;
|
||||
private int numberOfIterations;
|
||||
|
||||
// Output folder to store data in
|
||||
private string outputFolder;
|
||||
|
||||
// Name of the server handled by this controller
|
||||
private string serverName;
|
||||
|
||||
// Data collector and cache
|
||||
private DataPointsCollector dataCollector = null;
|
||||
private SqlPerfDataPointsCache perfDataCache = null;
|
||||
|
||||
// Whether or not this controller has been disposed
|
||||
private bool disposedValue = false;
|
||||
|
||||
private ISqlAssessmentLogger _logger;
|
||||
|
||||
// since this "console app" doesn't have any console to write to, store any messages so that they can be periodically fetched
|
||||
private List<KeyValuePair<string, DateTime>> messages;
|
||||
private List<KeyValuePair<string, DateTime>> errors;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new SqlDataQueryController.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">SQL connection string</param>
|
||||
/// <param name="outputFolder">Output folder to save results to</param>
|
||||
/// <param name="perfQueryIntervalInSec">Interval, in seconds, at which perf counters are collected</param>
|
||||
/// <param name="numberOfIterations">Number of iterations of perf counter collection before aggreagtion</param>
|
||||
/// <param name="staticQueryIntervalInSec">Interval, in seconds, at which static/common counters are colltected</param>
|
||||
/// <param name="logger">Logger</param>
|
||||
public SqlDataQueryController(
|
||||
string connectionString,
|
||||
string outputFolder,
|
||||
int perfQueryIntervalInSec,
|
||||
int numberOfIterations,
|
||||
int staticQueryIntervalInSec,
|
||||
ISqlAssessmentLogger logger = null)
|
||||
{
|
||||
this.outputFolder = outputFolder;
|
||||
this.perfQueryIntervalInSec = perfQueryIntervalInSec;
|
||||
this.numberOfIterations = numberOfIterations;
|
||||
this._logger = logger ?? new DefaultPerfDataCollectionLogger();
|
||||
this.messages = new List<KeyValuePair<string, DateTime>>();
|
||||
this.errors = new List<KeyValuePair<string, DateTime>>();
|
||||
perfDataCache = new SqlPerfDataPointsCache(this.outputFolder, _logger);
|
||||
dataCollector = new DataPointsCollector(new string[] { connectionString }, _logger);
|
||||
|
||||
// set up timers to run perf/static collection at specified intervals
|
||||
System.Timers.Timer perfDataCollectionTimer = new System.Timers.Timer();
|
||||
perfDataCollectionTimer.Elapsed += (sender, e) => PerfDataQueryEvent();
|
||||
perfDataCollectionTimer.Interval = perfQueryIntervalInSec * 1000;
|
||||
timers.Add(perfDataCollectionTimer);
|
||||
|
||||
System.Timers.Timer staticDataCollectionTimer = new System.Timers.Timer();
|
||||
staticDataCollectionTimer.Elapsed += (sender, e) => StaticDataQueryAndPersistEvent();
|
||||
staticDataCollectionTimer.Interval = staticQueryIntervalInSec * 1000;
|
||||
timers.Add(staticDataCollectionTimer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start this SqlDataQueryController.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
foreach (var timer in timers)
|
||||
{
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether or not this SqlDataQueryController is currently running.
|
||||
/// </summary>
|
||||
public bool IsRunning()
|
||||
{
|
||||
return this.timers.All(timer => timer.Enabled);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collect performance data, adding the collected points to the cache.
|
||||
/// </summary>
|
||||
private void PerfDataQueryEvent()
|
||||
{
|
||||
try
|
||||
{
|
||||
int currentIteration = perfDataCache.CurrentIteration;
|
||||
|
||||
// Get raw perf data points
|
||||
var validationResult = dataCollector.CollectPerfDataPoints(CancellationToken.None, TimeSpan.FromSeconds(this.perfQueryIntervalInSec)).Result.FirstOrDefault();
|
||||
|
||||
if (validationResult != null && validationResult.Status == SqlAssessmentStatus.Completed)
|
||||
{
|
||||
IList<ISqlPerfDataPoints> result = validationResult.SqlPerfDataPoints;
|
||||
perfDataCache.AddingPerfData(result);
|
||||
serverName = this.perfDataCache.ServerName;
|
||||
|
||||
this.messages.Add(new KeyValuePair<string, DateTime>(
|
||||
string.Format("Performance data query iteration: {0} of {1}, collected {2} data points.", currentIteration, numberOfIterations, result.Count),
|
||||
DateTime.UtcNow));
|
||||
|
||||
// perform aggregation and persistence once enough iterations have completed
|
||||
if (currentIteration == numberOfIterations)
|
||||
{
|
||||
PerfDataAggregateAndPersistEvent();
|
||||
}
|
||||
}
|
||||
else if (validationResult != null && validationResult.Status == SqlAssessmentStatus.Error)
|
||||
{
|
||||
var error = validationResult.Errors.FirstOrDefault();
|
||||
|
||||
Logging(error);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggregate and persist the cached points, saving the aggregated points to disk.
|
||||
/// </summary>
|
||||
internal void PerfDataAggregateAndPersistEvent()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Aggregate the records in the Cache
|
||||
int rawDataPointsCount = this.perfDataCache.GetRawDataPointsCount();
|
||||
|
||||
this.perfDataCache.AggregatingPerfData();
|
||||
int aggregatedDataPointsCount = this.perfDataCache.GetAggregatedDataPointsCount();
|
||||
|
||||
// Persist into local csv.
|
||||
if (aggregatedDataPointsCount > 0)
|
||||
{
|
||||
this.perfDataCache.PersistingCacheAsCsv();
|
||||
|
||||
this.messages.Add(new KeyValuePair<string, DateTime>(
|
||||
string.Format("Aggregated {0} raw data points to {1} performance counters, and saved to {2}.", rawDataPointsCount, aggregatedDataPointsCount, this.outputFolder),
|
||||
DateTime.UtcNow));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collect and persist static data, saving the collected points to disk.
|
||||
/// </summary>
|
||||
private void StaticDataQueryAndPersistEvent()
|
||||
{
|
||||
try
|
||||
{
|
||||
var validationResult = this.dataCollector.CollectCommonDataPoints(CancellationToken.None).Result.FirstOrDefault();
|
||||
if (validationResult != null && validationResult.Status == SqlAssessmentStatus.Completed)
|
||||
{
|
||||
// Common data result
|
||||
IList<ISqlCommonDataPoints> staticDataResult = new List<ISqlCommonDataPoints>();
|
||||
staticDataResult.Add(validationResult.SqlCommonDataPoints);
|
||||
serverName = staticDataResult.Select(p => p.ServerName).FirstOrDefault();
|
||||
|
||||
// Save to csv
|
||||
var persistor = new DataPointsPersistor(this.outputFolder);
|
||||
|
||||
serverName = staticDataResult.Select(p => p.ServerName).FirstOrDefault();
|
||||
persistor.SaveCommonDataPoints(staticDataResult, serverName);
|
||||
|
||||
this.messages.Add(new KeyValuePair<string, DateTime>(
|
||||
string.Format("Collected static configuration data, and saved to {0}.", this.outputFolder),
|
||||
DateTime.UtcNow));
|
||||
}
|
||||
else if (validationResult != null && validationResult.Status == SqlAssessmentStatus.Error)
|
||||
{
|
||||
var error = validationResult.Errors.FirstOrDefault();
|
||||
|
||||
Logging(error);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log exceptions to file.
|
||||
/// </summary>
|
||||
/// <param name="ex">Exception to log</param>
|
||||
private void Logging(Exception ex)
|
||||
{
|
||||
this.errors.Add(new KeyValuePair<string, DateTime>(ex.Message, DateTime.UtcNow));
|
||||
|
||||
var error = new UnhandledSqlExceptionErrorModel(ex, ErrorScope.General);
|
||||
_logger.Log(error, ErrorLevel.Error, TelemetryScope.PerfCollection);
|
||||
_logger.Log(TelemetryScope.PerfCollection, ex.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log errors to file.
|
||||
/// </summary>
|
||||
/// <param name="error">Error to log</param>
|
||||
private void Logging(IErrorModel error)
|
||||
{
|
||||
this.errors.Add(new KeyValuePair<string, DateTime>(error.RawException.Message, DateTime.UtcNow));
|
||||
|
||||
_logger.Log(error, ErrorLevel.Error, TelemetryScope.PerfCollection);
|
||||
_logger.Log(TelemetryScope.PerfCollection, error.RawException.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the latest messages, and then clears the message list.
|
||||
/// </summary>
|
||||
/// <param name="startTime">Only return messages from after this time</param>
|
||||
/// <returns>List of queued messages</returns>
|
||||
public List<string> FetchLatestMessages(DateTime startTime)
|
||||
{
|
||||
List<string> latestMessages = this.messages.Where(kvp => kvp.Value > startTime).Select(kvp => kvp.Key).ToList();
|
||||
this.messages.Clear();
|
||||
return latestMessages;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the latest messages, and then clears the message list.
|
||||
/// </summary>
|
||||
/// <param name="startTime">Only return messages from after this time</param>
|
||||
/// <returns>List of queued errors</returns>
|
||||
public List<string> FetchLatestErrors(DateTime startTime)
|
||||
{
|
||||
List<string> latestErrors = this.errors.Where(kvp => kvp.Value > startTime).Select(kvp => kvp.Key).ToList();
|
||||
this.messages.Clear();
|
||||
return latestErrors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose of this SqlDataQueryController.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
foreach (var timer in timers)
|
||||
{
|
||||
timer.Stop();
|
||||
}
|
||||
|
||||
if (perfDataCache.CurrentIteration > 2)
|
||||
{
|
||||
PerfDataAggregateAndPersistEvent(); // flush cache if there are enough data points
|
||||
}
|
||||
|
||||
this.perfDataCache = null;
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache to store intermediate SQL performance data before it is aggregated and persisted for SKU recommendation.
|
||||
/// </summary>
|
||||
public class SqlPerfDataPointsCache
|
||||
{
|
||||
public string ServerName { get; private set; }
|
||||
|
||||
public int CurrentIteration { get; private set; }
|
||||
|
||||
private string outputFolder;
|
||||
private ISqlAssessmentLogger logger;
|
||||
|
||||
private IList<IList<ISqlPerfDataPoints>> perfDataPoints = new List<IList<ISqlPerfDataPoints>>();
|
||||
private IList<AggregatedPerformanceCounters> perfAggregated = new List<AggregatedPerformanceCounters>();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new SqlPerfDataPointsCache.
|
||||
/// </summary>
|
||||
/// <param name="outputFolder">Output folder to save results to</param>
|
||||
/// <param name="logger">Logger</param>
|
||||
public SqlPerfDataPointsCache(string outputFolder, ISqlAssessmentLogger logger = null)
|
||||
{
|
||||
this.outputFolder = outputFolder;
|
||||
this.logger = logger ?? new DefaultPerfDataCollectionLogger();
|
||||
CurrentIteration = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the collected data points to the cache.
|
||||
/// </summary>
|
||||
/// <param name="result">Collected data points</param>
|
||||
public void AddingPerfData(IList<ISqlPerfDataPoints> result)
|
||||
{
|
||||
ServerName = result.Select(p => p.ServerName).FirstOrDefault();
|
||||
perfDataPoints.Add(result);
|
||||
CurrentIteration++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of raw data points.
|
||||
/// </summary>
|
||||
public int GetRawDataPointsCount()
|
||||
{
|
||||
// flatten list
|
||||
return perfDataPoints.SelectMany(x => x).Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of aggregated data points.
|
||||
/// </summary>
|
||||
public int GetAggregatedDataPointsCount()
|
||||
{
|
||||
return perfAggregated.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggregate the cached data points.
|
||||
/// </summary>
|
||||
public void AggregatingPerfData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var aggregator = new CounterAggregator(logger);
|
||||
perfAggregated = aggregator.AggregateDatapoints(perfDataPoints);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
perfDataPoints.Clear();
|
||||
// reset the iteration counter
|
||||
CurrentIteration = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the cached and aggregated data points to disk.
|
||||
/// </summary>
|
||||
public void PersistingCacheAsCsv()
|
||||
{
|
||||
// Save to csv
|
||||
var persistor = new DataPointsPersistor(outputFolder);
|
||||
persistor.SavePerfDataPoints(perfAggregated, machineId: ServerName, overwrite: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlServer.DataCollection.Common.Contracts.OperationsInfrastructure;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Utils
|
||||
{
|
||||
internal static class ExtensionMethods
|
||||
{
|
||||
public static void AddExceptions(this IDictionary<string, IEnumerable<ReportableException>> exceptionMap1, IDictionary<string, IEnumerable<ReportableException>> exceptionMap2)
|
||||
{
|
||||
if (exceptionMap1 is null || exceptionMap2 is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var keyValuePair2 in exceptionMap2)
|
||||
{
|
||||
// If the dictionary already contains the key then merge them
|
||||
if (exceptionMap1.ContainsKey(keyValuePair2.Key))
|
||||
{
|
||||
foreach (var value in keyValuePair2.Value)
|
||||
{
|
||||
exceptionMap1[keyValuePair2.Key].Append(value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
exceptionMap1.Add(keyValuePair2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Utils
|
||||
{
|
||||
internal static class MigrationServiceHelper
|
||||
{
|
||||
public static string FormatTimeSpan(TimeSpan ts)
|
||||
{
|
||||
return String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
ServerName,DatabaseName,LogicalName,PhysicalFullName,FileType,SizeMB,IsMemoryOptimizedDataOptionEnabled,TimeDataCollected
|
||||
TEST,test,test,C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test.mdf,Rows,3,False,2021-10-28 19:08:03
|
||||
TEST,test,test_log,C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test_log.ldf,Log,1,False,2021-10-28 19:08:03
|
||||
TEST,test1,AdventureWorks2008R2_Data,C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test1.mdf,Rows,195.9375,False,2021-10-28 19:08:03
|
||||
TEST,test1,AdventureWorks2008R2_Log,C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test1_1.LDF,Log,3.75,False,2021-10-28 19:08:03
|
||||
|
@@ -1,2 +0,0 @@
|
||||
ServerName,Edition,HyperthreadRatio,IsClustered,IsHadrEnabled,LogicalCpuCount,MaxServerMemoryInUse,NumberCoresUsed,NumberOfUserDatabases,PhysicalCpuCount,ProductVersion,SqlStartTime,SumOfUserDatabasesSize,TempDbSize,NumOfLogins,TimeDataCollected
|
||||
TEST,Enterprise Edition (64-bit),2,False,False,2,2147483647,2,2,1,10.50.6592.0,2021-10-26 19:26:06,203,8,13,2021-10-28 19:08:03
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Migration
|
||||
{
|
||||
public class MigrationServiceTests
|
||||
{
|
||||
[Test]
|
||||
public async Task TestHandleMigrationAssessmentRequest()
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
||||
|
||||
var requestParams = new MigrationAssessmentsParams()
|
||||
{
|
||||
OwnerUri = connectionResult.ConnectionInfo.OwnerUri
|
||||
};
|
||||
|
||||
var requestContext = new Mock<RequestContext<MigrationAssessmentResult>>();
|
||||
|
||||
MigrationService service = new MigrationService();
|
||||
await service.HandleMigrationAssessmentsRequest(requestParams, requestContext.Object);
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Disable failing test")]
|
||||
public async Task TestHandleMigrationGetSkuRecommendationsRequest()
|
||||
{
|
||||
GetSkuRecommendationsResult result = null;
|
||||
|
||||
var requestParams = new GetSkuRecommendationsParams()
|
||||
{
|
||||
DataFolder = Path.Combine("..", "..", "..", "Migration", "Data"),
|
||||
TargetPlatforms = new List<string> { "AzureSqlManagedInstance" },
|
||||
TargetSqlInstance = "Test",
|
||||
TargetPercentile = 95,
|
||||
StartTime = new DateTime(2020, 01, 01).ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
EndTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
PerfQueryIntervalInSec = 30,
|
||||
ScalingFactor = 1,
|
||||
DatabaseAllowList = new List<string> { "test", "test1" }
|
||||
};
|
||||
|
||||
var requestContext = RequestContextMocks.Create<GetSkuRecommendationsResult>(r => result = r).AddErrorHandling(null);
|
||||
|
||||
MigrationService service = new MigrationService();
|
||||
await service.HandleGetSkuRecommendationsRequest(requestParams, requestContext.Object);
|
||||
Assert.IsNotNull(result, "Get SKU Recommendation result is null");
|
||||
Assert.IsNotNull(result.SqlMiRecommendationResults, "Get MI SKU Recommendation baseline result is null");
|
||||
Assert.IsNotNull(result.ElasticSqlMiRecommendationResults, "Get MI SKU Recommendation elastic result is null");
|
||||
|
||||
// TODO: Include Negative Justification in future when we start recommending more than one SKU.
|
||||
Assert.Greater(result.SqlMiRecommendationResults.First().PositiveJustifications.Count, 0, "No positive justification for MI SKU Recommendation result");
|
||||
Assert.Greater(result.ElasticSqlMiRecommendationResults.First().PositiveJustifications.Count, 0, "No positive justification for MI SKU elastic Recommendation result");
|
||||
|
||||
Assert.IsNotNull(result.InstanceRequirements);
|
||||
Assert.AreEqual(result.InstanceRequirements.InstanceId, "TEST");
|
||||
Assert.AreEqual(result.InstanceRequirements.DatabaseLevelRequirements.Count, 2);
|
||||
Assert.AreEqual(result.InstanceRequirements.DatabaseLevelRequirements.Sum(db => db.FileLevelRequirements.Count), 4);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestHandleStartStopPerfDataCollectionRequest()
|
||||
{
|
||||
StartPerfDataCollectionResult result = null;
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
||||
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SkuRecommendationTest");
|
||||
Directory.CreateDirectory(folderPath);
|
||||
|
||||
var requestParams = new StartPerfDataCollectionParams()
|
||||
{
|
||||
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
|
||||
DataFolder = folderPath,
|
||||
PerfQueryIntervalInSec = 30,
|
||||
NumberOfIterations = 20,
|
||||
StaticQueryIntervalInSec = 3600,
|
||||
};
|
||||
|
||||
var requestContext = RequestContextMocks.Create<StartPerfDataCollectionResult>(r => result = r).AddErrorHandling(null);
|
||||
|
||||
MigrationService service = new MigrationService();
|
||||
await service.HandleStartPerfDataCollectionRequest(requestParams, requestContext.Object);
|
||||
Assert.IsNotNull(result, "Start Perf Data Collection result is null");
|
||||
Assert.IsNotNull(result.DateTimeStarted, "Time perf data collection started is null");
|
||||
|
||||
// Stop data collection
|
||||
StopPerfDataCollectionResult stopResult = null;
|
||||
var stopRequestParams = new StopPerfDataCollectionParams()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var stopRequestContext = RequestContextMocks.Create<StopPerfDataCollectionResult>(r => stopResult = r).AddErrorHandling(null);
|
||||
|
||||
await service.HandleStopPerfDataCollectionRequest(stopRequestParams, stopRequestContext.Object);
|
||||
Assert.IsNotNull(stopResult, "Stop Perf Data Collection result is null");
|
||||
Assert.IsNotNull(stopResult.DateTimeStopped, "Time perf data collection stoped is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user