Remove big data cluster references from connections. (#1775)

This commit is contained in:
Cory Rivera
2022-12-09 10:25:28 -08:00
committed by GitHub
parent cf5af7bcf2
commit 6122a5dbcb
2 changed files with 0 additions and 75 deletions

View File

@@ -652,8 +652,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
public class ServerInfo
{
internal const string OptionIsBigDataCluster = "isBigDataCluster";
internal const string OptionClusterEndpoints = "clusterEndpoints";
public int ServerMajorVersion;
public int ServerMinorVersion;
public int ServerReleaseVersion;
@@ -676,16 +674,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
public Dictionary<string, object> Options { get; set; }
}
public class ClusterEndpoint
{
public string ServiceName;
public string Description;
public string Endpoint;
public string Protocol;
public string IpAddress;
public int Port;
}
public class ServerHostInfo
{
public string Platform;
@@ -899,28 +887,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
serverInfo.Options = new Dictionary<string, object>();
// Get BDC endpoints
if (!serverInfo.IsCloud && serverInfo.ServerMajorVersion >= 15)
{
List<ClusterEndpoint> clusterEndpoints = new List<ClusterEndpoint>();
serverInfo.Options.Add(ServerInfo.OptionClusterEndpoints, clusterEndpoints);
try
{
LookupClusterEndpoints(connection, serverInfo, clusterEndpoints);
}
catch (SqlException)
{
// Failed to find cluster endpoints DMV, this must not be a cluster
// or user does not have permissions to see cluster info
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, false);
}
}
else
{
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, false);
}
return serverInfo;
};
@@ -939,28 +905,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
return result;
}
private static void LookupClusterEndpoints(IDbConnection connection, ServerInfo serverInfo, List<ClusterEndpoint> clusterEndpoints)
{
ExecuteReader(
connection,
SqlConnectionHelperScripts.GetClusterEndpoints,
delegate (IDataReader reader)
{
while (reader.Read())
{
clusterEndpoints.Add(new ClusterEndpoint
{
ServiceName = reader.GetString(0),
Description = reader.GetString(1),
Endpoint = reader.GetString(2),
Protocol = reader.GetString(3)
});
}
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, clusterEndpoints.Count > 0);
}
);
}
public static string GetServerName(IDbConnection connection)
{
return new DbConnectionWrapper(connection).DataSource;

View File

@@ -44,25 +44,6 @@ IF (@filepath IS NULL)
WHERE [file_id] = 2
SELECT @filepath AS FilePath
";
/**
* Query to get the server endpoints. We first try to query the dm_cluster_endpoints DMV since that will contain all
* of the endpoints. But if that fails (such as if the user doesn't have VIEW SERVER STATE permissions) then we'll
* fall back to just querying the ControllerEndpoint server property to at least get the endpoint of the controller
* and rely on the caller to connect to the controller to query for any of the other endpoints it needs.
*/
public const string GetClusterEndpoints = @"BEGIN TRY
SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints]
END TRY
BEGIN CATCH
DECLARE @endpoint VARCHAR(MAX)
SELECT @endpoint = CONVERT(VARCHAR(MAX),SERVERPROPERTY('ControllerEndpoint'))
-- If the endpoint is empty/null then return 0 rows (we don't have any cluster endpoints)
IF @endpoint <> ''
SELECT 'controller' AS name, 'Cluster Management Service' AS description, @endpoint as endpoint, SUBSTRING(@endpoint, 0, CHARINDEX(':', @endpoint))
ELSE
SELECT TOP 0 ''
END CATCH
";
public const string GetHostInfo = @"SELECT [host_platform], [host_distribution], [host_release], [host_service_pack_level], [host_sku], [os_language_version] FROM sys.dm_os_host_info";
public const string GetHostWindowsVersion = @"SELECT windows_release FROM sys.dm_os_windows_info";