replace netty-http by net-http-netty-client, update to Java 17, update to gradle 7.5.1
This commit is contained in:
parent
121e3831e7
commit
88c550d9c1
47 changed files with 192 additions and 173 deletions
|
@ -3,12 +3,13 @@ package org.xbib.elx.api;
|
|||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public interface BasicClient extends Closeable {
|
||||
|
||||
boolean init(Settings settings, String info);
|
||||
boolean init(Settings settings, String info) throws IOException;
|
||||
|
||||
void putClusterSetting(String key, Object value, long timeout, TimeUnit timeUnit);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dependencies {
|
||||
api project(':elx-api')
|
||||
implementation libs.time
|
||||
testImplementation libs.netty.http
|
||||
testImplementation libs.net.http.netty.client
|
||||
testImplementation libs.es.plugin.transport.netty4
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class AbstractBasicClient implements BasicClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String infoString) {
|
||||
public boolean init(Settings settings, String infoString) throws IOException {
|
||||
if (closed.compareAndSet(false, true)) {
|
||||
this.settings = settings;
|
||||
logger.log(Level.INFO, String.format("Elx: %s on %s %s %s Java: %s %s %s %s ES: %s %s",
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class AbstractBulkClient extends AbstractBasicClient implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, info)) {
|
||||
bulkProcessor = new DefaultBulkProcessor(this, settings);
|
||||
return true;
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, info)) {
|
||||
if (settings.getAsBoolean(Parameters.SEARCH_METRIC_ENABLED.getName(),
|
||||
Parameters.SEARCH_METRIC_ENABLED.getBoolean())) {
|
||||
|
|
|
@ -13,8 +13,7 @@ public class DaemonThreadFactory implements ThreadFactory {
|
|||
|
||||
public DaemonThreadFactory(String namePrefix) {
|
||||
this.namePrefix = namePrefix;
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
group = s != null ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
this.group = Thread.currentThread().getThreadGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
dependencies{
|
||||
api project(':elx-common')
|
||||
api libs.netty.http
|
||||
api libs.net.http.netty.client
|
||||
api libs.es.plugin.transport.netty4
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package org.xbib.elx.http;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -23,9 +19,12 @@ import org.elasticsearch.common.xcontent.XContentType;
|
|||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.netty.http.client.api.ClientTransport;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.HttpHeaderNames;
|
||||
import org.xbib.net.http.HttpMethod;
|
||||
import org.xbib.net.http.client.netty.HttpRequest;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.Interaction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -57,17 +56,17 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
listener.onFailure(validationException);
|
||||
return;
|
||||
}
|
||||
Request.Builder httpRequestBuilder =
|
||||
HttpRequestBuilder httpRequestBuilder =
|
||||
createHttpRequest(httpActionContext.getUrl(), httpActionContext.getRequest());
|
||||
Request httpRequest = httpRequestBuilder.build();
|
||||
HttpRequest httpRequest = httpRequestBuilder.build();
|
||||
httpRequest.setResponseListener(fullHttpResponse -> {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.log(Level.TRACE, "got response: " + fullHttpResponse.getStatus().getCode() +
|
||||
logger.log(Level.TRACE, "got response: " + fullHttpResponse.getStatus().codeAsText() +
|
||||
" headers = " + fullHttpResponse.getHeaders() +
|
||||
" content = " + fullHttpResponse.getBody().toString(StandardCharsets.UTF_8));
|
||||
" content = " + fullHttpResponse.getBodyAsChars(StandardCharsets.UTF_8));
|
||||
}
|
||||
httpActionContext.setHttpResponse(fullHttpResponse);
|
||||
if (fullHttpResponse.getStatus().getCode() == HttpResponseStatus.OK.code()) {
|
||||
if (fullHttpResponse.getStatus().code() == 200) {
|
||||
listener.onResponse(parseToResponse(httpActionContext));
|
||||
} else {
|
||||
ElasticsearchStatusException statusException = parseToError(httpActionContext);
|
||||
|
@ -81,7 +80,7 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
if (logger.isTraceEnabled()) {
|
||||
logger.log(Level.TRACE, "executing HTTP request " + httpRequest);
|
||||
}
|
||||
ClientTransport transport = httpActionContext.getExtendedHttpClient().internalClient().execute(httpRequest);
|
||||
Interaction transport = httpActionContext.getExtendedHttpClient().internalClient().execute(httpRequest);
|
||||
httpActionContext.setHttpClientTransport(transport);
|
||||
if (transport.isFailed()) {
|
||||
listener.onFailure(new Exception(transport.getFailure()));
|
||||
|
@ -92,68 +91,64 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
}
|
||||
}
|
||||
|
||||
protected Request.Builder newGetRequest(String url, String path) {
|
||||
protected HttpRequestBuilder newGetRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.GET, url, path);
|
||||
}
|
||||
|
||||
protected Request.Builder newGetRequest(String url, String path, BytesReference content) {
|
||||
protected HttpRequestBuilder newGetRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.GET, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newHeadRequest(String url, String path) {
|
||||
protected HttpRequestBuilder newHeadRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.HEAD, url, path);
|
||||
}
|
||||
|
||||
protected Request.Builder newPostRequest(String url, String path) {
|
||||
protected HttpRequestBuilder newPostRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.POST, url, path);
|
||||
}
|
||||
|
||||
protected Request.Builder newPostRequest(String url, String path, BytesReference content) {
|
||||
protected HttpRequestBuilder newPostRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.POST, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newPostRequest(String url, String path, String content) {
|
||||
protected HttpRequestBuilder newPostRequest(String url, String path, String content) {
|
||||
return newRequest(HttpMethod.POST, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newPutRequest(String url, String path) {
|
||||
protected HttpRequestBuilder newPutRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.PUT, url, path);
|
||||
}
|
||||
|
||||
protected Request.Builder newPutRequest(String url, String path, String content) {
|
||||
protected HttpRequestBuilder newPutRequest(String url, String path, String content) {
|
||||
return newRequest(HttpMethod.PUT, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newPutRequest(String url, String path, BytesReference content) {
|
||||
protected HttpRequestBuilder newPutRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.PUT, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newDeleteRequest(String url, String path) {
|
||||
protected HttpRequestBuilder newDeleteRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.DELETE, url, path);
|
||||
}
|
||||
|
||||
protected Request.Builder newDeleteRequest(String url, String path, BytesReference content) {
|
||||
protected HttpRequestBuilder newDeleteRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.DELETE, url, path, content);
|
||||
}
|
||||
|
||||
protected Request.Builder newRequest(HttpMethod method, String baseUrl, String path) {
|
||||
return Request.builder(method).url(URL.from(baseUrl).resolve(path));
|
||||
protected HttpRequestBuilder newRequest(HttpMethod method, String baseUrl, String path) {
|
||||
return HttpRequest.builder(method).setURL(URL.from(baseUrl).resolve(path));
|
||||
}
|
||||
|
||||
protected Request.Builder newRequest(HttpMethod method, String baseUrl, String path, BytesReference content) {
|
||||
return Request.builder(method).url(URL.from(baseUrl).resolve(path)).content(content.toBytesRef().bytes, APPLICATION_JSON);
|
||||
protected HttpRequestBuilder newRequest(HttpMethod method, String baseUrl, String path, BytesReference content) {
|
||||
return HttpRequest.builder(method).setURL(URL.from(baseUrl).resolve(path)).content(content.toBytesRef().bytes, APPLICATION_JSON);
|
||||
}
|
||||
|
||||
protected Request.Builder newRequest(HttpMethod method, String baseUrl, String path, String content) {
|
||||
return Request.builder(method).url(URL.from(baseUrl).resolve(path)).content(content, APPLICATION_JSON);
|
||||
}
|
||||
|
||||
protected Request.Builder newRequest(HttpMethod method, String baseUrl, String path, ByteBuf byteBuf) {
|
||||
return Request.builder(method).url(URL.from(baseUrl).resolve(path)).content(byteBuf, APPLICATION_JSON);
|
||||
protected HttpRequestBuilder newRequest(HttpMethod method, String baseUrl, String path, String content) {
|
||||
return HttpRequest.builder(method).setURL(URL.from(baseUrl).resolve(path)).content(content, APPLICATION_JSON);
|
||||
}
|
||||
|
||||
protected T parseToResponse(HttpActionContext<R, T> httpActionContext) {
|
||||
String mediaType = httpActionContext.getHttpResponse().getHeaders().getHeader(HttpHeaderNames.CONTENT_TYPE);
|
||||
String mediaType = httpActionContext.getHttpResponse().getHeaders().get(HttpHeaderNames.CONTENT_TYPE);
|
||||
XContentType xContentType = XContentType.fromMediaTypeOrFormat(mediaType);
|
||||
if (xContentType == null) {
|
||||
throw new IllegalStateException("unsupported content-type: " + mediaType);
|
||||
|
@ -161,13 +156,13 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
try (XContentParser parser = xContentType.xContent()
|
||||
.createParser(httpActionContext.getExtendedHttpClient().getRegistry(),
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
httpActionContext.getHttpResponse().getBody().toString(StandardCharsets.UTF_8))) {
|
||||
httpActionContext.getHttpResponse().getBodyAsChars(StandardCharsets.UTF_8).toString())) {
|
||||
return entityParser(httpActionContext.getHttpResponse()).apply(parser);
|
||||
} catch (Throwable e) {
|
||||
// catch all kinds of errors in the entity parsing process
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error("status = " + httpActionContext.getHttpResponse().getStatus().getCode());
|
||||
logger.error("body = " + httpActionContext.getHttpResponse().getBodyAsString(StandardCharsets.UTF_8));
|
||||
logger.error("status = " + httpActionContext.getHttpResponse().getStatus().code());
|
||||
logger.error("body = " + httpActionContext.getHttpResponse().getBodyAsChars(StandardCharsets.UTF_8));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +172,7 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
try (XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
||||
.createParser(httpActionContext.getExtendedHttpClient().getRegistry(),
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
httpActionContext.getHttpResponse().getBody().toString(StandardCharsets.UTF_8))) {
|
||||
httpActionContext.getHttpResponse().getBodyAsChars(StandardCharsets.UTF_8).toString())) {
|
||||
return errorParser().apply(parser);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
@ -189,7 +184,7 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
return BytesRestResponse::errorFromXContent;
|
||||
}
|
||||
|
||||
protected abstract Request.Builder createHttpRequest(String baseUrl, R request) throws IOException;
|
||||
protected abstract HttpRequestBuilder createHttpRequest(String baseUrl, R request) throws IOException;
|
||||
|
||||
protected abstract CheckedFunction<XContentParser, T, IOException> entityParser(HttpResponse httpResponse);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.xbib.elx.http;
|
|||
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.xbib.netty.http.client.api.ClientTransport;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.Interaction;
|
||||
|
||||
/**
|
||||
* HTTP action context.
|
||||
|
@ -19,7 +19,7 @@ public class HttpActionContext<R extends ActionRequest, T extends ActionResponse
|
|||
|
||||
private final String url;
|
||||
|
||||
private ClientTransport httpClientTransport;
|
||||
private Interaction httpClientTransport;
|
||||
|
||||
private HttpResponse httpResponse;
|
||||
|
||||
|
@ -41,11 +41,11 @@ public class HttpActionContext<R extends ActionRequest, T extends ActionResponse
|
|||
return url;
|
||||
}
|
||||
|
||||
public void setHttpClientTransport(ClientTransport httpClientTransport) {
|
||||
public void setHttpClientTransport(Interaction httpClientTransport) {
|
||||
this.httpClientTransport = httpClientTransport;
|
||||
}
|
||||
|
||||
public ClientTransport getHttpClientTransport() {
|
||||
public Interaction getHttpClientTransport() {
|
||||
return httpClientTransport;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.xbib.elx.common.AbstractAdminClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Elasticsearch HTTP admin client.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class HttpAdminClient extends AbstractAdminClient implements Elasticsearc
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, "Netty: " + io.netty.util.Version.identify())) {
|
||||
helper.init(settings);
|
||||
return true;
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.xbib.elx.common.AbstractBulkClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Elasticsearch HTTP bulk client.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class HttpBulkClient extends AbstractBulkClient implements ElasticsearchC
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, io.netty.util.Version.identify().toString())) {
|
||||
helper.init(settings);
|
||||
return true;
|
||||
|
|
|
@ -15,8 +15,10 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.xbib.elx.common.Parameters;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.netty.http.client.Client;
|
||||
import org.xbib.netty.http.common.HttpAddress;
|
||||
import org.xbib.net.http.HttpAddress;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClient;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientBuilder;
|
||||
import org.xbib.net.http.client.netty.NettyHttpClientConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,7 +39,7 @@ public class HttpClientHelper {
|
|||
|
||||
private static final Logger logger = LogManager.getLogger(HttpClientHelper.class);
|
||||
|
||||
private Client nettyHttpClient;
|
||||
private NettyHttpClient nettyHttpClient;
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
|
@ -64,7 +66,7 @@ public class HttpClientHelper {
|
|||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void init(Settings settings) {
|
||||
public void init(Settings settings) throws IOException {
|
||||
HttpAddress httpAddress;
|
||||
if (settings.hasValue("url")) {
|
||||
this.url = settings.get("url");
|
||||
|
@ -85,18 +87,15 @@ public class HttpClientHelper {
|
|||
httpAction.setSettings(settings);
|
||||
actionMap.put(httpAction.getActionInstance(), httpAction);
|
||||
}
|
||||
Client.Builder clientBuilder = Client.builder();
|
||||
if (settings.getAsBoolean("pool.enabled", true)) {
|
||||
clientBuilder.addPoolNode(httpAddress)
|
||||
.setPoolNodeConnectionLimit(settings.getAsInt("pool.limit", Runtime.getRuntime().availableProcessors()));
|
||||
}
|
||||
NettyHttpClientConfig clientConfig = new NettyHttpClientConfig();
|
||||
if (settings.hasValue("debug")) {
|
||||
clientBuilder.enableDebug();
|
||||
clientConfig.enableDebug();
|
||||
}
|
||||
this.nettyHttpClient = clientBuilder.build();
|
||||
NettyHttpClientBuilder clientBuilder = NettyHttpClient.builder().setConfig(clientConfig);
|
||||
this.nettyHttpClient = clientBuilder.build();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.log(Level.DEBUG, "HTTP client initialized, pooled = {}, settings = {}, url = {}, {} actions",
|
||||
nettyHttpClient.isPooled(), settings, url, actionMap.size());
|
||||
logger.log(Level.DEBUG, "HTTP client initialized, settings = {}, url = {}, {} actions",
|
||||
settings, url, actionMap.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,14 +107,14 @@ public class HttpClientHelper {
|
|||
return registry;
|
||||
}
|
||||
|
||||
public Client internalClient() {
|
||||
public NettyHttpClient internalClient() {
|
||||
return nettyHttpClient;
|
||||
}
|
||||
|
||||
protected void closeClient(Settings settings) {
|
||||
if (closed.compareAndSet(false, true)) {
|
||||
try {
|
||||
nettyHttpClient.shutdownGracefully();
|
||||
nettyHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARN, e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.xbib.elx.common.AbstractSearchClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Elasticsearch HTTP search client.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class HttpSearchClient extends AbstractSearchClient implements Elasticsea
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, "Netty: " + io.netty.util.Version.identify())) {
|
||||
helper.init(settings);
|
||||
return true;
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpClusterHealthAction extends HttpAction<ClusterHealthRequest, Cl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, ClusterHealthRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, ClusterHealthRequest request) {
|
||||
return newGetRequest(url, "/_cluster/health");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,13 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HttpNodesInfoAction extends HttpAction<NodesInfoRequest, NodesInfoResponse> {
|
||||
|
||||
@Override
|
||||
|
@ -26,12 +23,12 @@ public class HttpNodesInfoAction extends HttpAction<NodesInfoRequest, NodesInfoR
|
|||
/**
|
||||
* Endpoint "/_nodes/{nodeId}/{metrics}"
|
||||
*
|
||||
* @param url url
|
||||
* @param url url
|
||||
* @param request request
|
||||
* @return HTTP request
|
||||
*/
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, NodesInfoRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, NodesInfoRequest request) {
|
||||
StringBuilder path = new StringBuilder("/_nodes");
|
||||
if (request.nodesIds() != null) {
|
||||
String nodeIds = String.join(",", request.nodesIds());
|
||||
|
|
|
@ -9,8 +9,8 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
@ -25,7 +25,7 @@ public class HttpClusterUpdateSettingsAction extends HttpAction<ClusterUpdateSet
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, ClusterUpdateSettingsRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, ClusterUpdateSettingsRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject().startObject("persistent");
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.NamedObjectNotFoundException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,7 +48,7 @@ public class HttpClusterStateAction extends HttpAction<ClusterStateRequest, Clus
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, ClusterStateRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, ClusterStateRequest request) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (request.metadata()) {
|
||||
list.add("metadata");
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class HttpIndicesAliasesAction extends HttpAction<IndicesAliasesRequest,
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, IndicesAliasesRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, IndicesAliasesRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||
request.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
|
|
|
@ -9,8 +9,8 @@ import org.elasticsearch.common.CheckedFunction;
|
|||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -21,7 +21,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect
|
|||
public class HttpGetAliasAction extends HttpAction<GetAliasesRequest, GetAliasesResponse> {
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetAliasesRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetAliasesRequest request) {
|
||||
// beware of this inconsistency, request.indices() always return empty array
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
String aliases = request.aliases() != null ? String.join(",", request.aliases()) + "/" : "";
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, Create
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, CreateIndexRequest createIndexRequest) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, CreateIndexRequest createIndexRequest) throws IOException {
|
||||
XContentBuilder builder = createIndexRequest.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||
return newPutRequest(url, "/" + createIndexRequest.index() + "?include_type_name=true",
|
||||
BytesReference.bytes(builder));
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpDeleteIndexAction extends HttpAction<DeleteIndexRequest, Acknow
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, DeleteIndexRequest deleteIndexRequest) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, DeleteIndexRequest deleteIndexRequest) {
|
||||
return newDeleteRequest(url, "/" + String.join(",", deleteIndexRequest.indices()));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.elx.http.HttpActionContext;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class HttpIndicesExistsAction extends HttpAction<IndicesExistsRequest, In
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, IndicesExistsRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, IndicesExistsRequest request) {
|
||||
String index = String.join(",", request.indices());
|
||||
return newHeadRequest(url, index);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class HttpIndicesExistsAction extends HttpAction<IndicesExistsRequest, In
|
|||
|
||||
@Override
|
||||
protected CheckedFunction<XContentParser, IndicesExistsResponse, IOException> entityParser(HttpResponse httpResponse) {
|
||||
return httpResponse.getStatus().getCode() == 200 ? this::found : this::notfound;
|
||||
return httpResponse.getStatus().code() == 200 ? this::found : this::notfound;
|
||||
}
|
||||
|
||||
private IndicesExistsResponse found(XContentParser parser) {
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -20,7 +21,7 @@ public class HtppGetIndexAction extends HttpAction<GetIndexRequest, GetIndexResp
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetIndexRequest getIndexRequest) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetIndexRequest getIndexRequest) throws IOException {
|
||||
List<String> list = getIndexRequest.indices().length == 0 ?
|
||||
List.of("*") : Arrays.asList(getIndexRequest.indices());
|
||||
String command = "/" + String.join(",", list);
|
||||
|
|
|
@ -9,8 +9,9 @@ import org.elasticsearch.common.ParseField;
|
|||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class HttpGetMappingsAction extends HttpAction<GetMappingsRequest, GetMap
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetMappingsRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetMappingsRequest request) {
|
||||
String index = request.indices() != null ? "/" + String.join(",", request.indices()) : "";
|
||||
return newGetRequest(url, index + "/_mapping");
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpRefreshIndexAction extends HttpAction<RefreshRequest, RefreshRe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, RefreshRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, RefreshRequest request) {
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
return newPostRequest(url, "/" + index + "_refresh");
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpGetSettingsAction extends HttpAction<GetSettingsRequest, GetSet
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetSettingsRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetSettingsRequest request) {
|
||||
// beware, request.indices() is always an empty array
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
return newGetRequest(url, index + "_settings");
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
@ -24,7 +24,7 @@ public class HttpUpdateSettingsAction extends HttpAction<UpdateSettingsRequest,
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, UpdateSettingsRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, UpdateSettingsRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class HttpBulkAction extends HttpAction<BulkRequest, BulkResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, BulkRequest request) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, BulkRequest request) throws IOException {
|
||||
StringBuilder bulkContent = new StringBuilder();
|
||||
for (DocWriteRequest<?> actionRequest : request.requests()) {
|
||||
if (actionRequest instanceof IndexRequest) {
|
||||
|
|
|
@ -7,8 +7,8 @@ import org.elasticsearch.action.get.GetResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class HttpExistsAction extends HttpAction<GetRequest, GetResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetRequest request) {
|
||||
return newHeadRequest(url, "/" + request.index() + "/_doc/" + request.id());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import org.elasticsearch.action.get.GetResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class HttpGetAction extends HttpAction<GetRequest, GetResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, GetRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, GetRequest request) {
|
||||
return newGetRequest(url, "/" + request.index() + "/_doc/" + request.id());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpMultiGetAction extends HttpAction<MultiGetRequest, MultiGetResponse> {
|
||||
|
@ -22,7 +23,7 @@ public class HttpMultiGetAction extends HttpAction<MultiGetRequest, MultiGetResp
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, MultiGetRequest request) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, MultiGetRequest request) throws IOException {
|
||||
BytesReference source = XContentHelper.toXContent(request, XContentType.JSON, false);
|
||||
return newGetRequest(url, "/_mget", source);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import org.elasticsearch.action.index.IndexResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class HttpIndexAction extends HttpAction<IndexRequest, IndexResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, IndexRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, IndexRequest request) {
|
||||
String optype = request.opType() == DocWriteRequest.OpType.CREATE ? "_create" : "_doc";
|
||||
return newPutRequest(url, "/" + request.index() + "/" + optype + "/" + request.id(),
|
||||
request.source());
|
||||
|
|
|
@ -7,8 +7,8 @@ import org.elasticsearch.action.main.MainResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class HttpMainAction extends HttpAction<MainRequest, MainResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, MainRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, MainRequest request) {
|
||||
return newGetRequest(url, "/");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpClearScrollAction extends HttpAction<ClearScrollRequest, ClearScrollResponse> {
|
||||
|
@ -22,7 +23,7 @@ public class HttpClearScrollAction extends HttpAction<ClearScrollRequest, ClearS
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String baseUrl, ClearScrollRequest request) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String baseUrl, ClearScrollRequest request) throws IOException {
|
||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||
request.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
return newDeleteRequest(baseUrl, "_search/scroll", BytesReference.bytes(builder));
|
||||
|
|
|
@ -7,8 +7,8 @@ import org.elasticsearch.common.CheckedFunction;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class HttpSearchAction extends HttpAction<SearchRequest, SearchResponse>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, SearchRequest request) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, SearchRequest request) {
|
||||
Scroll scroll = request.scroll();
|
||||
String params = scroll != null ? "?scroll=" + scroll.keepAlive() : "";
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
|
|
|
@ -10,8 +10,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpSearchScrollAction extends HttpAction<SearchScrollRequest, SearchResponse> {
|
||||
|
@ -22,7 +23,7 @@ public class HttpSearchScrollAction extends HttpAction<SearchScrollRequest, Sear
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String baseUrl, SearchScrollRequest request) throws IOException {
|
||||
protected HttpRequestBuilder createHttpRequest(String baseUrl, SearchScrollRequest request) throws IOException {
|
||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||
request.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
return newPostRequest(baseUrl, "_search/scroll", BytesReference.bytes(builder));
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
import org.xbib.net.http.client.HttpResponse;
|
||||
import org.xbib.net.http.client.netty.HttpRequestBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class HttpUpdateAction extends HttpAction<UpdateRequest, UpdateResponse>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request.Builder createHttpRequest(String url, UpdateRequest updateRequest) {
|
||||
protected HttpRequestBuilder createHttpRequest(String url, UpdateRequest updateRequest) {
|
||||
try {
|
||||
// The Java API allows update requests with different content types
|
||||
// set for the partial document and the upsert document. This client
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.elasticsearch.client.transport.TransportClient;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.xbib.elx.common.AbstractAdminClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Transport admin client.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class TransportAdminClient extends AbstractAdminClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, "Netty: " + io.netty.util.Version.identify())) {
|
||||
helper.init((TransportClient) getClient(), settings);
|
||||
return true;
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.elasticsearch.client.transport.TransportClient;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.xbib.elx.common.AbstractBulkClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Transport search client with additional methods.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class TransportBulkClient extends AbstractBulkClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, "Netty: " + io.netty.util.Version.identify())) {
|
||||
helper.init((TransportClient) getClient(), settings);
|
||||
return true;
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.elasticsearch.client.transport.TransportClient;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.xbib.elx.common.AbstractSearchClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Transport search client with additional methods.
|
||||
*/
|
||||
|
@ -23,7 +25,7 @@ public class TransportSearchClient extends AbstractSearchClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Settings settings, String info) {
|
||||
public boolean init(Settings settings, String info) throws IOException {
|
||||
if (super.init(settings, "Netty: " + io.netty.util.Version.identify())) {
|
||||
helper.init((TransportClient) getClient(), settings);
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = elx
|
||||
version = 7.10.2.22
|
||||
version = 7.10.2.23
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
|
@ -5,13 +5,13 @@ java {
|
|||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -34,10 +34,11 @@ artifacts {
|
|||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
// TransportClient is deprecated
|
||||
options.compilerArgs << '-Xlint:all,-deprecation'
|
||||
options.compilerArgs.add('-Xlint:all')
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
6
gradlew
vendored
6
gradlew
vendored
|
@ -205,6 +205,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
14
gradlew.bat
vendored
14
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
|||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
|
@ -25,7 +25,7 @@
|
|||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
version('gradle', '7.5')
|
||||
version('junit', '5.8.2')
|
||||
version('gradle', '7.5.1')
|
||||
version('junit', '5.9.1')
|
||||
version('elasticsearch', '7.10.2')
|
||||
version('lucene', '8.7.0')
|
||||
version('log4j', '2.17.1') // ES 7.10.2 uses log4j2 2.11.1
|
||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
||||
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
|
||||
library('hamcrest', 'org.hamcrest:hamcrest-library:2.2')
|
||||
library('junit4', 'junit:junit:4.13.2')
|
||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||
library('junit4', 'junit', 'junit').version('4.13.2')
|
||||
library('log4j-api', 'org.apache.logging.log4j', 'log4j-api').versionRef('log4j')
|
||||
library('log4j-core', 'org.apache.logging.log4j', 'log4j-core').versionRef('log4j')
|
||||
library('log4j-slf4j', 'org.apache.logging.log4j', 'log4j-slf4j-impl').versionRef('log4j')
|
||||
|
@ -27,9 +27,11 @@ dependencyResolutionManagement {
|
|||
library('joda', 'joda-time', 'joda-time').version('2.10.4')
|
||||
library('tdigest', 'com.tdunning', 't-digest').version('3.2')
|
||||
library('es-plugin-transport-netty4', 'org.elasticsearch.plugin', 'transport-netty4-client').versionRef('elasticsearch')
|
||||
library('jackson', 'com.fasterxml.jackson.core', 'jackson-core').version('2.12.7') // ES 7.10.2 uses Jackson 2.10.4
|
||||
library('netty-http', 'org.xbib', 'netty-http-client').version('4.1.77.0') // ES 7.10.2 uses Netty 4.1.49
|
||||
library('metrics', 'org.xbib', 'metrics-common').version('2.2.0')
|
||||
// ES 7.10.2 uses Jackson 2.10.4
|
||||
library('jackson', 'com.fasterxml.jackson.core', 'jackson-core').version('2.12.7')
|
||||
// ES 7.10.2 uses Netty 4.1.49
|
||||
library('net-http-netty-client', 'org.xbib', 'net-http-client-netty').version('3.0.0')
|
||||
library('metrics', 'org.xbib', 'metrics-common').version('3.0.0')
|
||||
library('time', 'org.xbib', 'time').version('2.1.0')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue