Skip to content

Commit f3b6c36

Browse files
committed
Update documentation
1 parent 9265d9c commit f3b6c36

32 files changed

+151
-44
lines changed

docs/aggregations/writing-aggregations.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ s => s
202202

203203
An advanced scenario may involve an existing collection of aggregation functions that should be set as aggregations
204204
on the request. Using LINQ's `.Aggregate()` method, each function can be applied to the aggregation descriptor
205-
`childAggs` below) in turn, returning the descriptor after each function application.
205+
(`childAggs` below) in turn, returning the descriptor after each function application.
206206

207207
[source,csharp]
208208
----
@@ -228,6 +228,7 @@ return s => s
228228
);
229229
----
230230
<1> a list of aggregation functions to apply
231+
231232
<2> Using LINQ's `Aggregate()` function to accumulate/apply all of the aggregation functions
232233

233234
[[handling-aggregate-response]]
@@ -271,5 +272,6 @@ var maxPerChild = childAggregation.Max("max_per_child");
271272
maxPerChild.Should().NotBeNull(); <2>
272273
----
273274
<1> Do something with the average per child. Here we just assert it's not null
275+
274276
<2> Do something with the max per child. Here we just assert it's not null
275277

docs/client-concepts/certificates/working-with-certificates.asciidoc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ validation will not be performed for HTTPS connections to *both* Elasticsearch *
4040
==== Validation configuration
4141

4242
It's possible to also set a callback per service endpoint with .NET, and both Elasticsearch.NET and NEST expose this through
43-
connection settings `ConnectionConfiguration` with Elasticsearch.Net and `ConnectionSettings` with NEST). You can do
43+
connection settings (`ConnectionConfiguration` with Elasticsearch.Net and `ConnectionSettings` with NEST). You can do
4444
your own validation in that handler or use one of the baked in handlers that we ship with out of the box, on the static class
4545
`CertificateValidations`.
4646

@@ -57,7 +57,7 @@ public class DenyAllCertificatesCluster : SslAndKpiXPackCluster
5757
{
5858
protected override ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
5959
.ServerCertificateValidationCallback((o, certificate, chain, errors) => false)
60-
.ServerCertificateValidationCallback(CertificateValidations.DenyAll); <1>
60+
.ServerCertificateValidationCallback(CertificateValidations.DenyAll); <1>
6161
}
6262
----
6363
<1> synonymous with the previous lambda expression
@@ -72,7 +72,7 @@ public class AllowAllCertificatesCluster : SslAndKpiXPackCluster
7272
{
7373
protected override ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
7474
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true)
75-
.ServerCertificateValidationCallback(CertificateValidations.AllowAll); <1>
75+
.ServerCertificateValidationCallback(CertificateValidations.AllowAll); <1>
7676
}
7777
----
7878
<1> synonymous with the previous lambda expression
@@ -82,7 +82,7 @@ public class AllowAllCertificatesCluster : SslAndKpiXPackCluster
8282
If your client application has access to the public CA certificate locally, Elasticsearch.NET and NEST ship with some handy helpers
8383
that can assert that a certificate the server presents is one that came from the local CA.
8484

85-
If you use X-Pack's {ref_current}/certutil.html[+certutil+ tool] to generate SSL certificates, the generated node certificate
85+
If you use X-Pack's {ref_current}/certutil.html[`certutil` tool] to generate SSL certificates, the generated node certificate
8686
does not include the CA in the certificate chain, in order to cut down on SSL handshake size. In those case you can use
8787
`CertificateValidations.AuthorityIsRoot` and pass it your local copy of the CA public key to assert that
8888
the certificate the server presented was generated using it
@@ -118,11 +118,11 @@ the local CA certificate is part of the chain that was used to generate the serv
118118
==== Client Certificates
119119

120120
X-Pack also allows you to configure a {xpack_current}/pki-realm.html[PKI realm] to enable user authentication
121-
through client certificates. The {ref_current}/certutil.html[+certutil+ tool] included with X-Pack allows you to
121+
through client certificates. The {ref_current}/certutil.html[`certutil` tool] included with X-Pack allows you to
122122
generate client certificates as well and assign the distinguished name (DN) of the
123123
certificate to a user with a certain role.
124124

125-
By default, the `certutil` tool only generates a public certificate `.cer`) and a private key `.key`. To authenticate with client certificates, you need to present both
125+
By default, the `certutil` tool only generates a public certificate (`.cer`) and a private key `.key`. To authenticate with client certificates, you need to present both
126126
as one certificate. The easiest way to do this is to generate a `pfx` or `p12` file from the `.cer` and `.key`
127127
and attach these to requests using `new X509Certificate(pathToPfx)`.
128128

