Skip to content

Commit 88c50a8

Browse files
committed
Merge branch 'master' into refactor/aggs-metadata
# Conflicts: # src/Tests/Aggregations/WritingAggregations.doc.cs
2 parents 7fe138e + 32f48b2 commit 88c50a8

38 files changed

+1034
-326
lines changed

docs/asciidoc/Aggregations/WritingAggregations.doc.asciidoc

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ It benefits from types that are carried over to sub aggregations
1212
[source, csharp]
1313
----
1414
s => s
15-
.Aggregations(aggs=>aggs
15+
.Aggregations(aggs => aggs
1616
.Children<CommitActivity>("name_of_child_agg", child => child
17-
.Aggregations(childAggs=>childAggs
18-
.Average("average_per_child", avg=>avg.Field(p=>p.ConfidenceFactor))
19-
.Max("max_per_child", avg=>avg.Field(p=>p.ConfidenceFactor))
17+
.Aggregations(childAggs => childAggs
18+
.Average("average_per_child", avg => avg.Field(p => p.ConfidenceFactor))
19+
.Max("max_per_child", avg => avg.Field(p => p.ConfidenceFactor))
2020
)
2121
)
2222
)
@@ -31,9 +31,9 @@ new SearchRequest<Project>
3131
{
3232
Aggregations = new ChildrenAggregation("name_of_child_agg", typeof(CommitActivity))
3333
{
34-
Aggregations =
35-
new AverageAggregation("average_per_child", "confidenceFactor") &&
36-
new MaxAggregation("max_per_child", "confidenceFactor")
34+
Aggregations =
35+
new AverageAggregation("average_per_child", "confidenceFactor")
36+
&& new MaxAggregation("max_per_child", "confidenceFactor")
3737
}
3838
}
3939
----
@@ -50,9 +50,32 @@ new SearchRequest<Project>
5050
{
5151
Aggregations = new ChildrenAggregation("name_of_child_agg", typeof(CommitActivity))
5252
{
53-
Aggregations =
54-
new AverageAggregation("average_per_child", Field<CommitActivity>(p=>p.ConfidenceFactor))
55-
&& new MaxAggregation("max_per_child", Field<CommitActivity>(p=>p.ConfidenceFactor))
53+
Aggregations =
54+
new AverageAggregation("average_per_child", Field<CommitActivity>(p => p.ConfidenceFactor))
55+
&& new MaxAggregation("max_per_child", Field<CommitActivity>(p => p.ConfidenceFactor))
5656
}
5757
}
5858
----
59+
An advanced scenario may involve an existing collection of aggregation functions that should be set as aggregations
60+
on the request. Using LINQ's `.Aggregate()` method, each function can be applied to the aggregation descriptor
61+
(`childAggs` below) in turn, returning the descriptor after each function application.
62+
63+
[source, csharp]
64+
----
65+
{
66+
var aggregations = new List<Func<AggregationContainerDescriptor<CommitActivity>, IAggregationContainer>>
67+
{
68+
a => a.Average("average_per_child", avg => avg.Field(p => p.ConfidenceFactor)),
69+
a => a.Max("max_per_child", avg => avg.Field(p => p.ConfidenceFactor))
70+
};
71+
72+
return s => s
73+
.Aggregations(aggs => aggs
74+
.Children<CommitActivity>("name_of_child_agg", child => child
75+
.Aggregations(childAggs =>
76+
aggregations.Aggregate(childAggs, (acc, agg) => { agg(acc); return acc; })
77+
)
78+
)
79+
);
80+
}
81+
----

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/ConnectionPooling.Doc.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ var pool = new SniffingConnectionPool(uris);
121121
----
122122
Or using an enumerable of `Node`
123123
A major benefit here is you can include known node roles when seeding
124-
NEST can use this information to favour sniffing on master eligable nodes first
125-
and take master only nodes out of rotation for issueing client calls on.
124+
NEST can use this information to favour sniffing on master eligible nodes first
125+
and take master only nodes out of rotation for issuing client calls on.
126126

127127
[source, csharp]
128128
----
@@ -132,7 +132,7 @@ var nodes = uris.Select(u=>new Node(u));
132132
----
133133
pool = new SniffingConnectionPool(nodes);
134134
----
135-
This type of pool is hardwirted to optout out sniffing
135+
This type of pool is hardwired to opt out of sniffing
136136

137137
[source, csharp]
138138
----

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/KeepingTrackOfNodes.Doc.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ var node = new Node(new Uri("http://localhost:9200"));
77
node.Uri.Should().NotBeNull();
88
node.Uri.Port.Should().Be(9200);
99
----
10-
By default master eligable and holds data is presumed to be true *
10+
By default master eligible and holds data is presumed to be true *
1111

1212
[source, csharp]
1313
----
14-
node.MasterEligable.Should().BeTrue();
14+
node.MasterEligible.Should().BeTrue();
1515
----
1616
[source, csharp]
1717
----
@@ -88,11 +88,11 @@ Nodes are considered equal if they have the same endpoint no matter what other m
8888

8989
[source, csharp]
9090
----
91-
var node = new Node(new Uri("http://localhost:9200")) { MasterEligable = false };
91+
var node = new Node(new Uri("http://localhost:9200")) { MasterEligible = false };
9292
----
9393
[source, csharp]
9494
----
95-
var nodeAsMaster = new Node(new Uri("http://localhost:9200")) { MasterEligable = true };
95+
var nodeAsMaster = new Node(new Uri("http://localhost:9200")) { MasterEligible = true };
9696
(node == nodeAsMaster).Should().BeTrue();
9797
(node != nodeAsMaster).Should().BeFalse();
9898
var uri = new Uri("http://localhost:9200");

docs/asciidoc/ClientConcepts/ConnectionPooling/Exceptions/UnexpectedExceptions.doc.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ can still see the audit trail for the whole coordinated request.
4343
----
4444
var audit = new Auditor(() => Framework.Cluster
4545
.Nodes(10)
46+
#if DOTNETCORE
47+
.ClientCalls(r => r.OnPort(9200).FailAlways(new System.Net.Http.HttpRequestException("recover")))
48+
#else
4649
.ClientCalls(r => r.OnPort(9200).FailAlways(new WebException("recover")))
50+
#endif
4751
.ClientCalls(r => r.OnPort(9201).FailAlways(new Exception("boom!")))
4852
.StaticConnectionPool()
4953
.Settings(s => s.DisablePing())

docs/asciidoc/ClientConcepts/ConnectionPooling/RoundRobin/RoundRobin.doc.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ comes 9200 again
4545

4646
[source, csharp]
4747
----
48-
startingPositions = new List<int>();
48+
var threadedStartPositions = new ConcurrentBag<int>();
4949
----
5050
[source, csharp]
5151
----
5252
var threads = Enumerable.Range(0, 20)
53-
.Select(i => CreateThreadCallingGetNext(pool, startingPositions))
53+
.Select(i => CreateThreadCallingGetNext(pool, threadedStartPositions))
5454
.ToList();
5555
t.Start();
5656
t.Join();
@@ -60,7 +60,7 @@ because we started `NumberOfNodes * 2` threads
6060

6161
[source, csharp]
6262
----
63-
var grouped = startingPositions.GroupBy(p => p);
63+
var grouped = threadedStartPositions.GroupBy(p => p).ToList();
6464
----
6565
[source, csharp]
6666
----

docs/asciidoc/ClientConcepts/ConnectionPooling/Sniffing/OnConnectionFailure.doc.asciidoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ This can be very handy to force a refresh of the pools known healthy node by ins
55
A sniff tries to get the nodes by asking each currently known node until one response.
66

77
Here we seed our connection with 5 known nodes 9200-9204 of which we think
8-
9202, 9203, 9204 are master eligable nodes. Our virtualized cluster will throw once when doing
8+
9202, 9203, 9204 are master eligible nodes. Our virtualized cluster will throw once when doing
99
a search on 9201. This should a sniff to be kicked off.
1010

1111
[source, csharp]
1212
----
1313
var audit = new Auditor(() => Framework.Cluster
1414
.Nodes(5)
15-
.MasterEligable(9202, 9203, 9204)
15+
.MasterEligible(9202, 9203, 9204)
1616
.ClientCalls(r => r.SucceedAlways())
1717
.ClientCalls(r => r.OnPort(9201).Fails(Once))
1818
----
@@ -24,7 +24,7 @@ still fails once
2424
----
2525
.Sniff(p => p.SucceedAlways(Framework.Cluster
2626
.Nodes(3)
27-
.MasterEligable(9200, 9202)
27+
.MasterEligible(9200, 9202)
2828
.ClientCalls(r => r.OnPort(9201).Fails(Once))
2929
----
3030
After this second failure on 9201 another sniff will be returned a cluster that no
@@ -34,7 +34,7 @@ longer fails but looks completely different (9210-9212) we should be able to han
3434
----
3535
.Sniff(s => s.SucceedAlways(Framework.Cluster
3636
.Nodes(3, 9210)
37-
.MasterEligable(9210, 9212)
37+
.MasterEligible(9210, 9212)
3838
.ClientCalls(r => r.SucceedAlways())
3939
.Sniff(r => r.SucceedAlways())
4040
))
@@ -102,15 +102,15 @@ Only we enable pinging (default is true) and make the ping fail
102102
----
103103
var audit = new Auditor(() => Framework.Cluster
104104
.Nodes(5)
105-
.MasterEligable(9202, 9203, 9204)
105+
.MasterEligible(9202, 9203, 9204)
106106
.Ping(r => r.OnPort(9201).Fails(Once))
107107
.Sniff(p => p.SucceedAlways(Framework.Cluster
108108
.Nodes(3)
109-
.MasterEligable(9200, 9202)
109+
.MasterEligible(9200, 9202)
110110
.Ping(r => r.OnPort(9201).Fails(Once))
111111
.Sniff(s => s.SucceedAlways(Framework.Cluster
112112
.Nodes(3, 9210)
113-
.MasterEligable(9210, 9211)
113+
.MasterEligible(9210, 9211)
114114
.Ping(r => r.SucceedAlways())
115115
.Sniff(r => r.SucceedAlways())
116116
))

docs/asciidoc/ClientConcepts/ConnectionPooling/Sniffing/OnStaleClusterState.doc.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ but without sniffing periodically it will never find the nodes that have been ad
99
----
1010
var audit = new Auditor(() => Framework.Cluster
1111
.Nodes(10)
12-
.MasterEligable(9202, 9203, 9204)
12+
.MasterEligible(9202, 9203, 9204)
1313
.ClientCalls(r => r.SucceedAlways())
1414
.Sniff(s => s.SucceedAlways(Framework.Cluster
1515
.Nodes(100)
16-
.MasterEligable(9202, 9203, 9204)
16+
.MasterEligible(9202, 9203, 9204)
1717
.ClientCalls(r => r.SucceedAlways())
1818
.Sniff(ss => ss.SucceedAlways(Framework.Cluster
1919
.Nodes(10)
20-
.MasterEligable(9202, 9203, 9204)
20+
.MasterEligible(9202, 9203, 9204)
2121
.ClientCalls(r => r.SucceedAlways())
2222
))
2323
))

docs/asciidoc/ClientConcepts/ConnectionPooling/Sniffing/OnStartup.doc.asciidoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ await audit.TraceCall(new ClientCall {
8282
});
8383
var audit = new Auditor(() => Framework.Cluster
8484
.Nodes(new[] {
85-
new Node(new Uri("http://localhost:9200")) { MasterEligable = false },
86-
new Node(new Uri("http://localhost:9201")) { MasterEligable = false },
87-
new Node(new Uri("http://localhost:9202")) { MasterEligable = true },
85+
new Node(new Uri("http://localhost:9200")) { MasterEligible = false },
86+
new Node(new Uri("http://localhost:9201")) { MasterEligible = false },
87+
new Node(new Uri("http://localhost:9202")) { MasterEligible = true },
8888
})
8989
.Sniff(s => s.Succeeds(Always))
9090
.SniffingConnectionPool()
@@ -98,9 +98,9 @@ await audit.TraceCall(new ClientCall {
9898
});
9999
var audit = new Auditor(() => Framework.Cluster
100100
.Nodes(new[] {
101-
new Node(new Uri("http://localhost:9200")) { MasterEligable = true },
102-
new Node(new Uri("http://localhost:9201")) { MasterEligable = true },
103-
new Node(new Uri("http://localhost:9202")) { MasterEligable = false },
101+
new Node(new Uri("http://localhost:9200")) { MasterEligible = true },
102+
new Node(new Uri("http://localhost:9201")) { MasterEligible = true },
103+
new Node(new Uri("http://localhost:9202")) { MasterEligible = false },
104104
})
105105
.Sniff(s => s.Fails(Always))
106106
.Sniff(s => s.OnPort(9202).Succeeds(Always))

docs/asciidoc/ClientConcepts/ConnectionPooling/Sniffing/RoleDetection.doc.asciidoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
== Sniffing role detection
22

3-
When we sniff the custer state we detect the role of the node whether its master eligable and holds data
3+
When we sniff the custer state we detect the role of the node whether its master eligible and holds data
44
We use this information when selecting a node to perform an API call on.
55

66
[source, csharp]
@@ -9,7 +9,7 @@ var audit = new Auditor(() => Framework.Cluster
99
.Nodes(10)
1010
.Sniff(s => s.Fails(Always))
1111
.Sniff(s => s.OnPort(9202)
12-
.Succeeds(Always, Framework.Cluster.Nodes(8).MasterEligable(9200, 9201, 9202))
12+
.Succeeds(Always, Framework.Cluster.Nodes(8).MasterEligible(9200, 9201, 9202))
1313
)
1414
.SniffingConnectionPool()
1515
.AllDefaults()
@@ -19,21 +19,21 @@ var audit = new Auditor(() => Framework.Cluster
1919
{
2020
pool.Should().NotBeNull();
2121
pool.Nodes.Should().HaveCount(10);
22-
pool.Nodes.Where(n => n.MasterEligable).Should().HaveCount(10);
22+
pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(10);
2323
},
2424
AssertPoolAfterCall = (pool) =>
2525
{
2626
pool.Should().NotBeNull();
2727
pool.Nodes.Should().HaveCount(8);
28-
pool.Nodes.Where(n => n.MasterEligable).Should().HaveCount(3);
28+
pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(3);
2929
}
3030
};
3131
pool.Should().NotBeNull();
3232
pool.Nodes.Should().HaveCount(10);
33-
pool.Nodes.Where(n => n.MasterEligable).Should().HaveCount(10);
33+
pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(10);
3434
pool.Should().NotBeNull();
3535
pool.Nodes.Should().HaveCount(8);
36-
pool.Nodes.Where(n => n.MasterEligable).Should().HaveCount(3);
36+
pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(3);
3737
await audit.TraceStartup();
3838
var audit = new Auditor(() => Framework.Cluster
3939
.Nodes(10)
@@ -67,10 +67,10 @@ pool.Nodes.Should().HaveCount(8);
6767
pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(5);
6868
await audit.TraceStartup();
6969
var node = SniffAndReturnNode();
70-
node.MasterEligable.Should().BeTrue();
70+
node.MasterEligible.Should().BeTrue();
7171
node.HoldsData.Should().BeFalse();
7272
node = await SniffAndReturnNodeAsync();
73-
node.MasterEligable.Should().BeTrue();
73+
node.MasterEligible.Should().BeTrue();
7474
node.HoldsData.Should().BeFalse();
7575
var pipeline = CreatePipeline();
7676
pipeline.Sniff();

0 commit comments

Comments
 (0)