|
| 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-on-first-usage]] |
| 16 | +=== Product check on first usage |
| 17 | + |
| 18 | +Since 7.14.0, the client performs a required product check during the first call. |
| 19 | +This pre-flight product check allows us to establish the version of Elasticsearch we are communicating with. |
| 20 | + |
| 21 | +The product check requires one additional HTTP request to be sent to the server as part of the request pipeline. |
| 22 | +Once the product check succeeds, no further product check HTTP requests are sent as part of the pipeline. |
| 23 | + |
| 24 | +[source,csharp] |
| 25 | +---- |
| 26 | +var audit = new Auditor(() => VirtualClusterWith |
| 27 | + .Nodes(1) |
| 28 | + .ClientCalls(r => r.SucceedAlways()) |
| 29 | + .StaticConnectionPool() |
| 30 | + .Settings(s => s.DisablePing()) |
| 31 | +); |
| 32 | +
|
| 33 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 34 | + new ClientCall() { |
| 35 | + { ProductCheckOnStartup }, |
| 36 | + { ProductCheckSuccess, 9200 }, <1> |
| 37 | + { HealthyResponse, 9200 } <2> |
| 38 | + }, |
| 39 | + new ClientCall() { |
| 40 | + { HealthyResponse, 9200 } <3> |
| 41 | + } |
| 42 | +); |
| 43 | +---- |
| 44 | +<1> as this is the first call, the product check is executed |
| 45 | +<2> following the product check, the actual request is sent |
| 46 | +<3> subsequent calls no longer perform product check |
| 47 | + |
| 48 | +Here's an example with a single node cluster which fails for some reason during the first product check attempt. |
| 49 | + |
| 50 | +[source,csharp] |
| 51 | +---- |
| 52 | +var audit = new Auditor(() => VirtualClusterWith |
| 53 | + .Nodes(1, productCheckAlwaysSucceeds: false) |
| 54 | + .ProductCheck(r => r.Fails(TimesHelper.Once)) |
| 55 | + .ProductCheck(r => r.SucceedAlways()) |
| 56 | + .ClientCalls(r => r.SucceedAlways()) |
| 57 | + .StaticConnectionPool() |
| 58 | + .Settings(s => s.DisablePing()) |
| 59 | +); |
| 60 | +
|
| 61 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 62 | + new ClientCall() { |
| 63 | + { ProductCheckOnStartup }, |
| 64 | + { ProductCheckFailure, 9200 }, <1> |
| 65 | + { HealthyResponse, 9200 } <2> |
| 66 | + }, |
| 67 | + new ClientCall() { |
| 68 | + { ProductCheckOnStartup }, |
| 69 | + { ProductCheckSuccess, 9200 }, <3> |
| 70 | + { HealthyResponse, 9200 } |
| 71 | + }, |
| 72 | + new ClientCall() { |
| 73 | + { HealthyResponse, 9200 } <4> |
| 74 | + } |
| 75 | +); |
| 76 | +---- |
| 77 | +<1> as this is the first call, the product check is executed, but fails |
| 78 | +<2> the actual request is still sent and succeeds |
| 79 | +<3> as the previous product check failed, it runs on the second call |
| 80 | +<4> subsequent calls no longer perform product check |
| 81 | + |
| 82 | +Here's an example with a three node cluster which fails for some reason during the first and second product check attempts. |
| 83 | + |
| 84 | +[source,csharp] |
| 85 | +---- |
| 86 | +var audit = new Auditor(() => VirtualClusterWith |
| 87 | + .Nodes(3, productCheckAlwaysSucceeds: false) |
| 88 | + .ProductCheck(r => r.FailAlways()) |
| 89 | + .ProductCheck(r => r.OnPort(9202).SucceedAlways()) |
| 90 | + .ClientCalls(r => r.SucceedAlways()) |
| 91 | + .StaticConnectionPool() |
| 92 | + .Settings(s => s.DisablePing()) |
| 93 | +); |
| 94 | +
|
| 95 | +audit = await audit.TraceCalls(skipProductCheck: false, |
| 96 | + new ClientCall() { |
| 97 | + { ProductCheckOnStartup }, |
| 98 | + { ProductCheckFailure, 9200 }, <1> |
| 99 | + { ProductCheckFailure, 9201 }, <2> |
| 100 | + { ProductCheckSuccess, 9202 }, <3> |
| 101 | + { HealthyResponse, 9200 } <4> |
| 102 | + }, |
| 103 | + new ClientCall() { |
| 104 | + { HealthyResponse, 9201 } <5> |
| 105 | + } |
| 106 | +); |
| 107 | +---- |
| 108 | +<1> this is the first call, the product check is executed, but fails on this node |
| 109 | +<2> the next node is also tried and fails |
| 110 | +<3> the third node is tried, successfully responds and the product check succeeds |
| 111 | +<4> the actual request is sent and succeeds |
| 112 | +<5> subsequent calls no longer perform product check |
| 113 | + |
0 commit comments