Class RestRequest


  • public class RestRequest
    extends Object
    This is an abstraction on top of http client.

    Currently it only has one method for retrying http request execution so that the same logic doesn't have to be replicated at difference places where retry is needed.

    Author:
    jhuang
    • Constructor Summary

      Constructors 
      Constructor Description
      RestRequest()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.http.client.methods.CloseableHttpResponse execute​(org.apache.http.impl.client.CloseableHttpClient httpClient, org.apache.http.client.methods.HttpRequestBase httpRequest, long retryTimeout, long authTimeout, int socketTimeout, int maxRetries, int injectSocketTimeout, AtomicBoolean canceling, boolean withoutCookies, boolean includeRetryParameters, boolean includeRequestGuid, boolean retryHTTP403, boolean noRetry, ExecTimeTelemetryData execTimeData)
      Execute an http request with retry logic.
      static org.apache.http.client.methods.CloseableHttpResponse execute​(org.apache.http.impl.client.CloseableHttpClient httpClient, org.apache.http.client.methods.HttpRequestBase httpRequest, long retryTimeout, long authTimeout, int socketTimeout, int maxRetries, int injectSocketTimeout, AtomicBoolean canceling, boolean withoutCookies, boolean includeRetryParameters, boolean includeRequestGuid, boolean retryHTTP403, ExecTimeTelemetryData execTimeTelemetryData)  
    • Constructor Detail

      • RestRequest

        public RestRequest()
    • Method Detail

      • execute

        public static org.apache.http.client.methods.CloseableHttpResponse execute​(org.apache.http.impl.client.CloseableHttpClient httpClient,
                                                                                   org.apache.http.client.methods.HttpRequestBase httpRequest,
                                                                                   long retryTimeout,
                                                                                   long authTimeout,
                                                                                   int socketTimeout,
                                                                                   int maxRetries,
                                                                                   int injectSocketTimeout,
                                                                                   AtomicBoolean canceling,
                                                                                   boolean withoutCookies,
                                                                                   boolean includeRetryParameters,
                                                                                   boolean includeRequestGuid,
                                                                                   boolean retryHTTP403,
                                                                                   ExecTimeTelemetryData execTimeTelemetryData)
                                                                            throws SnowflakeSQLException
        Throws:
        SnowflakeSQLException
      • execute

        public static org.apache.http.client.methods.CloseableHttpResponse execute​(org.apache.http.impl.client.CloseableHttpClient httpClient,
                                                                                   org.apache.http.client.methods.HttpRequestBase httpRequest,
                                                                                   long retryTimeout,
                                                                                   long authTimeout,
                                                                                   int socketTimeout,
                                                                                   int maxRetries,
                                                                                   int injectSocketTimeout,
                                                                                   AtomicBoolean canceling,
                                                                                   boolean withoutCookies,
                                                                                   boolean includeRetryParameters,
                                                                                   boolean includeRequestGuid,
                                                                                   boolean retryHTTP403,
                                                                                   boolean noRetry,
                                                                                   ExecTimeTelemetryData execTimeData)
                                                                            throws SnowflakeSQLException
        Execute an http request with retry logic.
        Parameters:
        httpClient - client object used to communicate with other machine
        httpRequest - request object contains all the request information
        retryTimeout - : retry timeout (in seconds)
        authTimeout - : authenticator specific timeout (in seconds)
        socketTimeout - : curl timeout (in ms)
        maxRetries - : max retry count for the request
        injectSocketTimeout - : simulate socket timeout
        canceling - canceling flag
        withoutCookies - whether the cookie spec should be set to IGNORE or not
        includeRetryParameters - whether to include retry parameters in retried requests. Only needs to be true for JDBC statement execution (query requests to Snowflake server).
        includeRequestGuid - whether to include request_guid parameter
        retryHTTP403 - whether to retry on HTTP 403 or not
        noRetry - should we disable retry on non-successful http resp code
        Returns:
        HttpResponse Object get from server
        Throws:
        SnowflakeSQLException - Request timeout Exception or Illegal State Exception i.e. connection is already shutdown etc