Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pinot-clients/pinot-java-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.ning</groupId>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.ning.http.client.Response;
import io.netty.handler.ssl.ClientAuth;
import io.netty.handler.ssl.JdkSslContext;
import io.netty.handler.ssl.SslContext;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
Expand All @@ -33,6 +35,11 @@
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
import org.apache.pinot.spi.utils.CommonConstants;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.BoundRequestBuilder;
import org.asynchttpclient.DefaultAsyncHttpClientConfig.Builder;
import org.asynchttpclient.Dsl;
import org.asynchttpclient.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,25 +59,38 @@ public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
public JsonAsyncHttpPinotClientTransport() {
_headers = new HashMap<>();
_scheme = CommonConstants.HTTP_PROTOCOL;
_httpClient = new AsyncHttpClient();
_httpClient = Dsl.asyncHttpClient();
}

public JsonAsyncHttpPinotClientTransport(Map<String, String> headers, String scheme,
@Nullable SSLContext sslContext) {
@Nullable SSLContext sslContext) {
_headers = headers;
_scheme = scheme;

AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder();
Builder builder = Dsl.config();
if (sslContext != null) {
builder.setSSLContext(sslContext);
builder.setSslContext(new JdkSslContext(sslContext, true, ClientAuth.OPTIONAL));
}

_httpClient = new AsyncHttpClient(builder.build());
_httpClient = Dsl.asyncHttpClient(builder.build());
}

public JsonAsyncHttpPinotClientTransport(Map<String, String> headers, String scheme,
@Nullable SslContext sslContext) {
_headers = headers;
_scheme = scheme;

Builder builder = Dsl.config();
if (sslContext != null) {
builder.setSslContext(sslContext);
}

_httpClient = Dsl.asyncHttpClient(builder.build());
}

@Override
public BrokerResponse executeQuery(String brokerAddress, String query)
throws PinotClientException {
throws PinotClientException {
try {
return executeQueryAsync(brokerAddress, query).get();
} catch (Exception e) {
Expand All @@ -97,7 +117,7 @@ public Future<BrokerResponse> executePinotQueryAsync(String brokerAddress, final
url = _scheme + "://" + brokerAddress + "/query";
}

AsyncHttpClient.BoundRequestBuilder requestBuilder = _httpClient.preparePost(url);
BoundRequestBuilder requestBuilder = _httpClient.preparePost(url);

if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
Expand Down Expand Up @@ -135,7 +155,11 @@ public void close()
if (_httpClient.isClosed()) {
throw new PinotClientException("Connection is already closed!");
}
_httpClient.close();
try {
_httpClient.close();
} catch (IOException exception) {
throw new PinotClientException("Error while closing connection!");
}
}

private static class BrokerResponseFuture implements Future<BrokerResponse> {
Expand Down Expand Up @@ -185,7 +209,7 @@ public BrokerResponse get(long timeout, TimeUnit unit)
"Pinot returned HTTP status " + httpResponse.getStatusCode() + ", expected 200");
}

String responseBody = httpResponse.getResponseBody("UTF-8");
String responseBody = httpResponse.getResponseBody(StandardCharsets.UTF_8);
return BrokerResponse.fromJson(OBJECT_READER.readTree(responseBody));
} catch (Exception e) {
throw new ExecutionException(e);
Expand Down
6 changes: 5 additions & 1 deletion pinot-clients/pinot-jdbc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.ning</groupId>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
*/
package org.apache.pinot.client.controller;

import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.Response;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.apache.pinot.client.PinotClientException;
import org.apache.pinot.client.controller.response.ControllerTenantBrokerResponse;
import org.apache.pinot.client.controller.response.SchemaResponse;
import org.apache.pinot.client.controller.response.TableResponse;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.BoundRequestBuilder;
import org.asynchttpclient.Dsl;
import org.asynchttpclient.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -35,7 +38,7 @@ public class PinotControllerTransport {

private static final Logger LOGGER = LoggerFactory.getLogger(PinotControllerTransport.class);

AsyncHttpClient _httpClient = new AsyncHttpClient();
AsyncHttpClient _httpClient = Dsl.asyncHttpClient();
Map<String, String> _headers;

public PinotControllerTransport() {
Expand All @@ -48,7 +51,7 @@ public PinotControllerTransport(Map<String, String> headers) {
public TableResponse getAllTables(String controllerAddress) {
try {
String url = "http://" + controllerAddress + "/tables";
AsyncHttpClient.BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
Expand All @@ -66,7 +69,7 @@ public TableResponse getAllTables(String controllerAddress) {
public SchemaResponse getTableSchema(String table, String controllerAddress) {
try {
String url = "http://" + controllerAddress + "/tables/" + table + "/schema";
AsyncHttpClient.BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
Expand All @@ -84,7 +87,7 @@ public SchemaResponse getTableSchema(String table, String controllerAddress) {
public ControllerTenantBrokerResponse getBrokersFromController(String controllerAddress, String tenant) {
try {
String url = "http://" + controllerAddress + "/v2/brokers/tenants/" + tenant;
AsyncHttpClient.BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
BoundRequestBuilder requestBuilder = _httpClient.prepareGet(url);
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
Expand All @@ -105,6 +108,10 @@ public void close()
if (_httpClient.isClosed()) {
throw new PinotClientException("Connection is already closed!");
}
_httpClient.close();
try {
_httpClient.close();
} catch (IOException exception) {
throw new PinotClientException("Error while closing connection!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
*/
package org.apache.pinot.client.controller.response;

import com.ning.http.client.Response;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.pinot.client.PinotClientException;
import org.asynchttpclient.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -74,7 +75,7 @@ public String getStringResponse(long timeout, TimeUnit unit)
throw new PinotClientException("Pinot returned HTTP status " + httpResponse.getStatusCode() + ", expected 200");
}

String responseBody = httpResponse.getResponseBody("UTF-8");
String responseBody = httpResponse.getResponseBody(StandardCharsets.UTF_8);

return responseBody;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.ning.http.client.Response;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.asynchttpclient.Response;


public class ControllerTenantBrokerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.ning.http.client.Response;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.asynchttpclient.Response;


public class SchemaResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.ning.http.client.Response;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.asynchttpclient.Response;


public class TableResponse {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<zkclient.version>0.7</zkclient.version>
<jackson.version>2.10.0</jackson.version>
<zookeeper.version>3.5.8</zookeeper.version>
<async-http-client.version>1.9.21</async-http-client.version>
<async-http-client.version>2.12.3</async-http-client.version>
<jersey.version>2.28</jersey.version>
<grizzly.version>2.4.4</grizzly.version>
<swagger.version>1.5.16</swagger.version>
Expand Down Expand Up @@ -720,7 +720,7 @@
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>com.ning</groupId>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>${async-http-client.version}</version>
</dependency>
Expand Down