Skip to content

Commit 13c6a80

Browse files
committed
Cross Cluster Replication support (#3533)
* Initial code gen for CCR * Created all the infra for the CCR api's (request/response/client methods) * Progress commit implementing the API and coordinated integration test for it * Add global ccr stats endpoint and tidy up implemented ccr api's thus far * Auto Follow CCR api's + tests * default keyword * CCR url and api tests * This API comments
1 parent a002b40 commit 13c6a80

File tree

63 files changed

+3383
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3383
-41
lines changed

src/CodeGeneration/ApiGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static void Main(string[] args)
4040
RestSpecDownloader.Download(downloadBranch);
4141

4242
ApiGenerator.Generate(downloadBranch, "Core", "Graph", "License", "Security", "Watcher", "Info", "MachineLearning", "Migration", "Sql",
43-
"Rollup", "Ssl");
43+
"Rollup", "Ccr", "Ssl");
4444
}
4545
}
4646
}

src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,6 +2187,51 @@ public partial class UpdateByQueryRequestParameters : RequestParameters<UpdateBy
21872187
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
21882188
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
21892189
}
2190+
///<summary>Request options for CcrDeleteAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html</pre></summary>
2191+
public partial class DeleteAutoFollowPatternRequestParameters : RequestParameters<DeleteAutoFollowPatternRequestParameters>
2192+
{
2193+
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
2194+
}
2195+
///<summary>Request options for CcrFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</pre></summary>
2196+
public partial class CreateFollowIndexRequestParameters : RequestParameters<CreateFollowIndexRequestParameters>
2197+
{
2198+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
2199+
}
2200+
///<summary>Request options for CcrFollowStats<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</pre></summary>
2201+
public partial class FollowIndexStatsRequestParameters : RequestParameters<FollowIndexStatsRequestParameters>
2202+
{
2203+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2204+
}
2205+
///<summary>Request options for CcrGetAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</pre></summary>
2206+
public partial class GetAutoFollowPatternRequestParameters : RequestParameters<GetAutoFollowPatternRequestParameters>
2207+
{
2208+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2209+
}
2210+
///<summary>Request options for CcrPauseFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</pre></summary>
2211+
public partial class PauseFollowIndexRequestParameters : RequestParameters<PauseFollowIndexRequestParameters>
2212+
{
2213+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2214+
}
2215+
///<summary>Request options for CcrPutAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html</pre></summary>
2216+
public partial class CreateAutoFollowPatternRequestParameters : RequestParameters<CreateAutoFollowPatternRequestParameters>
2217+
{
2218+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
2219+
}
2220+
///<summary>Request options for CcrResumeFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</pre></summary>
2221+
public partial class ResumeFollowIndexRequestParameters : RequestParameters<ResumeFollowIndexRequestParameters>
2222+
{
2223+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2224+
}
2225+
///<summary>Request options for CcrStats<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</pre></summary>
2226+
public partial class CcrStatsRequestParameters : RequestParameters<CcrStatsRequestParameters>
2227+
{
2228+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2229+
}
2230+
///<summary>Request options for CcrUnfollow<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current</pre></summary>
2231+
public partial class UnfollowIndexRequestParameters : RequestParameters<UnfollowIndexRequestParameters>
2232+
{
2233+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2234+
}
21902235
///<summary>Request options for XpackGraphExplore<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html</pre></summary>
21912236
public partial class GraphExploreRequestParameters : RequestParameters<GraphExploreRequestParameters>
21922237
{

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 102 additions & 0 deletions
Large diffs are not rendered by default.

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,88 @@ public partial interface IElasticLowLevelClient
23762376
///<param name="body">The search definition using the Query DSL</param>
23772377
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
23782378
Task<TResponse> UpdateByQueryAsync<TResponse>(string index, string type, PostData body, UpdateByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2379+
///<summary>DELETE on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html</para></summary>
2380+
///<param name="name">The name of the auto follow pattern.</param>
2381+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2382+
TResponse CcrDeleteAutoFollowPattern<TResponse>(string name, DeleteAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2383+
///<summary>DELETE on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html</para></summary>
2384+
///<param name="name">The name of the auto follow pattern.</param>
2385+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2386+
Task<TResponse> CcrDeleteAutoFollowPatternAsync<TResponse>(string name, DeleteAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2387+
///<summary>PUT on /{index}/_ccr/follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</para></summary>
2388+
///<param name="index">The name of the follower index</param>
2389+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2390+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2391+
TResponse CcrFollow<TResponse>(string index, PostData body, CreateFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2392+
///<summary>PUT on /{index}/_ccr/follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</para></summary>
2393+
///<param name="index">The name of the follower index</param>
2394+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2395+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2396+
Task<TResponse> CcrFollowAsync<TResponse>(string index, PostData body, CreateFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2397+
///<summary>GET on /{index}/_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</para></summary>
2398+
///<param name="index">A comma-separated list of index patterns; use `_all` to perform the operation on all indices</param>
2399+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2400+
TResponse CcrFollowStats<TResponse>(string index, FollowIndexStatsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2401+
///<summary>GET on /{index}/_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</para></summary>
2402+
///<param name="index">A comma-separated list of index patterns; use `_all` to perform the operation on all indices</param>
2403+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2404+
Task<TResponse> CcrFollowStatsAsync<TResponse>(string index, FollowIndexStatsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2405+
///<summary>GET on /_ccr/auto_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2406+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2407+
TResponse CcrGetAutoFollowPattern<TResponse>(GetAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2408+
///<summary>GET on /_ccr/auto_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2409+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2410+
Task<TResponse> CcrGetAutoFollowPatternAsync<TResponse>(GetAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2411+
///<summary>GET on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2412+
///<param name="name">The name of the auto follow pattern.</param>
2413+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2414+
TResponse CcrGetAutoFollowPattern<TResponse>(string name, GetAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2415+
///<summary>GET on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2416+
///<param name="name">The name of the auto follow pattern.</param>
2417+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2418+
Task<TResponse> CcrGetAutoFollowPatternAsync<TResponse>(string name, GetAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2419+
///<summary>POST on /{index}/_ccr/pause_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</para></summary>
2420+
///<param name="index">The name of the follower index that should pause following its leader index.</param>
2421+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2422+
TResponse CcrPauseFollow<TResponse>(string index, PauseFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2423+
///<summary>POST on /{index}/_ccr/pause_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</para></summary>
2424+
///<param name="index">The name of the follower index that should pause following its leader index.</param>
2425+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2426+
Task<TResponse> CcrPauseFollowAsync<TResponse>(string index, PauseFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2427+
///<summary>PUT on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html</para></summary>
2428+
///<param name="name">The name of the auto follow pattern.</param>
2429+
///<param name="body">The specification of the auto follow pattern</param>
2430+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2431+
TResponse CcrPutAutoFollowPattern<TResponse>(string name, PostData body, CreateAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2432+
///<summary>PUT on /_ccr/auto_follow/{name} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html</para></summary>
2433+
///<param name="name">The name of the auto follow pattern.</param>
2434+
///<param name="body">The specification of the auto follow pattern</param>
2435+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2436+
Task<TResponse> CcrPutAutoFollowPatternAsync<TResponse>(string name, PostData body, CreateAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2437+
///<summary>POST on /{index}/_ccr/resume_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</para></summary>
2438+
///<param name="index">The name of the follow index to resume following.</param>
2439+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2440+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2441+
TResponse CcrResumeFollow<TResponse>(string index, PostData body, ResumeFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2442+
///<summary>POST on /{index}/_ccr/resume_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</para></summary>
2443+
///<param name="index">The name of the follow index to resume following.</param>
2444+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2445+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2446+
Task<TResponse> CcrResumeFollowAsync<TResponse>(string index, PostData body, ResumeFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2447+
///<summary>GET on /_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</para></summary>
2448+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2449+
TResponse CcrStats<TResponse>(CcrStatsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2450+
///<summary>GET on /_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</para></summary>
2451+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2452+
Task<TResponse> CcrStatsAsync<TResponse>(CcrStatsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2453+
///<summary>POST on /{index}/_ccr/unfollow <para>http://www.elastic.co/guide/en/elasticsearch/reference/current</para></summary>
2454+
///<param name="index">The name of the follower index that should be turned into a regular index.</param>
2455+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2456+
TResponse CcrUnfollow<TResponse>(string index, UnfollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2457+
///<summary>POST on /{index}/_ccr/unfollow <para>http://www.elastic.co/guide/en/elasticsearch/reference/current</para></summary>
2458+
///<param name="index">The name of the follower index that should be turned into a regular index.</param>
2459+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2460+
Task<TResponse> CcrUnfollowAsync<TResponse>(string index, UnfollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
23792461
///<summary>GET on /{index}/_xpack/graph/_explore <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html</para></summary>
23802462
///<param name="index">A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</param>
23812463
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Nest
6+
{
7+
/// <summary>
8+
/// Simplifies the creation of remote cluster configuration, can be combined with a dictionary using the overloaded + operator
9+
/// </summary>
10+
public class RemoteClusterConfiguration : IsADictionaryBase<string, object>
11+
{
12+
private readonly Dictionary<string, object> _remoteDictionary =
13+
new Dictionary<string, object>();
14+
15+
public RemoteClusterConfiguration() =>
16+
BackingDictionary["cluster"] = new Dictionary<string, object>()
17+
{
18+
{ "remote", _remoteDictionary }
19+
};
20+
21+
public void Add(string name, params Uri[] seeds) =>
22+
Add(name, seeds.Select(u => $"{u.Host}:{u.Port}").ToArray());
23+
24+
public void Add(string name, params string[] seeds) =>
25+
_remoteDictionary[name] = new Dictionary<string, object>()
26+
{
27+
{ "seeds", seeds }
28+
};
29+
30+
public static Dictionary<string, object> operator +(RemoteClusterConfiguration left, IDictionary<string, object> right) => Combine(left, right);
31+
public static Dictionary<string, object> operator +(IDictionary<string, object> left, RemoteClusterConfiguration right) => Combine(left, right);
32+
33+
private static Dictionary<string, object> Combine(IDictionary<string, object> left, IDictionary<string, object> right)
34+
{
35+
if (left == null && right == null) return null;
36+
if (left == null) return new Dictionary<string, object>(right);
37+
if (right == null) return new Dictionary<string, object>(left);
38+
39+
foreach (var kv in right) left[kv.Key] = kv.Value;
40+
return new Dictionary<string, object>(left);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)