-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document HTTP/2 support #330
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,28 +56,46 @@ There are multiple low level transports which `OpenSearchClient` could be config | |
### Create a client using `RestClientTransport` | ||
|
||
```java | ||
Transport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); | ||
OpenSearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); | ||
OpenSearchClient client = new OpenSearchClient(transport); | ||
``` | ||
|
||
The `JacksonJsonpMapper` class (2.x versions) only supports Java 7 objects by default. [Java 8 modules](https://github.com/FasterXML/jackson-modules-java8) to support JDK8 classes such as the Date and Time API (JSR-310), `Optional`, and more can be used by including [the additional datatype dependency](https://github.com/FasterXML/jackson-modules-java8#usage) and adding the module. For example, to include JSR-310 classes: | ||
|
||
```java | ||
Transport transport = new RestClientTransport(restClient, | ||
OpenSearchTransport transport = new RestClientTransport(restClient, | ||
new JacksonJsonpMapper(new ObjectMapper().registerModule(new JavaTimeModule()))); | ||
OpenSearchClient client = new OpenSearchClient(transport); | ||
``` | ||
|
||
Upcoming OpenSearch `3.0.0` release brings HTTP/2 support and as such, the `RestClientTransport` would switch to HTTP/2 if available (for both HTTPS and/or HTTP protocols). The desired protocol could be forced using `RestClientBuilder.HttpClientConfigCallback`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can I see what protocol has been chosen? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Basically this could be done by:
I am not sure what kind of prove we could provide here.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For documentation generally I ask myself "what would I do". So if you think logging is how you'd do it, I'd show here (or somewhere in the docs) how to log the HTTP version chosen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not something we should be worried about here (I think), there are few things involved on our behalf:
The OpenSearch Java client could connect to To this point, we would be building features on top of HTTP/2 very soon (I believe), so the presence of HTTP/2 would be obvious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
|
||
### Create a client using `ApacheHttpClient5Transport` | ||
|
||
```java | ||
final Transport transport = ApacheHttpClient5TransportBuilder | ||
final OpenSearchTransport transport = ApacheHttpClient5TransportBuilder | ||
.builder(hosts) | ||
.mapper(new JacksonJsonpMapper()) | ||
.build(); | ||
OpenSearchClient client = new OpenSearchClient(transport); | ||
``` | ||
|
||
Upcoming OpenSearch `3.0.0` release brings HTTP/2 support and as such, the `ApacheHttpClient5Transport` would switch to HTTP/2 if available (for both HTTPS and/or HTTP protocols). The desired protocol could be forced using `ApacheHttpClient5TransportBuilder.HttpClientConfigCallback`, for example: | ||
|
||
```java | ||
final OpenSearchTransport transport = ApacheHttpClient5TransportBuilder | ||
.builder(httpHost) | ||
.setMapper(new JacksonJsonpMapper()) | ||
.setHttpClientConfigCallback(new ApacheHttpClient5TransportBuilder.HttpClientConfigCallback() { | ||
@Override | ||
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { | ||
return httpClientBuilder.setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2); | ||
} | ||
}) | ||
.build(); | ||
OpenSearchClient client = new OpenSearchClient(transport); | ||
``` | ||
|
||
## Create an index | ||
|
||
```java | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that
OpenSearchClient
does not acceptTransport
butOpenSearchTransport
, fixed that in the guide