AppController/lib/app_controller_client.rb
# Provides automatic retry logic for transient SOAP errors. This code is
# used in few other clients (it should be made in a library):
#   lib/infrastructure_manager_client.rb
#   lib/user_app_client.rb
#   lib/taskqueue_client.rb
#   lib/app_manager_client.rb
#   lib/app_controller_client.rb
# Modification in this function should be reflected on the others too.
#
# Args:
#   time: A Fixnum that indicates how long the timeout should be set to when
#     executing the caller's block.
#   retry_on_except: A boolean that indicates if non-transient Exceptions
#     should result in the caller's block being retried or not.
#   callr: A String that names the caller's method, used for debugging
#     purposes.
#
# Raises:
#   FailedNodeException: if the given block contacted a machine that
#     is either not running or is rejecting connections.
#   SystemExit: If a non-transient Exception was thrown when executing the
#     given block.
# Returns:
#   The result of the block that was executed, or nil if the timeout was
#   exceeded.
Provides automatic retry logic for transient SOAP errors.

A Fixnum that indicates how long the timeout should be set to when
executing the caller's block.
retry_on_except: A boolean that indicates if non-transient Exceptions
should result in the caller's block being retried or not.
callr: A String that names the caller's method, used for debugging
purposes.

if the given block contacted a machine that
is either not running or is rejecting connections.
SystemExit: If a non-transient Exception was thrown when executing the
given block.
Returns:
The result of the block that was executed, or nil if the timeout was
exceeded.
Provides automatic retry logic for transient SOAP errors . A Fixnum that indicates how long the timeout should be set to when executing the caller ' s block . retry_on_except : A boolean that indicates if non - transient Exceptions should result in the caller ' s block being retried or not . callr : A String that names the caller ' s method used for debugging purposes . if the given block contacted a machine that is either not running or is rejecting connections . SystemExit : If a non - transient Exception was thrown when executing the given block . Returns : The result of the block that was executed or nil if the timeout was exceeded .
def make_call(time, retry_on_except, callr)
    begin
      Timeout::timeout(time) {
        begin
          yield if block_given?
        rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
          OpenSSL::SSL::SSLError, NotImplementedError, Errno::EPIPE,
          Errno::ECONNRESET, SOAP::EmptyResponseError, StandardError => e
          if retry_on_except
            Kernel.sleep(1)
            Djinn.log_debug("[#{callr}] exception in make_call to " +
              "#{@ip}:#{SERVER_PORT}. Exception class: #{e.class}. Retrying...")
            retry
          else
            trace = e.backtrace.join("\n")
            Djinn.log_warn("Exception encountered while talking to " +
              "#{@ip}:#{SERVER_PORT}.\n#{trace}")
            raise FailedNodeException.new("Exception #{e.class}:#{e.message} encountered " +
              "while talking to #{@ip}:#{SERVER_PORT}.")
          end
        end
      }
    rescue Timeout::Error
      Djinn.log_warn("[#{callr}] SOAP call to #{@ip} timed out")
      raise FailedNodeException.new("Time out talking to #{@ip}:#{SERVER_PORT}")
    end
  end
def make_call ( time , retry_on_except , callr ) begin Timeout :: timeout ( time ) { begin yield if block_given? rescue Errno :: ECONNREFUSED , Errno :: EHOSTUNREACH , OpenSSL :: SSL :: SSLError , NotImplementedError , Errno :: EPIPE , Errno :: ECONNRESET , SOAP :: EmptyResponseError , StandardError => e if retry_on_except Kernel . sleep ( 1 ) Djinn . log_debug ( "[#{callr}] exception in make_call to " + "#{@ip}:#{SERVER_PORT}. Exception class: #{e.class}. Retrying..." ) retry else trace = e . backtrace . join ( "\n" ) Djinn . log_warn ( "Exception encountered while talking to " + "#{@ip}:#{SERVER_PORT}.\n#{trace}" ) raise FailedNodeException . new ( "Exception #{e.class}:#{e.message} encountered " + "while talking to #{@ip}:#{SERVER_PORT}." ) end end } rescue Timeout :: Error Djinn . log_warn ( "[#{callr}] SOAP call to #{@ip} timed out" ) raise FailedNodeException . new ( "Time out talking to #{@ip}:#{SERVER_PORT}" ) end end
Provides automatic retry logic for transient SOAP errors.
Provides automatic retry logic for transient SOAP errors .
time
<not_specific>
retry_on_except
<not_specific>
callr
<not_specific>