Class ServiceResponseHandler


  • public final class ServiceResponseHandler
    extends Object
    This class handles taking the HttpResponses we've gotten back, and producing an appropriate response object for usage
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ServiceResponseHandler.ApiName
      Enums for Snowpipe REST API: https://docs.snowflake.com/en/user-guide/data-load-snowpipe-rest-apis.html Used in handleExceptionalStatus for logging purpose
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static HistoryRangeResponse unmarshallHistoryRangeResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response, UUID requestId, net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient, net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpGet request, RequestBuilder builder)
      Given an HttpResponse object - attempts to deserialize it into a HistoryRangeResponse
      static HistoryResponse unmarshallHistoryResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response, UUID requestId, net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient, net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpGet httpGetHistory, RequestBuilder builder)
      unmarshallHistoryResponse Given an HttpResponse object - attempts to deserialize it into a HistoryResponse object
      static IngestResponse unmarshallIngestResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response, UUID requestId, net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient, net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpPost httpPostForIngestFile, RequestBuilder builder)
      unmarshallIngestResponse Given an HttpResponse object - attempts to deserialize it into an IngestResponse object
      static <T> T unmarshallStreamingIngestResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response, Class<T> valueType, ServiceResponseHandler.ApiName apiName, net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient, net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpUriRequest request, RequestBuilder requestBuilder)
      unmarshallStreamingIngestResponse Given an HttpResponse object - attempts to deserialize it into an Object based on input type
    • Constructor Detail

      • ServiceResponseHandler

        public ServiceResponseHandler()
    • Method Detail

      • unmarshallIngestResponse

        public static IngestResponse unmarshallIngestResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response,
                                                              UUID requestId,
                                                              net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient,
                                                              net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpPost httpPostForIngestFile,
                                                              RequestBuilder builder)
                                                       throws IOException,
                                                              IngestResponseException,
                                                              BackOffException
        unmarshallIngestResponse Given an HttpResponse object - attempts to deserialize it into an IngestResponse object
        Parameters:
        response - the HTTPResponse we want to distill into an IngestResponse
        requestId -
        httpClient - HttpClient for retries
        httpPostForIngestFile - HttpRequest for retries
        builder - RequestBuilder for retries
        Returns:
        An IngestResponse with all of the parsed out information
        Throws:
        IOException - if our entity is somehow corrupt or we can't get it
        IngestResponseException - - if we have an uncategorized network issue
        BackOffException - - if we have a 503 issue
      • unmarshallHistoryResponse

        public static HistoryResponse unmarshallHistoryResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response,
                                                                UUID requestId,
                                                                net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient,
                                                                net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpGet httpGetHistory,
                                                                RequestBuilder builder)
                                                         throws IOException,
                                                                IngestResponseException,
                                                                BackOffException
        unmarshallHistoryResponse Given an HttpResponse object - attempts to deserialize it into a HistoryResponse object
        Parameters:
        response - the HttpResponse object we are trying to deserialize
        requestId -
        httpClient - HttpClient for retries
        httpGetHistory - HttpRequest for retries
        builder - RequestBuilder for retries
        Returns:
        a HistoryResponse with all the parsed out information
        Throws:
        IOException - if our entity is somehow corrupt or we can't get it
        IngestResponseException - - if we have an uncategorized network issue
        BackOffException - - if we have a 503 issue
      • unmarshallHistoryRangeResponse

        public static HistoryRangeResponse unmarshallHistoryRangeResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response,
                                                                          UUID requestId,
                                                                          net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient,
                                                                          net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpGet request,
                                                                          RequestBuilder builder)
                                                                   throws IOException,
                                                                          IngestResponseException,
                                                                          BackOffException
        Given an HttpResponse object - attempts to deserialize it into a HistoryRangeResponse
        Parameters:
        response - the HttpResponse object we are trying to deserialize
        requestId -
        httpClient - HttpClient for retries
        request - HttpRequest for retries
        builder - HttpBuilder for retries
        Returns:
        HistoryRangeResponse
        Throws:
        IOException - if our entity is somehow corrupt or we can't get it
        IngestResponseException - - if we have an uncategorized network issue
        BackOffException - - if we have a 503 issue
      • unmarshallStreamingIngestResponse

        public static <T> T unmarshallStreamingIngestResponse​(net.snowflake.client.jdbc.internal.apache.http.HttpResponse response,
                                                              Class<T> valueType,
                                                              ServiceResponseHandler.ApiName apiName,
                                                              net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient httpClient,
                                                              net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpUriRequest request,
                                                              RequestBuilder requestBuilder)
                                                       throws IOException,
                                                              IngestResponseException
        unmarshallStreamingIngestResponse Given an HttpResponse object - attempts to deserialize it into an Object based on input type
        Parameters:
        response - http response from server
        valueType - the class type
        apiName - enum to represent the corresponding api name
        Returns:
        the corresponding response object based on input class type
        Throws:
        IOException - if a low-level I/O problem
        IngestResponseException - if received an exceptional status code