Skip to content

Add settings to create follow index and create auto follow pattern APIs #4947

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

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace Nest
{
Expand All @@ -22,6 +23,8 @@ public partial class CreateAutoFollowPatternRequest
public string RemoteCluster { get; set; }
/// <inheritdoc cref="IAutoFollowPattern.LeaderIndexPatterns"/>
public IEnumerable<string> LeaderIndexPatterns { get; set; }
/// <inheritdoc cref="IAutoFollowPattern.Settings"/>
public IIndexSettings Settings { get; set; }
/// <inheritdoc cref="IAutoFollowPattern.FollowIndexPattern"/>
public string FollowIndexPattern { get; set; }
/// <inheritdoc cref="IAutoFollowPattern.MaxReadRequestOperationCount"/>
Expand Down Expand Up @@ -52,6 +55,7 @@ public partial class CreateAutoFollowPatternDescriptor
string IAutoFollowPattern.RemoteCluster { get; set; }
IEnumerable<string> IAutoFollowPattern.LeaderIndexPatterns { get; set; }
string IAutoFollowPattern.FollowIndexPattern { get; set; }
IIndexSettings IAutoFollowPattern.Settings { get; set; }
int? IAutoFollowPattern.MaxReadRequestOperationCount { get; set; }
long? IAutoFollowPattern.MaxOutstandingReadRequests { get; set; }
string IAutoFollowPattern.MaxReadRequestSize { get; set; }
Expand All @@ -78,6 +82,10 @@ public CreateAutoFollowPatternDescriptor LeaderIndexPatterns(params string[] lea
public CreateAutoFollowPatternDescriptor FollowIndexPattern(string followIndexPattern) =>
Assign(followIndexPattern, (a, v) => a.FollowIndexPattern = v);

/// <inheritdoc cref="IAutoFollowPattern.Settings"/>
public CreateAutoFollowPatternDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
Assign(selector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value);

/// <inheritdoc cref="IAutoFollowPattern.MaxReadRequestOperationCount"/>
public CreateAutoFollowPatternDescriptor MaxReadRequestOperationCount(int? maxReadRequestOperationCount) =>
Assign(maxReadRequestOperationCount, (a, v) => a.MaxReadRequestOperationCount = v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ public interface IAutoFollowPattern
[DataMember(Name = "leader_index_patterns")]
IEnumerable<string> LeaderIndexPatterns { get; set; }

/// <summary>
/// Settings to override from the leader index.
/// Note that certain settings can not be overrode e.g. index.number_of_shards.
/// <para />
/// Valid in Elasticsearch 7.9.0+
/// </summary>
[DataMember(Name ="settings")]
IIndexSettings Settings { get; set; }

/// <summary>
/// the maximum number of outstanding reads requests from the remote cluster
/// </summary>
Expand Down Expand Up @@ -189,6 +198,9 @@ public class AutoFollowPattern : IAutoFollowPattern
/// <inheritdoc cref="IAutoFollowPattern.LeaderIndexPatterns" />
public IEnumerable<string> LeaderIndexPatterns { get; set; }

/// <inheritdoc cref="IAutoFollowPattern.Settings" />
public IIndexSettings Settings { get; set; }

/// <inheritdoc cref="IAutoFollowPattern.MaxOutstandingReadRequests" />
public long? MaxOutstandingReadRequests { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;

namespace Nest
{
Expand All @@ -22,6 +23,15 @@ public partial interface ICreateFollowIndexRequest
[DataMember(Name = "leader_index")]
IndexName LeaderIndex { get; set; }

/// <summary>
/// Settings to override from the leader index.
/// Note that certain settings can not be overrode e.g. index.number_of_shards.
/// <para />
/// Valid in Elasticsearch 7.9.0+
/// </summary>
[DataMember(Name ="settings")]
IIndexSettings Settings { get; set; }

/// <summary>the maximum number of operations to pull per read from the remote cluster </summary>
[DataMember(Name = "max_read_request_operation_count")]
long? MaxReadRequestOperationCount { get; set; }
Expand Down Expand Up @@ -85,6 +95,9 @@ public partial class CreateFollowIndexRequest
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
public IndexName LeaderIndex { get; set; }

/// <inheritdoc cref="ICreateFollowIndexRequest.Settings"/>
public IIndexSettings Settings { get; set; }

/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
public long? MaxReadRequestOperationCount { get; set; }

Expand Down Expand Up @@ -121,6 +134,7 @@ public partial class CreateFollowIndexDescriptor
{
string ICreateFollowIndexRequest.RemoteCluster { get; set; }
IndexName ICreateFollowIndexRequest.LeaderIndex { get; set; }
IIndexSettings ICreateFollowIndexRequest.Settings { get; set; }
long? ICreateFollowIndexRequest.MaxReadRequestOperationCount { get; set; }
long? ICreateFollowIndexRequest.MaxOutstandingReadRequests { get; set; }
string ICreateFollowIndexRequest.MaxRequestSize { get; set; }
Expand All @@ -138,6 +152,10 @@ public partial class CreateFollowIndexDescriptor
/// <inheritdoc cref="ICreateFollowIndexRequest.LeaderIndex"/>
public CreateFollowIndexDescriptor LeaderIndex(IndexName index) => Assign(index, (a, v) => a.LeaderIndex = v);

/// <inheritdoc cref="ICreateFollowIndexRequest.Settings"/>
public CreateFollowIndexDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
Assign(selector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value);

/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
public CreateFollowIndexDescriptor MaxReadRequestOperationCount(long? max) => Assign(max, (a, v) => a.MaxReadRequestOperationCount = v);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See the LICENSE file in the project root for more information

using System;
using Elasticsearch.Net;
using System.Collections.Generic;
using Elasticsearch.Net;
using Nest;
using Tests.Core.ManagedElasticsearch.Clusters;
using Tests.Framework.EndpointTests;
Expand All @@ -19,6 +20,10 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
{
follow_index_pattern = "y",
leader_index_patterns = new [] { "z" },
settings = new Dictionary<string, object>
{
["index.queries.cache.enabled"] = false
},
max_outstanding_read_requests = 100,
max_outstanding_write_requests = 101,
max_read_request_operation_count = 102,
Expand All @@ -38,6 +43,13 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
.RemoteCluster("x")
.FollowIndexPattern("y")
.LeaderIndexPatterns("z")
.Settings(s => s
.Queries(q => q
.Cache(qc => qc
.Enabled(false)
)
)
)
.MaxWriteBufferSize("1mb")
.MaxOutstandingReadRequests(100)
.MaxOutstandingWriteRequests( 101)
Expand All @@ -57,6 +69,16 @@ public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage
RemoteCluster = "x",
FollowIndexPattern = "y",
LeaderIndexPatterns = new []{"z"},
Settings = new IndexSettings
{
Queries = new QueriesSettings
{
Cache = new QueriesCacheSettings
{
Enabled = false
}
}
},
MaxWriteBufferSize = "1mb",
MaxOutstandingReadRequests = 100,
MaxOutstandingWriteRequests = 101,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
using Nest;
using Tests.Framework.EndpointTests;
using static Tests.Framework.EndpointTests.UrlTester;

namespace Tests.XPack.CrossClusterReplication.AutoFollow.CreateAutoFollowPattern
{
Expand All @@ -14,7 +15,7 @@ public class CreateAutoFollowPatternUrlTests : UrlTestsBase
[U] public override async Task Urls()
{
var name = "x";
await UrlTester.PUT($"/_ccr/auto_follow/{name}")
await PUT($"/_ccr/auto_follow/{name}")
.Fluent(c => c.CrossClusterReplication.CreateAutoFollowPattern(name, d => d))
.Request(c => c.CrossClusterReplication.CreateAutoFollowPattern(new CreateAutoFollowPatternRequest(name)))
.FluentAsync(c => c.CrossClusterReplication.CreateAutoFollowPatternAsync(name, d => d))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See the LICENSE file in the project root for more information

using System;
using Elasticsearch.Net;
using System.Collections.Generic;
using Elasticsearch.Net;
using Nest;
using Tests.Core.ManagedElasticsearch.Clusters;
using Tests.Framework.EndpointTests;
Expand All @@ -18,6 +19,10 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
protected override object ExpectJson { get; } = new
{
leader_index = "leader",
settings = new Dictionary<string, object>
{
["index.queries.cache.enabled"] = false
},
max_outstanding_read_requests = 100,
max_outstanding_write_requests = 101,
max_read_request_operation_count = 102,
Expand Down Expand Up @@ -46,6 +51,13 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
.MaxRequestSize("4mb")
.ReadPollTimeout("2m")
.LeaderIndex("leader")
.Settings(s => s
.Queries(q => q
.Cache(qc => qc
.Enabled(false)
)
)
)
;

protected override HttpMethod HttpMethod => HttpMethod.PUT;
Expand All @@ -64,6 +76,16 @@ public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : ba
MaxRequestSize = "4mb",
ReadPollTimeout = "2m",
LeaderIndex = "leader",
Settings = new IndexSettings
{
Queries = new QueriesSettings
{
Cache = new QueriesCacheSettings
{
Enabled = false
}
}
},
};

protected override bool SupportsDeserialization => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
using Nest;
using Tests.Framework.EndpointTests;
using static Tests.Framework.EndpointTests.UrlTester;

namespace Tests.XPack.CrossClusterReplication.Follow.CreateFollowIndex
{
Expand All @@ -14,7 +15,7 @@ public class CreateFollowIndexUrlTests : UrlTestsBase
[U] public override async Task Urls()
{
var name = "x";
await UrlTester.PUT($"/{name}/_ccr/follow")
await PUT($"/{name}/_ccr/follow")
.Fluent(c => c.CrossClusterReplication.CreateFollowIndex(name, d => d))
.Request(c => c.CrossClusterReplication.CreateFollowIndex(new CreateFollowIndexRequest(name)))
.FluentAsync(c => c.CrossClusterReplication.CreateFollowIndexAsync(name, d => d))
Expand Down