Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete by query rethrottle API #3595

Merged
merged 5 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/CodeGeneration/ApiGenerator/ApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class ApiGenerator
// these API's are new and need to be mapped
"xpack.ml.delete_forecast.json",
"xpack.ml.find_file_structure.json",
"delete_by_query_rethrottle.json",
"update_by_query_rethrottle.json",

"xpack.ml.update_filter.json",
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGeneration/ApiGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static void Main(string[] args)

if (redownloadCoreSpecification)
{
Console.Write("Branch to download specification from (default master): ");
Console.Write($"Branch to download specification from (default {downloadBranch}): ");
var readBranch = Console.ReadLine()?.Trim();
if (!string.IsNullOrEmpty(readBranch)) downloadBranch = readBranch;
}
Expand Down
4,153 changes: 717 additions & 3,436 deletions src/CodeGeneration/ApiGenerator/RestSpecification/Core/root.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.3
v6.6.2
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,13 @@ public partial class DeleteByQueryRequestParameters : RequestParameters<DeleteBy
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
}
///<summary>Request options for DeleteByQueryRethrottle<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
public partial class DeleteByQueryRethrottleRequestParameters : RequestParameters<DeleteByQueryRethrottleRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
public long? RequestsPerSecond { get => Q<long?>("requests_per_second"); set => Q("requests_per_second", value); }
}
///<summary>Request options for DeleteScript<pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</pre></summary>
public partial class DeleteScriptRequestParameters : RequestParameters<DeleteScriptRequestParameters>
{
Expand Down
10 changes: 10 additions & 0 deletions src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,16 @@ public TResponse DeleteByQuery<TResponse>(string index, string type, PostData bo
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> DeleteByQueryAsync<TResponse>(string index, string type, PostData body, DeleteByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"{index.NotNull("index")}/{type.NotNull("type")}/_delete_by_query"), ctx, body, _params(requestParameters));
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
///<param name="task_id">The task id to rethrottle</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse DeleteByQueryRethrottle<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(POST, Url($"_delete_by_query/{task_id.NotNull("task_id")}/_rethrottle"), null, _params(requestParameters));
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
///<param name="task_id">The task id to rethrottle</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> DeleteByQueryRethrottleAsync<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_delete_by_query/{task_id.NotNull("task_id")}/_rethrottle"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_scripts/{id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</para></summary>
///<param name="id">Script ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down
8 changes: 8 additions & 0 deletions src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ public partial interface IElasticLowLevelClient
///<param name="body">The search definition using the Query DSL</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> DeleteByQueryAsync<TResponse>(string index, string type, PostData body, DeleteByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
///<param name="task_id">The task id to rethrottle</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse DeleteByQueryRethrottle<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>POST on /_delete_by_query/{task_id}/_rethrottle <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</para></summary>
///<param name="task_id">The task id to rethrottle</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> DeleteByQueryRethrottleAsync<TResponse>(string task_id, DeleteByQueryRethrottleRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_scripts/{id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</para></summary>
///<param name="id">Script ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,5 @@
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/Name/@EntryValue">Hack</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/Pattern/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;HACK)(\W|$)(.*)</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=B68C83B0AE11204AAA509A6033251E74/TodoIconStyle/@EntryValue">Warning</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rethrottle/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
15 changes: 14 additions & 1 deletion src/Nest/Cluster/TaskManagement/ListTasks/ListTasksResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ public class ListTasksResponse : ResponseBase, IListTasksResponse
{
public override bool IsValid => base.IsValid && !NodeFailures.HasAny();
public IReadOnlyCollection<ErrorCause> NodeFailures { get; internal set; } = EmptyReadOnly<ErrorCause>.Collection;

public IReadOnlyDictionary<string, TaskExecutingNode> Nodes { get; internal set; } = EmptyReadOnly<string, TaskExecutingNode>.Dictionary;
}

/// <summary>
/// A node executing a task
/// </summary>
public class TaskExecutingNode
{
[JsonProperty("attributes")]
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter<string, string>))]
public IReadOnlyDictionary<string, string> Attributes { get; internal set; } =
EmptyReadOnly<string, string>.Dictionary;

[JsonProperty("host")]
public string Host { get; internal set; }

Expand All @@ -33,13 +40,19 @@ public class TaskExecutingNode
[JsonProperty("name")]
public string Name { get; internal set; }

[JsonProperty("roles")]
public IEnumerable<string> Roles { get; internal set; }

[JsonProperty("tasks")]
public IReadOnlyDictionary<TaskId, TaskState> Tasks { get; internal set; } = EmptyReadOnly<TaskId, TaskState>.Dictionary;

[JsonProperty("transport_address")]
public string TransportAddress { get; internal set; }
}

