Module: UU::OS::QoS::QoSHandler
- Extended by:
- QoSHandler
- Included in:
- QoSHandler
- Defined in:
- uu_os_framework-0.29.16/lib/uu/os/qos/qos_handler.rb
Overview
QoS handler component.
Class Method Summary (collapse)
-
+ (Numeric) default_max_client_timeout
Returns default maximum client timeout (this timeout is used in case no timeout is found in configuration file..
-
+ (Object) default_max_client_timeout=(max_client_timeout)
Stores default maximum client timeout (this timeout is used in case no timeout is found in the configuration file..
Instance Method Summary (collapse)
-
- (Object) auto_retry(&block)
Automatically wait for QoSHandler renewal.
Class Method Details
+ (Numeric) default_max_client_timeout
Returns default maximum client timeout (this timeout is used in case no timeout is found in configuration file.
33 34 35 36 37 38 |
# File 'uu_os_framework-0.29.16/lib/uu/os/qos/qos_handler.rb', line 33 def self.default_max_client_timeout if !Thread.current[@@MAX_TIMEOUT_PARAM] QoSHandler.default_max_client_timeout=@@DEFAULT_MAX_TIMEOUT end Thread.current[@@MAX_TIMEOUT_PARAM] end |
+ (Object) default_max_client_timeout=(max_client_timeout)
Stores default maximum client timeout (this timeout is used in case no timeout is found in the configuration file.
44 45 46 |
# File 'uu_os_framework-0.29.16/lib/uu/os/qos/qos_handler.rb', line 44 def self.default_max_client_timeout=(max_client_timeout) Thread.current[@@MAX_TIMEOUT_PARAM] = max_client_timeout end |
Instance Method Details
- (Object) auto_retry(&block)
Automatically wait for QoSHandler renewal.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'uu_os_framework-0.29.16/lib/uu/os/qos/qos_handler.rb', line 51 def auto_retry(&block) # Load configuration uu.QoSHandler.max-client-timeout (in minutes) remainingTime = QoSHandler.default_max_client_timeout begin propt = Environment.load_configuration(@@CFG_FILE_PATH) remainingTime = propt[@@MAX_TIMEOUT_PARAM].to_i * 60 # seconds rescue # No problem, we will use default value end infiniteTimeout = (remainingTime < 0) while true do begin block.call break rescue QoSLimitException => e params = e.[0].params wait = (params[(params.size - 1)].to_i / 1000.0).to_i # value in exception is millis remainingTime -= wait if (!infiniteTimeout) && (remainingTime < 0) # Wait will exceed the maximum given time - throw QoSHandler limit exception raise e end @@log.warning('QoS limit exceeded. Waiting %s minutes for next attempt.', nil, wait / 60.0) sleep (wait) end end end |