@@ -66,11 +66,11 @@ private IRequestPipeline CreatePipeline(
6666 var settings = new ConnectionSettings ( pool , connection ?? new InMemoryConnection ( ) ) ;
6767 settings = settingsSelector ? . Invoke ( settings ) ?? settings ;
6868 return new FixedPipelineFactory ( settings , dateTimeProvider ?? DateTimeProvider . Default ) . Pipeline ;
69- }
70-
69+ }
70+
7171 /**=== Pipeline Behavior
7272 *==== Sniffing on First usage
73- */
73+ */
7474 [ U ]
7575 public void FirstUsageCheck ( )
7676 {
@@ -88,73 +88,73 @@ public void FirstUsageCheck()
8888 /** We can see that only the cluster that supports reseeding will opt in to `FirstPoolUsageNeedsSniffing()`;
8989 * You can however disable reseeding/sniffing on ConnectionSettings
9090 */
91- sniffingPipeline = CreatePipeline ( uris => new SniffingConnectionPool ( uris ) , s => s . SniffOnStartup ( false ) ) ; //<1> Disable sniffing on startup
91+ sniffingPipeline = CreatePipeline ( uris => new SniffingConnectionPool ( uris ) , s => s . SniffOnStartup ( false ) ) ; //<1> Disable sniffing on startup
9292 sniffingPipeline . FirstPoolUsageNeedsSniffing . Should ( ) . BeFalse ( ) ;
9393 }
9494
95- /**==== Wait for first Sniff
96- *
97- * All threads wait for the sniff on startup to finish, waiting the request timeout period. A
98- * https://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim(v=vs.110).aspx[`SemaphoreSlim`]
99- * is used to block threads until the sniff finishes and waiting threads release the `SemaphoreSlim` appropriately.
100- */
101- [ U ]
102- public void FirstUsageCheckConcurrentThreads ( )
103- {
104- var response = new
105- {
106- cluster_name = "elasticsearch" ,
107- nodes = new
108- {
109- node1 = new
110- {
111- name = "Node Name 1" ,
112- transport_address = "127.0.0.1:9300" ,
113- host = "127.0.0.1" ,
114- ip = "127.0.01" ,
115- version = "5.0.0-alpha3" ,
116- build = "e455fd0" ,
117- http_address = "127.0.0.1:9200" ,
118- settings = new JObject
119- {
120- { "client.type" , "node" } ,
121- { "cluster.name" , "elasticsearch" } ,
122- { "config.ignore_system_properties" , "true" } ,
123- { "name" , "Node Name 1" } ,
124- { "path.home" , "c:\\ elasticsearch\\ elasticsearch" } ,
125- { "path.logs" , "c:/ elasticsearch/logs" }
126- }
127- }
128- }
129- } ;
130-
131- var responseBody = Encoding . UTF8 . GetBytes ( JsonConvert . SerializeObject ( response ) ) ;
132-
133- var inMemoryConnection = new WaitingInMemoryConnection (
134- TimeSpan . FromSeconds ( 1 ) ,
135- responseBody ) ;
136-
137- var sniffingPipeline = CreatePipeline (
138- uris => new SniffingConnectionPool ( uris ) ,
139- connection : inMemoryConnection ,
140- settingsSelector : s => s . RequestTimeout ( TimeSpan . FromSeconds ( 2 ) ) ) ;
141-
142- var semaphoreSlim = new SemaphoreSlim ( 1 , 1 ) ;
95+ /**==== Wait for first Sniff
96+ *
97+ * All threads wait for the sniff on startup to finish, waiting the request timeout period. A
98+ * https://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim(v=vs.110).aspx[`SemaphoreSlim`]
99+ * is used to block threads until the sniff finishes and waiting threads release the `SemaphoreSlim` appropriately.
100+ */
101+ [ U ]
102+ public void FirstUsageCheckConcurrentThreads ( )
103+ {
104+ var response = new
105+ {
106+ cluster_name = "elasticsearch" ,
107+ nodes = new
108+ {
109+ node1 = new
110+ {
111+ name = "Node Name 1" ,
112+ transport_address = "127.0.0.1:9300" ,
113+ host = "127.0.0.1" ,
114+ ip = "127.0.01" ,
115+ version = "5.0.0-alpha3" ,
116+ build = "e455fd0" ,
117+ http_address = "127.0.0.1:9200" ,
118+ settings = new JObject
119+ {
120+ { "client.type" , "node" } ,
121+ { "cluster.name" , "elasticsearch" } ,
122+ { "config.ignore_system_properties" , "true" } ,
123+ { "name" , "Node Name 1" } ,
124+ { "path.home" , "c:\\ elasticsearch\\ elasticsearch" } ,
125+ { "path.logs" , "c:/ elasticsearch/logs" }
126+ }
127+ }
128+ }
129+ } ;
143130
144- /**
145- * start three tasks that will initiate a sniff on startup. The first task will successfully
146- * sniff on startup with the remaining two waiting tasks exiting without exception and releasing
147- * the `SemaphoreSlim`.
148- */
149- var task1 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
150- var task2 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
151- var task3 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
152-
153- var exception = Record . Exception ( ( ) => System . Threading . Tasks . Task . WaitAll ( task1 , task2 , task3 ) ) ;
154- exception . Should ( ) . BeNull ( ) ;
155- }
156-
157- /**==== Sniffing on Connection Failure */
131+ var responseBody = Encoding . UTF8 . GetBytes ( JsonConvert . SerializeObject ( response ) ) ;
132+
133+ var inMemoryConnection = new WaitingInMemoryConnection (
134+ TimeSpan . FromSeconds ( 1 ) ,
135+ responseBody ) ;
136+
137+ var sniffingPipeline = CreatePipeline (
138+ uris => new SniffingConnectionPool ( uris ) ,
139+ connection : inMemoryConnection ,
140+ settingsSelector : s => s . RequestTimeout ( TimeSpan . FromSeconds ( 2 ) ) ) ;
141+
142+ var semaphoreSlim = new SemaphoreSlim ( 1 , 1 ) ;
143+
144+ /**
145+ * start three tasks that will initiate a sniff on startup. The first task will successfully
146+ * sniff on startup with the remaining two waiting tasks exiting without exception and releasing
147+ * the `SemaphoreSlim`.
148+ */
149+ var task1 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
150+ var task2 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
151+ var task3 = System . Threading . Tasks . Task . Run ( ( ) => sniffingPipeline . FirstPoolUsage ( semaphoreSlim ) ) ;
152+
153+ var exception = Record . Exception ( ( ) => System . Threading . Tasks . Task . WaitAll ( task1 , task2 , task3 ) ) ;
154+ exception . Should ( ) . BeNull ( ) ;
155+ }
156+
157+ /**==== Sniffing on Connection Failure */
158158 [ U ]
159159 public void SniffsOnConnectionFailure ( )
160160 {
@@ -171,9 +171,9 @@ public void SniffsOnConnectionFailure()
171171 */
172172 sniffingPipeline = CreatePipeline ( uris => new SniffingConnectionPool ( uris ) , s => s . SniffOnConnectionFault ( false ) ) ;
173173 sniffingPipeline . SniffsOnConnectionFailure . Should ( ) . BeFalse ( ) ;
174- }
175-
176- /**==== Sniffing on Stale cluster */
174+ }
175+
176+ /**==== Sniffing on Stale cluster */
177177 [ U ]
178178 public void SniffsOnStaleCluster ( )
179179 {
0 commit comments