Skip to content

Commit

Permalink
feat(apache): Add maxConnPerRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Apr 3, 2018
1 parent 0c64242 commit f78e52f
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 190 deletions.
61 changes: 61 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
Changelog
=========

2.17.0 (2018-04-03)
-------------------
- Add maxConnPerRoute

2.16.6 (2018-04-03)
-------------------
- Fix AroundRadius serialization (#476)

2.16.6 (2018-03-08)
-------------------
- Nothing

2.16.5 (2018-03-07)
-------------------
- Fix facet_stats type (#469)

2.16.4 (2018-03-06)
-------------------
- Nothing

2.16.3 (2018-03-05)
-------------------
- Add facet stats (#467)

2.16.2 (2018-02-28)
-------------------
- Nothing

2.16.1 (2018-02-27)
-------------------
- Add CredentialsProvider parameter (#463)

2.16.0 (2018-02-26)
-------------------
- Add a way to put a proxy for the underlying http client

2.15.7 (2018-02-20)
-------------------
- Add multipleQueries(List<IndexQuery> queries, String strategy)
- Add asyncClient.waitTask(task) (#457)
- Add deleteIndex method (without RequestOptions version)
- Fix scope in copy index (#460)

2.15.6 (2018-01-24)
-------------------
- Add waitTask with taskID (#417)
- Rename listIndices to listIndexes (#440)
- Rename types to type (#438)
- Rename `client.updateKey` => `client.updateApiKey` (#442)
- Remove `replaceExistingSynonyms` from `saveSynonym` (#441)
- Add copy/move Index (#444)
- Add waitTask method for taskID with requestOptions (#437)
- Fix visibility for compatibility with Clojure (#453)
- Rename `builder.setExtraHeader` => `builder.addExtraHeader` (#445)
- `partialUpdateObjects` with `createIfNotExists` (#447)
- Fix browse from (#448)

2.15.5 (2017-12-29)
-------------------
- Add Serializable to multiple objects

2.15.5 (2017-12-29)
-------------------
- Add Serializable to multiple objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public APIClientBuilder setMaxConnTotal(int maxConnTotal) {
return this;
}

@Override
public GenericAPIClientBuilder setMaxConnPerRoute(int maxConnPerRoute) {
super.setMaxConnPerRoute(maxConnPerRoute);
return this;
}

protected abstract APIClient build(@Nonnull APIClientConfiguration configuration);

/**
Expand All @@ -118,16 +124,17 @@ public APIClientBuilder setMaxConnTotal(int maxConnTotal) {
*/
public APIClient build() {
return build(
new APIClientConfiguration()
.setApplicationId(applicationId)
.setApiKey(apiKey)
.setObjectMapper(objectMapper)
.setBuildHosts(generateBuildHosts())
.setQueryHosts(generateQueryHosts())
.setHeaders(generateHeaders())
.setConnectTimeout(connectTimeout)
.setReadTimeout(readTimeout)
.setHostDownTimeout(hostDownTimeout)
.setMaxConnTotal(maxConnTotal));
new APIClientConfiguration(
applicationId,
apiKey,
objectMapper,
generateBuildHosts(),
generateQueryHosts(),
generateHeaders(),
connectTimeout,
readTimeout,
hostDownTimeout,
maxConnTotal,
maxConnPerRoute));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,104 +6,84 @@

public class APIClientConfiguration {

protected String applicationId;
protected String apiKey;
protected ObjectMapper objectMapper;
protected List<String> buildHosts;
protected List<String> queryHosts;
protected Map<String, String> headers;
protected int connectTimeout;
protected int readTimeout;
protected int hostDownTimeout;
protected int maxConnTotal;
private final String applicationId;
private final String apiKey;
private final ObjectMapper objectMapper;
private final List<String> buildHosts;
private final List<String> queryHosts;
private final Map<String, String> headers;
private final int connectTimeout;
private final int readTimeout;
private final int hostDownTimeout;
private final int maxConnTotal;
private final int maxConnPerRoute;

public APIClientConfiguration(
String applicationId,
String apiKey,
ObjectMapper objectMapper,
List<String> buildHosts,
List<String> queryHosts,
Map<String, String> headers,
int connectTimeout,
int readTimeout,
int hostDownTimeout,
int maxConnTotal,
int maxConnPerRoute) {
this.applicationId = applicationId;
this.apiKey = apiKey;
this.objectMapper = objectMapper;
this.buildHosts = buildHosts;
this.queryHosts = queryHosts;
this.headers = headers;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
this.hostDownTimeout = hostDownTimeout;
this.maxConnTotal = maxConnTotal;
this.maxConnPerRoute = maxConnPerRoute;
}

public String getApplicationId() {
return applicationId;
}

public APIClientConfiguration setApplicationId(String applicationId) {
this.applicationId = applicationId;
return this;
}

public String getApiKey() {
return apiKey;
}

public APIClientConfiguration setApiKey(String apiKey) {
this.apiKey = apiKey;
return this;
}

public ObjectMapper getObjectMapper() {
return objectMapper;
}

public APIClientConfiguration setObjectMapper(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
return this;
}

public List<String> getBuildHosts() {
return buildHosts;
}

public APIClientConfiguration setBuildHosts(List<String> buildHosts) {
this.buildHosts = buildHosts;
return this;
}

public List<String> getQueryHosts() {
return queryHosts;
}

public APIClientConfiguration setQueryHosts(List<String> queryHosts) {
this.queryHosts = queryHosts;
return this;
}

public Map<String, String> getHeaders() {
return headers;
}

public APIClientConfiguration setHeaders(Map<String, String> headers) {
this.headers = headers;
return this;
}

public int getConnectTimeout() {
return connectTimeout;
}

public APIClientConfiguration setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}

public int getReadTimeout() {
return readTimeout;
}

public APIClientConfiguration setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
return this;
}

public int getHostDownTimeout() {
return hostDownTimeout;
}

public APIClientConfiguration setHostDownTimeout(int hostDownTimeout) {
this.hostDownTimeout = hostDownTimeout;
return this;
}

public int getMaxConnTotal() {
return maxConnTotal;
}

public APIClientConfiguration setMaxConnTotal(int maxConnTotal) {
this.maxConnTotal = maxConnTotal;
return this;
public int getMaxConnPerRoute() {
return maxConnPerRoute;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ public AsyncAPIClientBuilder setBuildHosts(List<String> buildHosts) {
return this;
}

@Override
public GenericAPIClientBuilder setHostDownTimeout(int hostDownTimeout) {
super.setHostDownTimeout(hostDownTimeout);
return this;
}

@Override
public GenericAPIClientBuilder setMaxConnTotal(int maxConnTotal) {
super.setMaxConnTotal(maxConnTotal);
return this;
}

@Override
public GenericAPIClientBuilder setMaxConnPerRoute(int maxConnPerRoute) {
super.setMaxConnPerRoute(maxConnPerRoute);
return this;
}

protected abstract AsyncAPIClient build(@Nonnull AsyncAPIClientConfiguration configuration);

/**
Expand All @@ -113,15 +131,18 @@ public AsyncAPIClient build() {
*/
public AsyncAPIClient build(ExecutorService executor) {
return build(
new AsyncAPIClientConfiguration()
.setExecutor(executor)
.setApplicationId(applicationId)
.setApiKey(apiKey)
.setObjectMapper(objectMapper)
.setBuildHosts(generateBuildHosts())
.setQueryHosts(generateQueryHosts())
.setHeaders(generateHeaders())
.setConnectTimeout(connectTimeout)
.setReadTimeout(readTimeout));
new AsyncAPIClientConfiguration(
applicationId,
apiKey,
objectMapper,
generateBuildHosts(),
generateQueryHosts(),
generateHeaders(),
connectTimeout,
readTimeout,
hostDownTimeout,
maxConnTotal,
maxConnPerRoute,
executor));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,37 @@

public class AsyncAPIClientConfiguration extends APIClientConfiguration {

private ExecutorService executor;

public ExecutorService getExecutorService() {
return executor;
}

public AsyncAPIClientConfiguration setExecutor(ExecutorService executor) {
private final ExecutorService executor;

public AsyncAPIClientConfiguration(
String applicationId,
String apiKey,
ObjectMapper objectMapper,
List<String> buildHosts,
List<String> queryHosts,
Map<String, String> headers,
int connectTimeout,
int readTimeout,
int hostDownTimeout,
int maxConnTotal,
int maxConnPerRoute,
ExecutorService executor) {
super(
applicationId,
apiKey,
objectMapper,
buildHosts,
queryHosts,
headers,
connectTimeout,
readTimeout,
hostDownTimeout,
maxConnTotal,
maxConnPerRoute);
this.executor = executor;
return this;
}

@Override
public AsyncAPIClientConfiguration setApplicationId(String applicationId) {
super.setApplicationId(applicationId);
return this;
}

@Override
public AsyncAPIClientConfiguration setApiKey(String apiKey) {
super.setApiKey(apiKey);
return this;
}

@Override
public AsyncAPIClientConfiguration setObjectMapper(ObjectMapper objectMapper) {
super.setObjectMapper(objectMapper);
return this;
}

@Override
public AsyncAPIClientConfiguration setBuildHosts(List<String> buildHosts) {
super.setBuildHosts(buildHosts);
return this;
}

@Override
public AsyncAPIClientConfiguration setQueryHosts(List<String> queryHosts) {
super.setQueryHosts(queryHosts);
return this;
}

@Override
public AsyncAPIClientConfiguration setHeaders(Map<String, String> headers) {
super.setHeaders(headers);
return this;
}

@Override
public AsyncAPIClientConfiguration setConnectTimeout(int connectTimeout) {
super.setConnectTimeout(connectTimeout);
return this;
}

@Override
public AsyncAPIClientConfiguration setReadTimeout(int readTimeout) {
super.setReadTimeout(readTimeout);
return this;
public ExecutorService getExecutorService() {
return executor;
}
}
Loading

0 comments on commit f78e52f

Please sign in to comment.