Skip to content

Commit 853a94f

Browse files
committed
Progress commit implementing the API and coordinated integration test for it
1 parent eb7d6a9 commit 853a94f

21 files changed

+1006
-110
lines changed

src/Nest/IndexModules/IndexSettings/Settings/IndexSettings.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public interface IIndexSettings : IDynamicIndexSettings
2828
/// </summary>
2929
int? NumberOfShards { get; set; }
3030

31-
/// <summary>
32-
/// Settings associated with queries.
33-
/// </summary>
31+
/// <summary> Settings associated with queries. </summary>
3432
IQueriesSettings Queries { get; set; }
3533

3634
/// <summary>
@@ -44,6 +42,9 @@ public interface IIndexSettings : IDynamicIndexSettings
4442
/// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/index-modules-index-sorting.html
4543
/// </summary>
4644
ISortingSettings Sorting { get; set; }
45+
46+
/// <summary> Soft delete settings for the index </summary>
47+
ISoftDeleteSettings SoftDeletes { get; set; }
4748
}
4849

4950
/// <inheritdoc cref="IIndexSettings" />
@@ -70,6 +71,9 @@ public IndexSettings(IDictionary<string, object> container) : base(container) {
7071

7172
/// <inheritdoc />
7273
public ISortingSettings Sorting { get; set; }
74+
75+
/// <inheritdoc />
76+
public ISoftDeleteSettings SoftDeletes { get; set; }
7377
}
7478

7579
/// <inheritdoc cref="IIndexSettings" />
@@ -100,5 +104,9 @@ public IndexSettingsDescriptor Queries(Func<QueriesSettingsDescriptor, IQueriesS
100104
/// <inheritdoc cref="IIndexSettings.Sorting" />
101105
public IndexSettingsDescriptor Sorting<T>(Func<SortingSettingsDescriptor<T>, ISortingSettings> selector) where T : class =>
102106
Assign(a => a.Sorting = selector?.Invoke(new SortingSettingsDescriptor<T>()));
107+
108+
/// <inheritdoc cref="IIndexSettings.SoftDeletes" />
109+
public IndexSettingsDescriptor SoftDeletes(Func<SoftDeleteSettingsDescriptor, ISoftDeleteSettings> selector) =>
110+
Assign(a => a.SoftDeletes = selector?.Invoke(new SoftDeleteSettingsDescriptor()));
103111
}
104112
}

src/Nest/IndexModules/IndexSettings/Settings/IndexSettingsConverter.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ void Set(string knownKey, object newValue)
9696
Set(NumberOfShards, indexSettings?.NumberOfShards);
9797
Set(NumberOfRoutingShards, indexSettings?.NumberOfRoutingShards);
9898
Set(RoutingPartitionSize, indexSettings?.RoutingPartitionSize);
99+
if (indexSettings?.SoftDeletes != null)
100+
{
101+
Set(SoftDeletesEnabled, indexSettings?.SoftDeletes?.Enabled);
102+
Set(SoftDeletesRetentionOperations, indexSettings?.SoftDeletes?.Retention?.Operations);
103+
}
99104

