Class DatabricksHttpClient
- java.lang.Object
-
- com.databricks.jdbc.dbclient.impl.http.DatabricksHttpClient
-
- All Implemented Interfaces:
IDatabricksHttpClient,Closeable,AutoCloseable
public class DatabricksHttpClient extends Object implements IDatabricksHttpClient, Closeable
Http client implementation to be used for executing http requests.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()org.apache.http.client.methods.CloseableHttpResponseexecute(org.apache.http.client.methods.HttpUriRequest request)Executes the given http request and returns the responseorg.apache.http.client.methods.CloseableHttpResponseexecute(org.apache.http.client.methods.HttpUriRequest request, boolean supportGzipEncoding)Executes the given http request and returns the response<T> Future<T>executeAsync(org.apache.hc.core5.http.nio.AsyncRequestProducer requestProducer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<T> responseConsumer, org.apache.hc.core5.concurrent.FutureCallback<T> callback)Executes the given http request asynchronously and returns the future
-
-
-
Method Detail
-
execute
public org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest request) throws DatabricksHttpExceptionDescription copied from interface:IDatabricksHttpClientExecutes the given http request and returns the response- Specified by:
executein interfaceIDatabricksHttpClient- Parameters:
request- underlying http request- Returns:
- http response
- Throws:
DatabricksHttpException
-
execute
public org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest request, boolean supportGzipEncoding) throws DatabricksHttpExceptionDescription copied from interface:IDatabricksHttpClientExecutes the given http request and returns the response- Specified by:
executein interfaceIDatabricksHttpClient- Parameters:
request- underlying http requestsupportGzipEncoding- whether to support gzip encoding header- Returns:
- http response
- Throws:
DatabricksHttpException
-
executeAsync
public <T> Future<T> executeAsync(org.apache.hc.core5.http.nio.AsyncRequestProducer requestProducer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<T> responseConsumer, org.apache.hc.core5.concurrent.FutureCallback<T> callback)
Executes the given http request asynchronously and returns the futureThis method leverages the Apache Async HTTP client which uses non-blocking I/O, allowing for higher throughput and better resource utilization compared to blocking I/O. Instead of dedicating one thread per connection, it can handle multiple connections with a smaller thread pool, significantly reducing memory overhead and thread context switching.
- Specified by:
executeAsyncin interfaceIDatabricksHttpClient- Type Parameters:
T- type of the response- Parameters:
requestProducer- request producerresponseConsumer- response consumercallback- future callback- Returns:
- future
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-