/// <summary>
/// The state of the task
/// </summary>
public class TaskState
{
[JsonProperty("action")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using Newtonsoft.Json;

namespace Nest
{
/// <summary>
/// Rethrottles a running delete by query
/// </summary>
public partial interface IDeleteByQueryRethrottleRequest
{
}

/// <inheritdoc cref="IDeleteByQueryRethrottleRequest" />
public partial class DeleteByQueryRethrottleRequest : IDeleteByQueryRethrottleRequest
{

}

/// <inheritdoc cref="IDeleteByQueryRethrottleRequest" />
public partial class DeleteByQueryRethrottleDescriptor : IDeleteByQueryRethrottleRequest
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Elasticsearch.Net;

namespace Nest
{
public partial interface IElasticClient
{
/// <summary>
/// Rethrottles a running delete by query. Rethrottling that speeds up the query takes effect immediately
/// but rethrotting that slows down the query will take effect after completing the current batch. This prevents scroll timeouts.
/// <para> </para>
/// <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-rethrottle">https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-rethrottle</a>
/// </summary>
IListTasksResponse DeleteByQueryRethrottle(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null);

/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
IListTasksResponse DeleteByQueryRethrottle(IDeleteByQueryRethrottleRequest request);

/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
Task<IListTasksResponse> DeleteByQueryRethrottleAsync(TaskId taskId,
Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null,
CancellationToken cancellationToken = default(CancellationToken)
);

/// <inheritdoc cref="DeleteByQueryRethrottle(Nest.TaskId,System.Func{Nest.DeleteByQueryRethrottleDescriptor,Nest.IDeleteByQueryRethrottleRequest})" />
Task<IListTasksResponse> DeleteByQueryRethrottleAsync(IDeleteByQueryRethrottleRequest request,
CancellationToken cancellationToken = default(CancellationToken)
);
}

public partial class ElasticClient
{
/// <inheritdoc />
public IListTasksResponse DeleteByQueryRethrottle(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null) =>
DeleteByQueryRethrottle(selector.InvokeOrDefault(new DeleteByQueryRethrottleDescriptor(taskId)));

/// <inheritdoc />
public IListTasksResponse DeleteByQueryRethrottle(IDeleteByQueryRethrottleRequest request) =>
Dispatcher.Dispatch<IDeleteByQueryRethrottleRequest, DeleteByQueryRethrottleRequestParameters, ListTasksResponse>(
request,
(p, d) => LowLevelDispatch.DeleteByQueryRethrottleDispatch<ListTasksResponse>(p)
);

/// <inheritdoc />
public Task<IListTasksResponse> DeleteByQueryRethrottleAsync(TaskId taskId, Func<DeleteByQueryRethrottleDescriptor, IDeleteByQueryRethrottleRequest> selector = null,
CancellationToken cancellationToken = default(CancellationToken)
) =>
DeleteByQueryRethrottleAsync(selector.InvokeOrDefault(new DeleteByQueryRethrottleDescriptor(taskId)), cancellationToken);

/// <inheritdoc />
public Task<IListTasksResponse> DeleteByQueryRethrottleAsync(IDeleteByQueryRethrottleRequest request,
CancellationToken cancellationToken = default(CancellationToken)
) =>
Dispatcher.DispatchAsync<IDeleteByQueryRethrottleRequest, DeleteByQueryRethrottleRequestParameters, ListTasksResponse, IListTasksResponse>(
request,
cancellationToken,
(p, d, c) => LowLevelDispatch.DeleteByQueryRethrottleDispatchAsync<ListTasksResponse>(p, c)
);
}
}
14 changes: 14 additions & 0 deletions src/Nest/_Generated/_Descriptors.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,20 @@ public DeleteByQueryDescriptor(Indices index) : base(r=>r.Required("index", inde
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
public DeleteByQueryDescriptor<T> Slices(long? slices) => Qs("slices", slices);
}
///<summary>descriptor for DeleteByQueryRethrottle <pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
public partial class DeleteByQueryRethrottleDescriptor : RequestDescriptorBase<DeleteByQueryRethrottleDescriptor,DeleteByQueryRethrottleRequestParameters, IDeleteByQueryRethrottleRequest>, IDeleteByQueryRethrottleRequest
{
/// <summary>/_delete_by_query/{task_id}/_rethrottle</summary>
///<param name="task_id"> this parameter is required</param>
public DeleteByQueryRethrottleDescriptor(TaskId task_id) : base(r=>r.Required("task_id", task_id)){}
// values part of the url path
TaskId IDeleteByQueryRethrottleRequest.TaskId => Self.RouteValues.Get<TaskId>("task_id");

// Request parameters

///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
public DeleteByQueryRethrottleDescriptor RequestsPerSecond(long? requestsPerSecond) => Qs("requests_per_second", requestsPerSecond);
}
///<summary>descriptor for DeleteScript <pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html</pre></summary>
public partial class DeleteScriptDescriptor : RequestDescriptorBase<DeleteScriptDescriptor,DeleteScriptRequestParameters, IDeleteScriptRequest>, IDeleteScriptRequest
{
Expand Down
22 changes: 22 additions & 0 deletions src/Nest/_Generated/_LowLevelDispatch.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,28 @@ internal partial class LowLevelDispatch
throw InvalidDispatch("DeleteByQuery", p, new [] { POST }, "/{index}/_delete_by_query", "/{index}/{type}/_delete_by_query");
}

internal TResponse DeleteByQueryRethrottleDispatch<TResponse>(IRequest<DeleteByQueryRethrottleRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
{
case POST:
if (AllSetNoFallback(p.RouteValues.TaskId)) return _lowLevel.DeleteByQueryRethrottle<TResponse>(p.RouteValues.TaskId,p.RequestParameters);
break;
}
throw InvalidDispatch("DeleteByQueryRethrottle", p, new [] { POST }, "/_delete_by_query/{task_id}/_rethrottle");
}

internal Task<TResponse> DeleteByQueryRethrottleDispatchAsync<TResponse>(IRequest<DeleteByQueryRethrottleRequestParameters> p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
{
case POST:
if (AllSetNoFallback(p.RouteValues.TaskId)) return _lowLevel.DeleteByQueryRethrottleAsync<TResponse>(p.RouteValues.TaskId,p.RequestParameters,ct);
break;
}
throw InvalidDispatch("DeleteByQueryRethrottle", p, new [] { POST }, "/_delete_by_query/{task_id}/_rethrottle");
}

internal TResponse DeleteScriptDispatch<TResponse>(IRequest<DeleteScriptRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
Expand Down
19 changes: 19 additions & 0 deletions src/Nest/_Generated/_Requests.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,25 @@ public DeleteByQueryRequest(Indices index, Types type) : base(r=>r.Required("ind
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IDeleteByQueryRethrottleRequest : IRequest<DeleteByQueryRethrottleRequestParameters>
{
TaskId TaskId { get; }
}
///<summary>Request parameters for DeleteByQueryRethrottle <pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html</pre></summary>
public partial class DeleteByQueryRethrottleRequest : PlainRequestBase<DeleteByQueryRethrottleRequestParameters>, IDeleteByQueryRethrottleRequest
{
protected IDeleteByQueryRethrottleRequest Self => this;
///<summary>/_delete_by_query/{task_id}/_rethrottle</summary>
///<param name="task_id">this parameter is required</param>
public DeleteByQueryRethrottleRequest(TaskId task_id) : base(r=>r.Required("task_id", task_id)){}
// values part of the url path
TaskId IDeleteByQueryRethrottleRequest.TaskId => Self.RouteValues.Get<TaskId>("task_id");

// Request parameters
///<summary>The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.</summary>
public long? RequestsPerSecond { get => Q<long?>("requests_per_second"); set => Q("requests_per_second", value); }
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IDeleteCalendarEventRequest : IRequest<DeleteCalendarEventRequestParameters>
{
Id CalendarId { get; }
Expand Down
23 changes: 23 additions & 0 deletions src/Tests/Tests.Configuration/tests.default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# IMPORTANT! This file is just a template and provides the default settings
# for the test runner. Do not edit this file in anyway unless you intend
# to change the defaults. To change your settings locally make a copy of
# this file in this directory and rename it to `tests.yaml` (which isn't
# tracked by git).

# mode either u (unit test), i (integration test) or m (mixed mode)
mode: m
# the elasticsearch version that should be started
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
elasticsearch_version: 6.6.2
# cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed)
# cluster_filter:
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running
#force_reseed: true
# do not spawn nodes as part of the test setup if we find a node is already running
# this is opt in during development in CI we never want to see our tests running against an already running node
test_against_already_running_elasticsearch: true
# elasticsearch_out_after_started: true

#random_source_serializer: true
#random_old_connection: true
#seed: 69819
3 changes: 2 additions & 1 deletion src/Tests/Tests/CodeStandards/NamingConventions.doc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public void ParityBetweenRequestsAndResponses()
typeof(IndicesShardStoresRequest),
typeof(RenderSearchTemplateRequest),
typeof(MultiSearchTemplateRequest),
typeof(CreateRequest<>)
typeof(CreateRequest<>),
typeof(DeleteByQueryRethrottleRequest) // uses ListTasksResponse
};

var types = typeof(IRequest).Assembly().GetTypes();
Expand Down
Loading