Skip to content

Commit

Permalink
Merge pull request #6 from bamcis-io/vNext
Browse files Browse the repository at this point in the history
Updates for 0.198.4-beta
  • Loading branch information
hakenmt authored May 5, 2021
2 parents ce73b5f + 73037f6 commit 64bb012
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 93 deletions.
133 changes: 116 additions & 17 deletions PrestoClient/Interfaces/IPrestoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using BAMCIS.PrestoClient.Model.SPI;
using BAMCIS.PrestoClient.Model.Statement;
using BAMCIS.PrestoClient.Model.Thread;
using System.Threading;
using System.Threading.Tasks;

namespace BAMCIS.PrestoClient.Interfaces
Expand All @@ -16,77 +17,167 @@ public interface IPrestoClient
#region Threads

/// <summary>
/// Lists thread details
/// Gets information about the in use threads in the cluster.
/// </summary>
/// <returns>Details about each thread</returns>
/// <returns>
/// Information about all of the threads and their state.
/// </returns>
Task<ListThreadsV1Response> ListThreads();

/// <summary>
/// Retrieves the web ui HTML page for thread stats
/// Gets information about the in use threads in the cluster.
/// </summary>
/// <returns></returns>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>
/// Information about all of the threads and their state.
/// </returns>
Task<ListThreadsV1Response> ListThreads(CancellationToken cancellationToken);

/// <summary>
/// Gets the web ui html that displays information about the threads
/// in the cluster and optionally opens that web page.
/// </summary>
/// <returns>The web page html/javascript/css.</returns>
Task<string> GetThreadUIHtml();

/// <summary>
/// Gets the web ui html that displays information about the threads
/// in the cluster and optionally opens that web page.
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>The web page html/javascript/css.</returns>
Task<string> GetThreadUIHtml(CancellationToken cancellationToken);

#endregion

#region Nodes

/// <summary>
/// Gets a list of worker nodes
/// Gets the worker nodes in a presto cluster
/// </summary>
/// <returns>The worker nodes</returns>
/// <returns>
/// Information about all of the worker nodes. If the request is unsuccessful,
/// a PrestoException is thrown.
/// </returns>
Task<ListNodesV1Response> ListNodes();

/// <summary>
/// Gets a list of failed worker nodes
/// Gets the worker nodes in a presto cluster
/// </summary>
/// <returns>The list of failed worker nodes</returns>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>
/// Information about all of the worker nodes. If the request is unsuccessful,
/// a PrestoException is thrown.
/// </returns>
Task<ListNodesV1Response> ListNodes(CancellationToken cancellationToken);

/// <summary>
/// Gets any failed nodes in a presto cluster.
/// </summary>
/// <returns>
/// Information about the failed nodes. If there are no failed nodes,
/// the FailedNodes property will be null.
/// </returns>
Task<ListFailedNodesV1Response> ListFailedNodes();

/// <summary>
/// Gets any failed nodes in a presto cluster.
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>
/// Information about the failed nodes. If there are no failed nodes,
/// the FailedNodes property will be null.
/// </returns>
Task<ListFailedNodesV1Response> ListFailedNodes(CancellationToken cancellationToken);

#endregion

#region Query

/// <summary>
/// Kills a specified query
/// Kills an active query statement
/// </summary>
/// <param name="queryId">The id of the query</param>
/// <returns></returns>
/// <param name="queryId">The id of the query to kill</param>
/// <returns>No value is returned, but the method will throw an exception if it was not successful</returns>
Task KillQuery(string queryId);

/// <summary>
/// Gets basic query details about all queries that have not been purged
/// Kills an active query statement
/// </summary>
/// <param name="queryId">The Id of the query to kill</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>No value is returned, but the method will throw an exception if it was not successful</returns>
Task KillQuery(string queryId, CancellationToken cancellationToken);

/// <summary>
/// This method returns information and statistics about queries that
/// are currently being executed on a Presto coordinator that have not been purged
/// </summary>
/// <returns>Details on the queries</returns>
Task<ListQueriesV1Response> GetQueries();

/// <summary>
/// This method returns information and statistics about queries that
/// are currently being executed on a Presto coordinator that have not been purged
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>Details on the queries</returns>
Task<ListQueriesV1Response> GetQueries(CancellationToken cancellationToken);

/// <summary>
/// Gets a detailed summary of the specified query
/// </summary>
/// <param name="queryId">The id of the query</param>
/// <param name="queryId">The id of the query to retrieve details about.</param>
/// <returns>Detailed summary of the query</returns>
Task<GetQueryV1Response> GetQuery(string queryId);

/// <summary>
/// Gets a detailed summary of the specified query
/// </summary>
/// <param name="queryId">The id of the query</param>
/// <param name="queryId">The id of the query to retrieve details about.</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>Detailed summary of the query</returns>
Task<GetQueryV1Response> GetQuery(string queryId, CancellationToken CancellationToken);

/// <summary>
/// Gets a detailed summary of the specified query
/// </summary>
/// <param name="queryId">The id of the query to retrieve details about.</param>
/// <returns>Detailed summary of the query</returns>
Task<GetQueryV1Response> GetQuery(QueryId queryId);

