Skip to content

Commit 5b2f940

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 (cherry picked from commit 13c6a80)
1 parent c064cb9 commit 5b2f940

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
@@ -2201,6 +2201,51 @@ public class UpdateByQueryRequestParameters : RequestParameters<UpdateByQueryReq
22012201
///<summary>The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.</summary>
22022202
public long? Slices { get => Q<long?>("slices"); set => Q("slices", value); }
22032203
}
2204+
///<summary>Request options for CcrDeleteAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html</pre></summary>
2205+
public partial class DeleteAutoFollowPatternRequestParameters : RequestParameters<DeleteAutoFollowPatternRequestParameters>
2206+
{
2207+
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
2208+
}
2209+
///<summary>Request options for CcrFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</pre></summary>
2210+
public partial class CreateFollowIndexRequestParameters : RequestParameters<CreateFollowIndexRequestParameters>
2211+
{
2212+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
2213+
}
2214+
///<summary>Request options for CcrFollowStats<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</pre></summary>
2215+
public partial class FollowIndexStatsRequestParameters : RequestParameters<FollowIndexStatsRequestParameters>
2216+
{
2217+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2218+
}
2219+
///<summary>Request options for CcrGetAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</pre></summary>
2220+
public partial class GetAutoFollowPatternRequestParameters : RequestParameters<GetAutoFollowPatternRequestParameters>
2221+
{
2222+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2223+
}
2224+
///<summary>Request options for CcrPauseFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</pre></summary>
2225+
public partial class PauseFollowIndexRequestParameters : RequestParameters<PauseFollowIndexRequestParameters>
2226+
{
2227+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2228+
}
2229+
///<summary>Request options for CcrPutAutoFollowPattern<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html</pre></summary>
2230+
public partial class CreateAutoFollowPatternRequestParameters : RequestParameters<CreateAutoFollowPatternRequestParameters>
2231+
{
2232+
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
2233+
}
2234+
///<summary>Request options for CcrResumeFollow<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</pre></summary>
2235+
public partial class ResumeFollowIndexRequestParameters : RequestParameters<ResumeFollowIndexRequestParameters>
2236+
{
2237+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2238+
}
2239+
///<summary>Request options for CcrStats<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</pre></summary>
2240+
public partial class CcrStatsRequestParameters : RequestParameters<CcrStatsRequestParameters>
2241+
{
2242+
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
2243+
}
2244+
///<summary>Request options for CcrUnfollow<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current</pre></summary>
2245+
public partial class UnfollowIndexRequestParameters : RequestParameters<UnfollowIndexRequestParameters>
2246+
{
2247+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
2248+
}
22042249
///<summary>Request options for XpackGraphExplore<pre>https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html</pre></summary>
22052250
public class GraphExploreRequestParameters : RequestParameters<GraphExploreRequestParameters>
22062251
{

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
@@ -2408,6 +2408,88 @@ public partial interface IElasticLowLevelClient
24082408
///<param name="body">The search definition using the Query DSL</param>
24092409
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
24102410
Task<TResponse> UpdateByQueryAsync<TResponse>(string index, string type, PostData body, UpdateByQueryRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2411+
///<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>
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 CcrDeleteAutoFollowPattern<TResponse>(string name, DeleteAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2415+
///<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>
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> CcrDeleteAutoFollowPatternAsync<TResponse>(string name, DeleteAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2419+
///<summary>PUT on /{index}/_ccr/follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</para></summary>
2420+
///<param name="index">The name of the follower index</param>
2421+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2422+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2423+
TResponse CcrFollow<TResponse>(string index, PostData body, CreateFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2424+
///<summary>PUT on /{index}/_ccr/follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html</para></summary>
2425+
///<param name="index">The name of the follower index</param>
2426+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2427+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2428+
Task<TResponse> CcrFollowAsync<TResponse>(string index, PostData body, CreateFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2429+
///<summary>GET on /{index}/_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</para></summary>
2430+
///<param name="index">A comma-separated list of index patterns; use `_all` to perform the operation on all indices</param>
2431+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2432+
TResponse CcrFollowStats<TResponse>(string index, FollowIndexStatsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2433+
///<summary>GET on /{index}/_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html</para></summary>
2434+
///<param name="index">A comma-separated list of index patterns; use `_all` to perform the operation on all indices</param>
2435+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2436+
Task<TResponse> CcrFollowStatsAsync<TResponse>(string index, FollowIndexStatsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2437+
///<summary>GET on /_ccr/auto_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2438+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2439+
TResponse CcrGetAutoFollowPattern<TResponse>(GetAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2440+
///<summary>GET on /_ccr/auto_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html</para></summary>
2441+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2442+
Task<TResponse> CcrGetAutoFollowPatternAsync<TResponse>(GetAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2443+
///<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>
2444+
///<param name="name">The name of the auto follow pattern.</param>
2445+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2446+
TResponse CcrGetAutoFollowPattern<TResponse>(string name, GetAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2447+
///<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>
2448+
///<param name="name">The name of the auto follow pattern.</param>
2449+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2450+
Task<TResponse> CcrGetAutoFollowPatternAsync<TResponse>(string name, GetAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2451+
///<summary>POST on /{index}/_ccr/pause_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</para></summary>
2452+
///<param name="index">The name of the follower index that should pause following its leader index.</param>
2453+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2454+
TResponse CcrPauseFollow<TResponse>(string index, PauseFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2455+
///<summary>POST on /{index}/_ccr/pause_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html</para></summary>
2456+
///<param name="index">The name of the follower index that should pause following its leader index.</param>
2457+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2458+
Task<TResponse> CcrPauseFollowAsync<TResponse>(string index, PauseFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2459+
///<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>
2460+
///<param name="name">The name of the auto follow pattern.</param>
2461+
///<param name="body">The specification of the auto follow pattern</param>
2462+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2463+
TResponse CcrPutAutoFollowPattern<TResponse>(string name, PostData body, CreateAutoFollowPatternRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2464+
///<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>
2465+
///<param name="name">The name of the auto follow pattern.</param>
2466+
///<param name="body">The specification of the auto follow pattern</param>
2467+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2468+
Task<TResponse> CcrPutAutoFollowPatternAsync<TResponse>(string name, PostData body, CreateAutoFollowPatternRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2469+
///<summary>POST on /{index}/_ccr/resume_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</para></summary>
2470+
///<param name="index">The name of the follow index to resume following.</param>
2471+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2472+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2473+
TResponse CcrResumeFollow<TResponse>(string index, PostData body, ResumeFollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2474+
///<summary>POST on /{index}/_ccr/resume_follow <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html</para></summary>
2475+
///<param name="index">The name of the follow index to resume following.</param>
2476+
///<param name="body">The name of the leader index and other optional ccr related parameters</param>
2477+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2478+
Task<TResponse> CcrResumeFollowAsync<TResponse>(string index, PostData body, ResumeFollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2479+
///<summary>GET on /_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</para></summary>
2480+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2481+
TResponse CcrStats<TResponse>(CcrStatsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2482+
///<summary>GET on /_ccr/stats <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html</para></summary>
2483+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2484+
Task<TResponse> CcrStatsAsync<TResponse>(CcrStatsRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
2485+
///<summary>POST on /{index}/_ccr/unfollow <para>http://www.elastic.co/guide/en/elasticsearch/reference/current</para></summary>
2486+
///<param name="index">The name of the follower index that should be turned into a regular index.</param>
2487+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2488+
TResponse CcrUnfollow<TResponse>(string index, UnfollowIndexRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
2489+
///<summary>POST on /{index}/_ccr/unfollow <para>http://www.elastic.co/guide/en/elasticsearch/reference/current</para></summary>
2490+
///<param name="index">The name of the follower index that should be turned into a regular index.</param>
2491+
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2492+
Task<TResponse> CcrUnfollowAsync<TResponse>(string index, UnfollowIndexRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
24112493
///<summary>GET on /{index}/_xpack/graph/_explore <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html</para></summary>
24122494
///<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>
24132495
///<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)