100105
if (indexSettings?.Sorting != null)
101106
{
@@ -205,14 +210,10 @@ private static void SetKnownIndexSettings(JsonReader reader, JsonSerializer seri
205210
v => fetch.ThresholdTrace = v);
206211

207212
var indexing = s.SlowLog.Indexing = new SlowLogIndexing();
208-
Set<Time>(s, settings, SlowlogIndexingThresholdFetchWarn,
209-
v => indexing.ThresholdWarn = v);
210-
Set<Time>(s, settings, SlowlogIndexingThresholdFetchInfo,
211-
v => indexing.ThresholdInfo = v);
212-
Set<Time>(s, settings, SlowlogIndexingThresholdFetchDebug,
213-
v => indexing.ThresholdDebug = v);
214-
Set<Time>(s, settings, SlowlogIndexingThresholdFetchTrace,
215-
v => indexing.ThresholdTrace = v);
213+
Set<Time>(s, settings, SlowlogIndexingThresholdFetchWarn, v => indexing.ThresholdWarn = v);
214+
Set<Time>(s, settings, SlowlogIndexingThresholdFetchInfo, v => indexing.ThresholdInfo = v);
215+
Set<Time>(s, settings, SlowlogIndexingThresholdFetchDebug, v => indexing.ThresholdDebug = v);
216+
Set<Time>(s, settings, SlowlogIndexingThresholdFetchTrace, v => indexing.ThresholdTrace = v);
216217
Set<LogLevel?>(s, settings, SlowlogIndexingLevel, v => indexing.LogLevel = v);
217218
Set<int?>(s, settings, SlowlogIndexingSource, v => indexing.Source = v);
218219
Set<int?>(s, settings, NumberOfShards, v => s.NumberOfShards = v);
@@ -230,6 +231,11 @@ private static void SetKnownIndexSettings(JsonReader reader, JsonSerializer seri
230231
var queriesCache = s.Queries.Cache = new QueriesCacheSettings();
231232
Set<bool?>(s, settings, QueriesCacheEnabled, v => queriesCache.Enabled = v);
232233

234+
var softDeletes = s.SoftDeletes = new SoftDeleteSettings();
235+
Set<bool?>(s, settings, SoftDeletesEnabled, v => softDeletes.Enabled = v);
236+
var softDeletesRetention = s.SoftDeletes.Retention = new SoftDeleteRetentionSettings();
237+
Set<long?>(s, settings, SoftDeletesEnabled, v => softDeletesRetention.Operations = v);
238+
233239
IDictionary<string, object> dict = s;
234240
foreach (var kv in settings)
235241
{

src/Nest/IndexModules/IndexSettings/Settings/UpdatableIndexSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public static class UpdatableIndexSettings
3030

3131
public const string QueriesCacheEnabled = "index.queries.cache.enabled";
3232

33+
public const string SoftDeletesEnabled = "index.soft_deletes.enabled";
34+
public const string SoftDeletesRetentionOperations = "index.soft_deletes.retention.operations";
35+
3336
public const string RecoveryInitialShards = "index.recovery.initial_shards";
3437
public const string RefreshInterval = "index.refresh_interval";
3538

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace Nest
2+
{
3+
public interface ISoftDeleteRetentionSettings
4+
{
5+
/// <summary> How many operations should be retained </summary>
6+
long? Operations { get; set; }
7+
}
8+
9+
public class SoftDeleteRetentionSettings : ISoftDeleteRetentionSettings
10+
{
11+
/// <inheritdoc see cref="ISoftDeleteRetentionSettings.Operations"/>
12+
public long? Operations { get; set; }
13+
}
14+
15+
public class SoftDeleteRetentionSettingsDescriptor : DescriptorBase<SoftDeleteRetentionSettingsDescriptor, ISoftDeleteRetentionSettings>, ISoftDeleteRetentionSettings
16+
{
17+
long? ISoftDeleteRetentionSettings.Operations { get; set; }
18+
19+
/// <inheritdoc see cref="ISoftDeleteRetentionSettings.Operations"/>
20+
public SoftDeleteRetentionSettingsDescriptor Operations(long? operations) => Assign(a => a.Operations = operations);
21+
}
22+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
namespace Nest
4+
{
5+
public interface ISoftDeleteSettings
6+
{
7+
/// <summary> Enables soft deletes on the index</summary>
8+
bool? Enabled { get; set; }
9+
/// <summary> Configure the retention of soft deletes on the index</summary>
10+
ISoftDeleteRetentionSettings Retention { get; set; }
11+
}
12+
13+
public class SoftDeleteSettings : ISoftDeleteSettings
14+
{
15+
/// <inheritdoc see cref="ISoftDeleteSettings.Retention"/>
16+
public ISoftDeleteRetentionSettings Retention { get; set; }
17+
18+
/// <inheritdoc see cref="ISoftDeleteSettings.Enabled"/>
19+
public bool? Enabled { get; set; }
20+
}
21+
22+
public class SoftDeleteSettingsDescriptor : DescriptorBase<SoftDeleteSettingsDescriptor, ISoftDeleteSettings>, ISoftDeleteSettings
23+
{
24+
bool? ISoftDeleteSettings.Enabled { get; set; }
25+
ISoftDeleteRetentionSettings ISoftDeleteSettings.Retention { get; set; }
26+
27+
/// <inheritdoc see cref="ISoftDeleteSettings.Retention"/>
28+
public SoftDeleteSettingsDescriptor Retention(Func<SoftDeleteRetentionSettingsDescriptor, ISoftDeleteRetentionSettings> selector) =>
29+
Assign(a => a.Retention = selector.Invoke(new SoftDeleteRetentionSettingsDescriptor()));
30+
31+
/// <inheritdoc see cref="ISoftDeleteSettings.Enabled"/>
32+
public SoftDeleteSettingsDescriptor Enabled(bool? enabled = true) => Assign(a => a.Enabled = enabled);
33+
}
34+
}
Lines changed: 148 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,170 @@
11
using System;
2+
using Elasticsearch.Net;
23
using Newtonsoft.Json;
34

45
namespace Nest
56
{
7+
/// <summary>
8+
/// This API creates a new follower index that is configured to follow the referenced leader index.
9+
/// When this API returns, the follower index exists, and cross-cluster replication starts replicating operations
10+
/// from the leader index to the follower index
11+
/// </summary>
612
[MapsApi("ccr.follow.json")]
713
[ContractJsonConverter(typeof(ReadAsTypeJsonConverter<CreateFollowIndexRequest>))]
814
public partial interface ICreateFollowIndexRequest
915
{
16+
/// <summary> the remote cluster containing the leader index <para>
17+
[JsonProperty("remote_cluster")]
18+
string RemoteCluster { get; set; }
19+
20+
/// <summary> the name of the index in the leader cluster to follow </summary>
21+
[JsonProperty("leader_index")]
22+
IndexName LeaderIndex { get; set; }
23+
24+
/// <summary>the maximum number of operations to pull per read from the remote cluster </summary>
25+
[JsonProperty("max_read_request_operation_count")]
26+
long? MaxReadRequestOperationCount { get; set; }
27+
28+
/// <summary>the maximum number of outstanding reads requests from the remote cluster</summary>
29+
[JsonProperty("max_outstanding_read_requests")]
30+
long? MaxOutstandingReadRequests { get; set; }
31+
32+
/// <summary>the maximum size in bytes of per read of a batch of operations pulled from the remote cluster</summary>
33+
[JsonProperty("max_read_request_size")]
34+
string MaxRequestSize { get; set; }
35+
36+
/// <summary>the maximum number of operations per bulk write request executed on the follower</summary>
37+
[JsonProperty("max_write_request_operation_count")]
38+
long? MaxWriteRequestOperationCount { get; set; }
39+
40+
/// <summary>the maximum total bytes of operations per bulk write request executed on the follower</summary>
41+
[JsonProperty("max_write_request_size")]
42+
string MaxWriteRequestSize { get; set; }
43+
44+
/// <summary>the maximum number of outstanding write requests on the follower</summary>
45+
[JsonProperty("max_outstanding_write_requests")]
46+
long? MaxOutstandingWriteRequests { get; set; }
47+
48+
/// <summary>
49+
/// the maximum number of operations that can be queued for writing; when this limit is reached, reads from
50+
/// the remote cluster will be deferred until the number of queued operations goes below the limit
51+
/// </summary>
52+
[JsonProperty("max_write_buffer_count")]
53+
long? MaxWriteBufferCount { get; set; }
54+
55+
/// <summary>
56+
/// the maximum total bytes of operations that can be queued for writing; when this limit is reached, reads
57+
/// from the remote cluster will be deferred until the total bytes of queued operations goes below the limit
58+
/// </summary>
59+
[JsonProperty("max_write_buffer_size")]
60+
string MaxWriteBufferSize { get; set; }
61+
62+
/// <summary>
63+
/// the maximum time to wait before retrying an operation that failed exceptionally; an exponential backoff
64+
/// strategy is employed when retrying
65+
/// </summary>
66+
[JsonProperty("max_retry_delay")]
67+
Time MaxRetryDelay { get; set; }
68+
1069
/// <summary>
11-
///
12-
/// <para>
13-
/// </para>
70+
/// the maximum time to wait for new operations on the remote cluster when the follower index is synchronized with the
71+
/// leader index; when the timeout has elapsed, the poll for operations will return to the follower so that it can
72+
/// update some statistics, and then the follower will immediately attempt to read from the leader again
1473
/// </summary>
15-
[JsonProperty("cursor")]
16-
string Cursor { get; set; }
74+
[JsonProperty("read_poll_timeout")]
75+
Time ReadPollTimeout { get; set; }
1776
}
1877

78+
/// <inheritdoc cref="ICreateFollowIndexRequest"/>
1979
public partial class CreateFollowIndexRequest
2080
{
21-
/// <inheritdoc cref="ICreateFollowIndexRequest.Cursor" />
22-
public string Cursor { get; set; }
81+
/// <inheritdoc cref="ICreateFollowIndexRequest.RemoteCluster"/>
82+
public string RemoteCluster { get; set; }
83+
84+
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
85+
public IndexName LeaderIndex { get; set; }
86+
87+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
88+
public long? MaxReadRequestOperationCount { get; set; }
89+
90+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingReadRequests"/>
91+
public long? MaxOutstandingReadRequests { get; set; }
92+
93+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRequestSize"/>
94+
public string MaxRequestSize { get; set; }
95+
96+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestOperationCount"/>
97+
public long? MaxWriteRequestOperationCount { get; set; }
98+
99+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestSize"/>
100+
public string MaxWriteRequestSize { get; set; }
101+
102+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingWriteRequests"/>
103+
public long? MaxOutstandingWriteRequests { get; set; }
104+
105+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferCount"/>
106+
public long? MaxWriteBufferCount { get; set; }
107+
108+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferSize"/>
109+
public string MaxWriteBufferSize { get; set; }
110+
111+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRetryDelay"/>
112+
public Time MaxRetryDelay { get; set; }
113+
114+
/// <inheritdoc cref="ICreateFollowIndexRequest.ReadPollTimeout"/>
115+
public Time ReadPollTimeout { get; set; }
23116
}
24117

118+
/// <inheritdoc cref="ICreateFollowIndexRequest"/>
25119
public partial class CreateFollowIndexDescriptor
26120
{
27-
string ICreateFollowIndexRequest.Cursor { get; set; }
121+
string ICreateFollowIndexRequest.RemoteCluster { get; set; }
122+
IndexName ICreateFollowIndexRequest.LeaderIndex { get; set; }
123+
long? ICreateFollowIndexRequest.MaxReadRequestOperationCount { get; set; }
124+
long? ICreateFollowIndexRequest.MaxOutstandingReadRequests { get; set; }
125+
string ICreateFollowIndexRequest.MaxRequestSize { get; set; }
126+
long? ICreateFollowIndexRequest.MaxWriteRequestOperationCount { get; set; }
127+
string ICreateFollowIndexRequest.MaxWriteRequestSize { get; set; }
128+
long? ICreateFollowIndexRequest.MaxOutstandingWriteRequests { get; set; }
129+
long? ICreateFollowIndexRequest.MaxWriteBufferCount { get; set; }
130+
string ICreateFollowIndexRequest.MaxWriteBufferSize { get; set; }
131+
Time ICreateFollowIndexRequest.MaxRetryDelay { get; set; }
132+
Time ICreateFollowIndexRequest.ReadPollTimeout { get; set; }
133+
134+
/// <inheritdoc cref="ICreateFollowIndexRequest.RemoteCluster"/>
135+
public CreateFollowIndexDescriptor RemoteCluster(string remoteCluster) => Assign(a => a.RemoteCluster = remoteCluster);
136+
137+
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
138+
public CreateFollowIndexDescriptor LeaderIndex(IndexName index) => Assign(a => a.LeaderIndex = index);
139+
140+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
141+
public CreateFollowIndexDescriptor MaxReadRequestOperationCount(long? max) => Assign(a => a.MaxReadRequestOperationCount = max);
142+
143+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingReadRequests"/>
144+
public CreateFollowIndexDescriptor MaxOutstandingReadRequests(long? max) => Assign(a => a.MaxOutstandingReadRequests = max);
145+
146+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRequestSize"/>
147+
public CreateFollowIndexDescriptor MaxRequestSize(string maxRequestSize) => Assign(a => a.MaxRequestSize = maxRequestSize);
148+
149+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestOperationCount"/>
150+
public CreateFollowIndexDescriptor MaxWriteRequestOperationCount(long? max) => Assign(a => a.MaxWriteRequestOperationCount = max);
151+
152+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestSize"/>
153+
public CreateFollowIndexDescriptor MaxWriteRequestSize(string maxSize) => Assign(a => a.MaxWriteRequestSize = maxSize);
154+
155+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingWriteRequests"/>
156+
public CreateFollowIndexDescriptor MaxOutstandingWriteRequests(long? max) => Assign(a => a.MaxOutstandingWriteRequests = max);
157+
158+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferCount"/>
159+
public CreateFollowIndexDescriptor MaxWriteBufferCount(long? max) => Assign(a => a.MaxWriteBufferCount = max);
160+
161+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferSize"/>
162+
public CreateFollowIndexDescriptor MaxWriteBufferSize(string max) => Assign(a => a.MaxWriteBufferSize = max);
163+
164+
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRetryDelay"/>
165+
public CreateFollowIndexDescriptor MaxRetryDelay(Time maxRetryDelay) => Assign(a => a.MaxRetryDelay = maxRetryDelay);
28166

29-
/// <inheritdoc cref="ICreateFollowIndexRequest.Cursor" />
30-
public CreateFollowIndexDescriptor Cursor(string cursor) => Assign(a => a.Cursor = cursor);
167+
/// <inheritdoc cref="ICreateFollowIndexRequest.ReadPollTimeout"/>
168+
public CreateFollowIndexDescriptor ReadPollTimeout(Time readPollTimeout) => Assign(a => a.ReadPollTimeout = readPollTimeout);
31169
}
32170
}

src/Nest/XPack/CrossClusterReplication/Follow/CreateFollowIndex/CreateFollowIndexResponse.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ namespace Nest
55
{
66
public interface ICreateFollowIndexResponse : IResponse
77
{
8-
/// <summary>
9-
///
10-
/// </summary>
11-
[JsonProperty("columns")]
12-
IReadOnlyCollection<SqlColumn> Columns { get; }
8+
[JsonProperty("follow_index_created")]
9+
bool FollowIndexCreated { get; }
10+
11+
[JsonProperty("follow_index_shards_acked")]
12+
bool FollowIndexShardsAcked { get; }
13+
14+
[JsonProperty("index_following_started")]
15+
bool IndexFollowingStarted { get; }
1316
}
1417

1518
public class CreateFollowIndexResponse : ResponseBase, ICreateFollowIndexResponse
1619
{
17-
/// <inheritdoc cref="ICreateFollowIndexResponse.Columns" />
18-
public IReadOnlyCollection<SqlColumn> Columns { get; internal set; } = EmptyReadOnly<SqlColumn>.Collection;
20+
public bool FollowIndexCreated { get; internal set; }
21+
public bool FollowIndexShardsAcked { get; internal set; }
22+
public bool IndexFollowingStarted { get; internal set; }
1923
}
2024
}

0 commit comments

Comments
 (0)