/// <summary>
/// Gets a detailed summary of the specified query
/// </summary>
/// <param name="queryId">The id of the query to retrieve details about.</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>Detailed summary of the query</returns>
Task<GetQueryV1Response> GetQuery(QueryId queryId, CancellationToken cancellationToken);

#endregion

#region Statements

/// <summary>
/// Executes a Presto SQL statement
/// Submits a Presto SQL statement for execution. The Presto client
/// executes queries on behalf of a user against a catalog and a schema.
/// </summary>
/// <param name="request">The request details</param>
/// <returns>The response from the statement</returns>
/// <param name="request">The query execution request.</param>
/// <returns>The resulting response object from the query.</returns>
Task<ExecuteQueryV1Response> ExecuteQueryV1(ExecuteQueryV1Request request);

/// <summary>
/// Submits a Presto SQL statement for execution. The Presto client
/// executes queries on behalf of a user against a catalog and a schema.
/// </summary>
/// <param name="request">The query execution request.</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>The resulting response object from the query.</returns>
Task<ExecuteQueryV1Response> ExecuteQueryV1(ExecuteQueryV1Request request, CancellationToken cancellationToken);

// Not yet available as of Presto 0.198
// Task<ExecuteQueryResponse<QueryResultsV2>> ExecuteQueryV2(ExecuteQueryV2Request request);
// Task<ExecuteQueryResponse<QueryResultsV2>> ExecuteQueryV2(ExecuteQueryV2Request request, CancellationToken cancellationToken);

#endregion

Expand All @@ -99,6 +190,14 @@ public interface IPrestoClient
/// <returns>Details about the specified Jmx Mbean</returns>
Task<JmxMbeanV1Response> GetJmxMbean(JmxMbeanV1Request request);

/// <summary>
/// Gets details about a specified Jmx Mbean
/// </summary>
/// <param name="request">The request details</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>Details about the specified Jmx Mbean</returns>
Task<JmxMbeanV1Response> GetJmxMbean(JmxMbeanV1Request request, CancellationToken cancellationToken);

#endregion
}
}
6 changes: 3 additions & 3 deletions PrestoClient/Model/Statement/ResponseHeaderCollection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http.Headers;
using System.Web;

namespace BAMCIS.PrestoClient.Model.Statement
{
Expand Down Expand Up @@ -86,14 +86,14 @@ public ResponseHeaderCollection(HttpResponseHeaders headers)
continue;
}

AddedPrepare.Add(HttpUtility.UrlDecode(Parts[0]), HttpUtility.UrlDecode(Parts[1]));
AddedPrepare.Add(WebUtility.UrlDecode(Parts[0]), WebUtility.UrlDecode(Parts[1]));
}
}

// Get the deallocated prepared statements
if (headers.TryGetValues(PrestoHeader.PRESTO_DEALLOCATED_PREPARE.Value, out Temp))
{
this.DeallocatedPreparedStatements = new HashSet<string>(Temp.Select(x => HttpUtility.UrlDecode(x)));
this.DeallocatedPreparedStatements = new HashSet<string>(Temp.Select(x => WebUtility.UrlDecode(x)));
}
else
{
Expand Down
35 changes: 27 additions & 8 deletions PrestoClient/PrestoClient.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<AssemblyName>PrestoClient</AssemblyName>
<RootNamespace>BAMCIS.PrestoClient</RootNamespace>
<Version>0.198.2</Version>
<Version>0.198.4-beta</Version>
<Authors>Michael Haken</Authors>
<Company>bamcis.io</Company>
<PackageReleaseNotes>This is a presto db .NET client for Presto version 0.198.</PackageReleaseNotes>
<Copyright>2018 BAMCIS</Copyright>
<Copyright>2021 bamcis.io</Copyright>
<PackageProjectUrl>https://github.com/bamcis-io/PrestoClient</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>Presto Prestodb</PackageTags>
<RepositoryUrl>https://github.com/bamcis-io/PrestoClient</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Description>A .NET Core client for Presto.</Description>
<PackageLicenseUrl>https://github.com/bamcis-io/PrestoClient/blob/master/LICENSE</PackageLicenseUrl>
<AssemblyVersion>0.198.2.0</AssemblyVersion>
<PackageLicenseUrl></PackageLicenseUrl>
<AssemblyVersion>0.198.4.0</AssemblyVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>prestoclient.snk</AssemblyOriginatorKeyFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.4.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>DynamicProxyGenAssembly2,PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>
$(AssemblyName).Tests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100055a653391531f8cac53f14cba9d262efc5f847873a45dcec35b3c5fc9b80295da9562eb92186acbae0aec962e19e87932fc2177c8eb808edcf8842fd23266a2f49e010cbf0b58beea5b113004642d6140bd6d3368338f222f4ebf100c0d902aea019d6dded20011bd38617493ea2ee5e49da8cae15a4be231bb9a6670e997be
</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions PrestoClient/PrestoClientSessionConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public string User
}
}

/// <summary>
/// The password to use in HTTP basic auth with the presto server
/// </summary>
public string Password { get; set; }

/// <summary>
/// The catalog to use for interaction with presto.
/// </summary>
Expand Down
Loading

0 comments on commit 64bb012

Please # to comment.