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