@@ -136,12 +136,12 @@ You can set Client Certificates to use on all connections on `ConnectionSettings
136136
----
137137
public class PkiCluster : CertgenCaCluster
138138
{
139-
protected override ConnectionSettings Authenticate(ConnectionSettings s) => s <1>
139+
protected override ConnectionSettings Authenticate(ConnectionSettings s) => s <1>
140140
.ClientCertificate(
141141
ClientCertificate.LoadWithPrivateKey(
142-
this.Node.FileSystem.ClientCertificate, <2>
143-
this.Node.FileSystem.ClientPrivateKey, <3>
144-
"") <4>
142+
this.Node.FileSystem.ClientCertificate, <2>
143+
this.Node.FileSystem.ClientPrivateKey, <3>
144+
"") <4>
145145
);
146146
147147
//hide
@@ -153,8 +153,11 @@ public class PkiCluster : CertgenCaCluster
153153
}
154154
----
155155
<1> Set the client certificate on `ConnectionSettings`
156+
156157
<2> The path to the `.cer` file
158+
157159
<3> The path to the `.key` file
160+
158161
<4> The password for the private key
159162

160163
Or per request on `RequestConfiguration` which will take precedence over the ones defined on `ConnectionConfiguration`

docs/client-concepts/connection-pooling/building-blocks/connection-pooling.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ NEST can use to issue client calls on.
2020

2121
[IMPORTANT]
2222
--
23-
Despite the name, a connection pool in NEST is **not** like connection pooling that you may be familiar with from https://msdn.microsoft.com/en-us/library/bb399543(v=vs.110).aspx[interacting with a database using ADO.Net]; for example,
23+
Despite the name, a connection pool in NEST is **not** like connection pooling that you may be familiar with from
24+
https://msdn.microsoft.com/en-us/library/bb399543(v=vs.110).aspx[interacting with a database using ADO.Net]; for example,
2425
a connection pool in NEST is **not** responsible for managing an underlying pool of TCP connections to Elasticsearch,
2526
this is https://blogs.msdn.microsoft.com/adarshk/2005/01/02/understanding-system-net-connection-management-and-servicepointmanager/[handled by the ServicePointManager in Desktop CLR]
2627
and can be controlled by <<servicepoint-behaviour,changing the ServicePoint behaviour>> on `HttpConnection`.

docs/client-concepts/connection-pooling/building-blocks/request-pipelines.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ sniffingPipeline.FirstPoolUsageNeedsSniffing.Should().BeFalse();
101101

102102
==== Wait for first sniff
103103

104-
All threads wait for the sniff on startup to finish, waiting the request timeout period. A https://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim(v=vs.110).aspx[`SemaphoreSlim`]
104+
All threads wait for the sniff on startup to finish, waiting the request timeout period. A
105+
https://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim(v=vs.110).aspx[`SemaphoreSlim`]
105106
is used to block threads until the sniff finishes and waiting threads release the `SemaphoreSlim` appropriately.
106107

107108
We can demonstrate this with the following example. First, let's configure

docs/client-concepts/connection-pooling/exceptions/unexpected-exceptions.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ audit = await audit.TraceUnexpectedException(
5858
);
5959
----
6060
<1> set up a cluster with 10 nodes
61+
6162
<2> where node 2 on port 9201 always throws an exception
63+
6264
<3> The first call to 9200 returns a healthy response
65+
6366
<4> ...but the second call, to 9201, returns a bad response
6467

6568
Sometimes, an unexpected exception happens further down in the pipeline. In this scenario, we
@@ -98,7 +101,9 @@ audit = await audit.TraceUnexpectedException(
98101
);
99102
----
100103
<1> calls on 9200 set up to throw a `WebException`
104+
101105
<2> calls on 9201 set up to throw an `Exception`
106+
102107
<3> Assert that the audit trail for the client call includes the bad response from 9200 and 9201
103108

104109
An unexpected hard exception on ping and sniff is something we *do* try to recover from and failover to retrying on the next node.
@@ -143,6 +148,8 @@ audit = await audit.TraceUnexpectedException(
143148
);
144149
----
145150
<1> `InnerException` is the exception that brought the request down
151+
146152
<2> The hard exception that happened on ping is still available though
153+
147154
<3> An exception can be hard to relate back to a point in time, so the exception is also available on the audit trail
148155

docs/client-concepts/connection-pooling/exceptions/unrecoverable-exceptions.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ var audit = new Auditor(() => Framework.Cluster
8181
);
8282
----
8383
<1> Always succeed on ping
84+
8485
<2> ...but always fail on calls with a 401 Bad Authentication response
8586

8687
Now, let's make a client call. We'll see that the first audit event is a successful ping
@@ -101,7 +102,9 @@ audit = await audit.TraceElasticsearchException(
101102
);
102103
----
103104
<1> First call results in a successful ping
105+
104106
<2> Second call results in a bad response
107+
105108
<3> The reason for the bad response is Bad Authentication
106109

107110
When a bad authentication response occurs, the client attempts to deserialize the response body returned;
@@ -135,6 +138,7 @@ audit = await audit.TraceElasticsearchException(
135138
);
136139
----
137140
<1> Always return a 401 bad response with a HTML response on client calls
141+
138142
<2> Assert that the response body bytes are null
139143

140144
Now in this example, by turning on `DisableDirectStreaming()` on `ConnectionSettings`, we see the same behaviour exhibited
@@ -169,5 +173,6 @@ audit = await audit.TraceElasticsearchException(
169173
);
170174
----
171175
<1> Response bytes are set on the response
176+
172177
<2> Assert that the response contains `"nginx/"`
173178

docs/client-concepts/connection-pooling/request-overrides/disable-sniff-ping-per-request.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ audit = await audit.TraceCalls(
6565
);
6666
----
6767
<1> disable sniffing
68+
6869
<2> first call is a successful ping
70+
6971
<3> sniff on startup call happens here, on the second call
72+
7073
<4> No sniff on startup again
7174

7275
Now, let's disable pinging on the request
@@ -90,6 +93,7 @@ audit = await audit.TraceCall(
9093
);
9194
----
9295
<1> disable ping
96+
9397
<2> No ping after sniffing
9498

9599
Finally, let's demonstrate disabling both sniff and ping on the request
@@ -111,5 +115,6 @@ audit = await audit.TraceCall(
111115
);
112116
----
113117
<1> diable ping and sniff
118+
114119
<2> no ping or sniff before the call
115120

docs/client-concepts/connection-pooling/round-robin/skip-dead-nodes.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ await audit.TraceCalls(
140140
);
141141
----
142142
<1> The first call goes to 9200 which succeeds
143+
143144
<2> The 2nd call does a ping on 9201 because its used for the first time. It fails so we wrap over to node 9202
145+
144146
<3> The next call goes to 9203 which fails so we should wrap over
145147

146148
A cluster with 2 nodes where the second node fails on ping
@@ -190,5 +192,6 @@ await audit.TraceCalls(
190192
);
191193
----
192194
<1> All the calls fail
195+
193196
<2> After all our registered nodes are marked dead we want to sample a single dead node each time to quickly see if the cluster is back up. We do not want to retry all 4 nodes
194197

docs/client-concepts/connection-pooling/sniffing/role-detection.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ var audit = new Auditor(() => Framework.Cluster
138138
};
139139
----
140140
<1> Before the sniff, assert we only see three master only nodes
141+
141142
<2> After the sniff, assert we now know about the existence of 20 nodes.
142143

143144
After the sniff has happened on 9200 before the first API call, assert that the subsequent API
@@ -218,7 +219,9 @@ var audit = new Auditor(() => Framework.Cluster
218219
};
219220
----
220221
<1> for testing simplicity, disable pings
222+
221223
<2> We only want to execute API calls to nodes in rack_one
224+
222225
<3> After sniffing on startup, assert that the pool of nodes that the client will execute API calls against only contains the three nodes that are in `rack_one`
223226

224227
With the cluster set up, assert that the sniff happens on 9200 before the first API call
@@ -295,6 +298,8 @@ await audit.TraceUnexpectedElasticsearchException(new ClientCall
295298
});
296299
----
297300
<1> The audit trail indicates a sniff for the very first time on startup
301+
298302
<2> The sniff succeeds because the node predicate is ignored when sniffing
303+
299304
<3> when trying to do an actual API call however, the predicate prevents any nodes from being attempted
300305

docs/client-concepts/connection-pooling/sticky/sticky-sniffing-connection-pool.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ We set up a cluster with 4 nodes all having a different rack id
5656
our Sticky Sniffing Connection Pool gives the most weight to rack_2 and rack_11.
5757
We initially only seed nodes `9200-9203` in racks 0 to 3. So we should be sticky on rack_2.
5858
We setup node 9202 to fail after two client calls in which case we sniff and find nodes
59-
`9210-9213` in which case we should become sticky on rack_11.
59+
`9210-9213` in which case we should become sticky on rack_11.
6060

6161
[source,csharp]
6262
----

0 commit comments

Comments
 (0)