|
| 1 | +:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.x |
| 2 | + |
| 3 | +:github: https://github.com/elastic/elasticsearch-net |
| 4 | + |
| 5 | +:nuget: https://www.nuget.org/packages |
| 6 | + |
| 7 | +//// |
| 8 | +IMPORTANT NOTE |
| 9 | +============== |
| 10 | +This file has been generated from https://github.com/elastic/elasticsearch-net/tree/7.x/src/Tests/Tests/ClientConcepts/ConnectionPooling/ProductChecking/ProductCheckAtStartup.doc.cs. |
| 11 | +If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file, |
| 12 | +please modify the original csharp file found at the link and submit the PR with that change. Thanks! |
| 13 | +//// |
| 14 | + |
| 15 | +[[product-check-at-startup]] |
| 16 | +== Product check at startup |
| 17 | + |
| 18 | +Since v7.14.0, the client performs a required product check before the first call. |
| 19 | +This pre-flight product check allows the client to establish the version of Elasticsearch that it is communicating with. |
| 20 | + |
| 21 | +The product check requires one additional HTTP request to be sent to the server as part of the request pipeline before |
| 22 | +the main API call is sent. In most cases, this will succeed during the very first API call that the client sends. |
| 23 | +Once the product check succeeds, no further product check HTTP requests are sent for subsequent API calls. |
| 24 | + |
| 25 | +[source,csharp] |
| 26 | +---- |
| 27 | +var audit = new Auditor(() => VirtualClusterWith |
| 28 | + .Nodes(1) |
| 29 | + .ClientCalls(r => r.SucceedAlways()) |
| 30 | + .StaticConnectionPool() |
| 31 | + .Settings(s => s.DisablePing()) |
| 32 | +); |
| 33 | +
|
| 34 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 35 | + new ClientCall() { |
| 36 | + { ProductCheckOnStartup }, |
| 37 | + { ProductCheckSuccess, 9200 }, <1> |
| 38 | + { HealthyResponse, 9200 } <2> |
| 39 | + }, |
| 40 | + new ClientCall() { |
| 41 | + { HealthyResponse, 9200 } <3> |
| 42 | + } |
| 43 | +); |
| 44 | +---- |
| 45 | +<1> as this is the first call, the product check is executed |
| 46 | +<2> following the product check, the actual request is sent |
| 47 | +<3> subsequent calls no longer perform product check |
| 48 | + |
| 49 | +Here's an example with a single node cluster which fails for some reason during the first product check attempt. |
| 50 | + |
| 51 | +[source,csharp] |
| 52 | +---- |
| 53 | +var audit = new Auditor(() => VirtualClusterWith |
| 54 | + .Nodes(1, productCheckAlwaysSucceeds: false) |
| 55 | + .ProductCheck(r => r.Fails(TimesHelper.Once)) |
| 56 | + .ProductCheck(r => r.SucceedAlways()) |
| 57 | + .ClientCalls(r => r.SucceedAlways()) |
| 58 | + .StaticConnectionPool() |
| 59 | + .Settings(s => s.DisablePing()) |
| 60 | +); |
| 61 | +
|
| 62 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 63 | + new ClientCall() { |
| 64 | + { ProductCheckOnStartup }, |
| 65 | + { ProductCheckFailure, 9200 }, <1> |
| 66 | + { HealthyResponse, 9200 } <2> |
| 67 | + }, |
| 68 | + new ClientCall() { |
| 69 | + { ProductCheckOnStartup }, |
| 70 | + { ProductCheckSuccess, 9200 }, <3> |
| 71 | + { HealthyResponse, 9200 } |
| 72 | + }, |
| 73 | + new ClientCall() { |
| 74 | + { HealthyResponse, 9200 } <4> |
| 75 | + } |
| 76 | +); |
| 77 | +---- |
| 78 | +<1> as this is the first call, the product check is executed, but fails |
| 79 | +<2> the actual request is still sent and succeeds |
| 80 | +<3> as the previous product check failed, it runs again on the second call |
| 81 | +<4> subsequent calls no longer perform product check |
| 82 | + |
| 83 | +Here's an example with a three node cluster which fails for some reason during the first and second product check attempts. |
| 84 | + |
| 85 | +[source,csharp] |
| 86 | +---- |
| 87 | +var audit = new Auditor(() => VirtualClusterWith |
| 88 | + .Nodes(3, productCheckAlwaysSucceeds: false) |
| 89 | + .ProductCheck(r => r.FailAlways()) |
| 90 | + .ProductCheck(r => r.OnPort(9202).SucceedAlways()) |
| 91 | + .ClientCalls(r => r.SucceedAlways()) |
| 92 | + .StaticConnectionPool() |
| 93 | + .Settings(s => s.DisablePing()) |
| 94 | +); |
| 95 | +
|
| 96 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 97 | + new ClientCall() { |
| 98 | + { ProductCheckOnStartup }, |
| 99 | + { ProductCheckFailure, 9200 }, <1> |
| 100 | + { ProductCheckFailure, 9201 }, <2> |
| 101 | + { ProductCheckSuccess, 9202 }, <3> |
| 102 | + { HealthyResponse, 9200 } <4> |
| 103 | + }, |
| 104 | + new ClientCall() { |
| 105 | + { HealthyResponse, 9201 } <5> |
| 106 | + } |
| 107 | +); |
| 108 | +---- |
| 109 | +<1> this is the first call, the product check is executed, but fails on this node |
| 110 | +<2> the next node is also tried and fails |
| 111 | +<3> the third node is tried, successfully responds and the product check succeeds |
| 112 | +<4> the actual request is sent and succeeds |
| 113 | +<5> subsequent calls no longer perform product check |
| 114 | + |
0 commit comments