From a5f243a85dc9b4c7353720efa40c8bc3ea0664e5 Mon Sep 17 00:00:00 2001 From: Geert Josten Date: Mon, 29 Jun 2015 20:03:05 +0200 Subject: [PATCH] Fixed #470: allow overriding http timeout settings from props --- deploy/default.properties | 8 ++++++++ deploy/lib/MLClient.rb | 11 ++++++++++- deploy/lib/ml_rest.rb | 6 +++++- deploy/lib/server_config.rb | 18 +++++++++++++++--- deploy/lib/xcc.rb | 8 +++++++- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/deploy/default.properties b/deploy/default.properties index e997ea9b..5a4dd272 100644 --- a/deploy/default.properties +++ b/deploy/default.properties @@ -213,3 +213,11 @@ evaler-port=7998 # List of MarkLogic system databases, for replication # system-dbs=App-Services,Documents,Extensions,Fab,Last-Login,Meters,Modules,Schemas,Security,Triggers + +# +# HTTP connection settings +# +http.retry-count=3 +http.open-timeout=5 +http.read-timeout=300 +http.retry-delay=15 diff --git a/deploy/lib/MLClient.rb b/deploy/lib/MLClient.rb index c268db7a..20911d5a 100644 --- a/deploy/lib/MLClient.rb +++ b/deploy/lib/MLClient.rb @@ -32,6 +32,11 @@ def initialize(options) @request = {} @@no_prompt = options[:no_prompt] + @@http_connection_retry_count = options[:http_connection_retry_count] + @@http_connection_open_timeout = options[:http_connection_open_timeout] + @@http_connection_read_timeout = options[:http_connection_read_timeout] + @@http_connection_retry_delay = options[:http_connection_retry_delay] + end def MLClient.logger() @@ -49,7 +54,11 @@ def logger() def get_http if (!@http) @http = Roxy::Http.new({ - :logger => logger + :logger => logger, + :http_connection_retry_count => @@http_connection_retry_count, + :http_connection_open_timeout => @@http_connection_open_timeout, + :http_connection_read_timeout => @@http_connection_read_timeout, + :http_connection_retry_delay => @@http_connection_retry_delay }) end @http diff --git a/deploy/lib/ml_rest.rb b/deploy/lib/ml_rest.rb index ae8bd076..1b1742a3 100644 --- a/deploy/lib/ml_rest.rb +++ b/deploy/lib/ml_rest.rb @@ -8,7 +8,11 @@ def initialize(options) @port = options[:app_port] end @http = Roxy::Http.new({ - :logger => @logger + :logger => @logger, + :http_connection_retry_count => options[:http_connection_retry_count], + :http_connection_open_timeout => options[:http_connection_open_timeout], + :http_connection_read_timeout => options[:http_connection_read_timeout], + :http_connection_retry_delay => options[:http_connection_retry_delay] }) @request = {} @gmt_offset = Time.now.gmt_offset diff --git a/deploy/lib/server_config.rb b/deploy/lib/server_config.rb index 68eac185..526c2ba1 100644 --- a/deploy/lib/server_config.rb +++ b/deploy/lib/server_config.rb @@ -74,7 +74,11 @@ def initialize(options) :user_name => @properties["ml.user"], :password => @properties["ml.password"], :logger => options[:logger], - :no_prompt => options[:no_prompt] + :no_prompt => options[:no_prompt], + :http_connection_retry_count => @properties["ml.http.retry-count"].to_i, + :http_connection_open_timeout => @properties["ml.http.open-timeout"].to_i, + :http_connection_read_timeout => @properties["ml.http.read-timeout"].to_i, + :http_connection_retry_delay => @properties["ml.http.retry-delay"].to_i ) @server_version = @properties["ml.server-version"].to_i @@ -1694,7 +1698,11 @@ def xcc :password => @ml_password, :xcc_server => @hostname, :xcc_port => @properties["ml.xcc-port"], - :logger => logger + :logger => logger, + :http_connection_retry_count => @properties["ml.http.retry-count"].to_i, + :http_connection_open_timeout => @properties["ml.http.open-timeout"].to_i, + :http_connection_read_timeout => @properties["ml.http.read-timeout"].to_i, + :http_connection_retry_delay => @properties["ml.http.retry-delay"].to_i }) end end @@ -1708,7 +1716,11 @@ def mlRest :app_port => @properties["ml.app-port"], :rest_port => @properties["ml.rest-port"], :logger => @logger, - :server_version => @server_version + :server_version => @server_version, + :http_connection_retry_count => @properties["ml.http.retry-count"].to_i, + :http_connection_open_timeout => @properties["ml.http.open-timeout"].to_i, + :http_connection_read_timeout => @properties["ml.http.read-timeout"].to_i, + :http_connection_retry_delay => @properties["ml.http.retry-delay"].to_i }) else @mlRest diff --git a/deploy/lib/xcc.rb b/deploy/lib/xcc.rb index 1ebf5c38..3441b211 100644 --- a/deploy/lib/xcc.rb +++ b/deploy/lib/xcc.rb @@ -92,7 +92,13 @@ def initialize(options) super(options) @hostname = options[:xcc_server] @port = options[:xcc_port] - @http = Roxy::Http.new :logger => logger + @http = Roxy::Http.new({ + :logger => logger, + :http_connection_retry_count => options[:http_connection_retry_count], + :http_connection_open_timeout => options[:http_connection_open_timeout], + :http_connection_read_timeout => options[:http_connection_read_timeout], + :http_connection_retry_delay => options[:http_connection_retry_delay] + }) @request = {} @gmt_offset = Time.now.gmt_offset end