From 4958636631b4408a306b077816c201a39ed6c5cc Mon Sep 17 00:00:00 2001 From: gmarz Date: Mon, 19 Jan 2015 18:00:51 -0500 Subject: [PATCH] Use ConnectTimeout instead of PingTimeout for thrift connections --- .../ThriftConnection.cs | 2 +- .../Configuration/ConnectionConfiguration.cs | 23 +++++++++++++++---- .../IConnectionConfigurationValues.cs | 23 +++++++++++-------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/Connections/Elasticsearch.Net.Connection.Thrift/ThriftConnection.cs b/src/Connections/Elasticsearch.Net.Connection.Thrift/ThriftConnection.cs index 34e6ea48d5e..948f8829043 100644 --- a/src/Connections/Elasticsearch.Net.Connection.Thrift/ThriftConnection.cs +++ b/src/Connections/Elasticsearch.Net.Connection.Thrift/ThriftConnection.cs @@ -246,7 +246,7 @@ private Rest.Client CreateClient(Uri uri, ConcurrentQueue queue) var protocol = _protocolFactory == null ? new TBinaryProtocol(transport) : _protocolFactory.GetProtocol(transport); var client = new Rest.Client(protocol); - tsocket.ConnectTimeout = this._connectionSettings.PingTimeout.GetValueOrDefault(200); + tsocket.ConnectTimeout = this._connectionSettings.ConnectTimeout.GetValueOrDefault(200); tsocket.Timeout = this._connectionSettings.Timeout; tsocket.TcpClient.SendTimeout = this._connectionSettings.Timeout; tsocket.TcpClient.ReceiveTimeout = this._connectionSettings.Timeout; diff --git a/src/Elasticsearch.Net/Connection/Configuration/ConnectionConfiguration.cs b/src/Elasticsearch.Net/Connection/Configuration/ConnectionConfiguration.cs index d1da359822a..675a7e15bc1 100644 --- a/src/Elasticsearch.Net/Connection/Configuration/ConnectionConfiguration.cs +++ b/src/Elasticsearch.Net/Connection/Configuration/ConnectionConfiguration.cs @@ -53,7 +53,10 @@ public class ConnectionConfiguration : IConnectionConfigurationValues, IHideO int IConnectionConfigurationValues.Timeout { get { return _timeout; }} private int? _pingTimeout; - int? IConnectionConfigurationValues.PingTimeout { get{ return _pingTimeout; } } + int? IConnectionConfigurationValues.PingTimeout { get { return _pingTimeout; } } + + private int? _connectTimeout; + int? IConnectionConfigurationValues.ConnectTimeout { get { return _connectTimeout; } } private int? _deadTimeout; int? IConnectionConfigurationValues.DeadTimeout { get{ return _deadTimeout; } } @@ -240,8 +243,8 @@ public T SetGlobalQueryStringParameters(NameValueCollection queryStringParameter } /// - /// Timeout in milliseconds when the .NET webrequest should abort the request, note that you can set this to a high value here, - /// and specify the timeout in various calls on Elasticsearch's side. + /// Sets the default timeout in milliseconds for each request to Elasticsearch. + /// NOTE: You can set this to a high value here, and specify the timeout on Elasticsearch's side. /// /// time out in milliseconds public T SetTimeout(int timeout) @@ -251,15 +254,25 @@ public T SetTimeout(int timeout) } /// - /// This is a separate timeout for Ping() requests. A ping should fail as fast as possible. + /// Sets the default ping timeout in milliseconds for ping requests, which are used + /// to determine whether a node is alive. Pings should fail as fast as possible. /// - /// The ping timeout in milliseconds defaults to 200 + /// The ping timeout in milliseconds defaults to 1000, or 2000 is using SSL. public T SetPingTimeout(int timeout) { this._pingTimeout = timeout; return (T) this; } + /// + /// Sets the default connection timeout in milliseconds. + /// + public T SetConnectTimeout(int timeout) + { + this._connectTimeout = timeout; + return (T)this; + } + /// /// Sets the default dead timeout factor when a node has been marked dead. /// diff --git a/src/Elasticsearch.Net/Connection/Configuration/IConnectionConfigurationValues.cs b/src/Elasticsearch.Net/Connection/Configuration/IConnectionConfigurationValues.cs index 9b132730a2a..9027cfe8c31 100644 --- a/src/Elasticsearch.Net/Connection/Configuration/IConnectionConfigurationValues.cs +++ b/src/Elasticsearch.Net/Connection/Configuration/IConnectionConfigurationValues.cs @@ -23,14 +23,19 @@ public interface IConnectionConfigurationValues int MaximumAsyncConnections { get; } /// - /// The time out for calls to elasticsearch + /// The timeout in milliseconds for each request to Elasticsearch /// int Timeout { get; } /// - /// The timeout in milliseconds to use for ping calls that are issues to check whether a node is up or not. + /// The timeout in milliseconds to use for ping requests, which are issued to determine whether a node is alive /// int? PingTimeout { get; } + + /// + /// The connect timeout in milliseconds + /// + int? ConnectTimeout { get; } /// /// The time to put dead nodes out of rotation (this will be multiplied by the number of times they've been dead) @@ -41,21 +46,21 @@ public interface IConnectionConfigurationValues /// The maximum ammount of time a node is allowed to marked dead /// int? MaxDeadTimeout { get; } - - /// - /// When a retryable exception occurs or status code is returned this controls the maximum - /// amount of times we should retry the call to elasticsearch - /// - int? MaxRetries { get; } /// /// Limits the total runtime including retries separately from ///
-		/// When not specified defaults to  which itself defaults to 60seconds
+		/// When not specified defaults to  which itself defaults to 60 seconds
 		/// 
///
TimeSpan? MaxRetryTimeout { get; } + /// + /// When a retryable exception occurs or status code is returned this controls the maximum + /// amount of times we should retry the call to elasticsearch + /// + int? MaxRetries { get; } + /// /// This signals that we do not want to send initial pings to unknown/previously dead nodes /// and just send the call straightaway