update for new 6.3.2.4 version
This commit is contained in:
parent
1912c018d5
commit
7b71bf9481
54 changed files with 262 additions and 209 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,4 +11,5 @@
|
|||
/.project
|
||||
/.gradle
|
||||
build
|
||||
out
|
||||
plugins
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface BulkProcessor extends Closeable, Flushable {
|
|||
/**
|
||||
* A listener for the execution.
|
||||
*/
|
||||
public interface Listener {
|
||||
interface Listener {
|
||||
|
||||
/**
|
||||
* Callback before the bulk is executed.
|
||||
|
|
|
@ -317,7 +317,7 @@ public interface ExtendedClient extends Flushable, Closeable {
|
|||
|
||||
/**
|
||||
* Force segment merge of an index.
|
||||
* @param indexDefinition th eindex definition
|
||||
* @param indexDefinition the index definition
|
||||
* @return this
|
||||
*/
|
||||
boolean forceMerge(IndexDefinition indexDefinition);
|
||||
|
|
|
@ -2,5 +2,5 @@ package org.xbib.elx.api;
|
|||
|
||||
public interface ReadClientProvider<C extends ReadClient> {
|
||||
|
||||
C getReadClient();
|
||||
C getReadClient();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.xbib.elx.common;
|
|||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
|
@ -194,16 +195,17 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|||
|
||||
@Override
|
||||
public AbstractExtendedClient init(Settings settings) throws IOException {
|
||||
logger.log(Level.INFO, "initializing with settings = " + settings.toDelimitedString(','));
|
||||
if (client == null) {
|
||||
client = createClient(settings);
|
||||
}
|
||||
if (bulkMetric == null) {
|
||||
this.bulkMetric = new DefaultBulkMetric();
|
||||
this.bulkMetric.init(settings);
|
||||
bulkMetric = new DefaultBulkMetric();
|
||||
bulkMetric.init(settings);
|
||||
}
|
||||
if (bulkController == null) {
|
||||
this.bulkController = new DefaultBulkController(this, bulkMetric);
|
||||
this.bulkController.init(settings);
|
||||
bulkController = new DefaultBulkController(this, bulkMetric);
|
||||
bulkController.init(settings);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -235,8 +237,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|||
public String getClusterName() {
|
||||
ensureActive();
|
||||
try {
|
||||
ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
|
||||
clusterStateRequest.clear();
|
||||
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().clear();
|
||||
ClusterStateResponse clusterStateResponse =
|
||||
client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet();
|
||||
return clusterStateResponse.getClusterName().value();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.xbib.elx.common;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -16,6 +19,8 @@ import java.util.ServiceLoader;
|
|||
@SuppressWarnings("rawtypes")
|
||||
public class ClientBuilder {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(ClientBuilder.class);
|
||||
|
||||
private final ElasticsearchClient client;
|
||||
|
||||
private final Settings.Builder settingsBuilder;
|
||||
|
@ -97,6 +102,10 @@ public class ClientBuilder {
|
|||
if (provider == null) {
|
||||
throw new IllegalArgumentException("no provider");
|
||||
}
|
||||
return (C) providerMap.get(provider).getExtendedClient().setClient(client).init(settingsBuilder.build());
|
||||
Settings settings = settingsBuilder.build();
|
||||
logger.log(Level.INFO, "settings = " + settings.toDelimitedString(','));
|
||||
return (C) providerMap.get(provider).getExtendedClient()
|
||||
.setClient(client)
|
||||
.init(settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public class DefaultBulkController implements BulkController {
|
|||
|
||||
private AtomicBoolean active;
|
||||
|
||||
private boolean enableBulkLogging;
|
||||
|
||||
public DefaultBulkController(ExtendedClient client, BulkMetric bulkMetric) {
|
||||
this.client = client;
|
||||
this.bulkMetric = bulkMetric;
|
||||
|
@ -76,11 +78,8 @@ public class DefaultBulkController implements BulkController {
|
|||
ByteSizeValue maxVolumePerRequest = settings.getAsBytesSize(Parameters.MAX_VOLUME_PER_REQUEST.name(),
|
||||
ByteSizeValue.parseBytesSizeValue(Parameters.DEFAULT_MAX_VOLUME_PER_REQUEST.getString(),
|
||||
"maxVolumePerRequest"));
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("bulk processor up with maxActionsPerRequest = {} maxConcurrentRequests = {} " +
|
||||
"flushIngestInterval = {} maxVolumePerRequest = {}",
|
||||
maxActionsPerRequest, maxConcurrentRequests, flushIngestInterval, maxVolumePerRequest);
|
||||
}
|
||||
this.enableBulkLogging = settings.getAsBoolean(Parameters.ENABLE_BULK_LOGGING.name(),
|
||||
Parameters.ENABLE_BULK_LOGGING.getValue());
|
||||
this.bulkListener = new BulkListener();
|
||||
this.bulkProcessor = DefaultBulkProcessor.builder(client.getClient(), bulkListener)
|
||||
.setBulkActions(maxActionsPerRequest)
|
||||
|
@ -89,6 +88,12 @@ public class DefaultBulkController implements BulkController {
|
|||
.setBulkSize(maxVolumePerRequest)
|
||||
.build();
|
||||
this.active.set(true);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("bulk processor up with maxActionsPerRequest = {} maxConcurrentRequests = {} " +
|
||||
"flushIngestInterval = {} maxVolumePerRequest = {} bulk logging = {} logger debug = {} from settings = {}",
|
||||
maxActionsPerRequest, maxConcurrentRequests, flushIngestInterval, maxVolumePerRequest,
|
||||
enableBulkLogging, logger.isDebugEnabled(), settings.toDelimitedString(','));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,6 +120,9 @@ public class DefaultBulkController implements BulkController {
|
|||
@Override
|
||||
public void index(IndexRequest indexRequest) {
|
||||
ensureActiveAndBulk();
|
||||
if (!active.get()) {
|
||||
throw new IllegalStateException("inactive");
|
||||
}
|
||||
try {
|
||||
if (bulkMetric != null) {
|
||||
bulkMetric.getCurrentIngest().inc(indexRequest.index(), indexRequest.type(), indexRequest.id());
|
||||
|
@ -237,7 +245,7 @@ public class DefaultBulkController implements BulkController {
|
|||
|
||||
private class BulkListener implements DefaultBulkProcessor.Listener {
|
||||
|
||||
private final Logger logger = LogManager.getLogger("org.xbib.elx.BulkProcessor.Listener");
|
||||
private final Logger logger = LogManager.getLogger(BulkListener.class.getName());
|
||||
|
||||
private Throwable lastBulkError = null;
|
||||
|
||||
|
@ -252,7 +260,7 @@ public class DefaultBulkController implements BulkController {
|
|||
bulkMetric.getCurrentIngestNumDocs().inc(n);
|
||||
bulkMetric.getTotalIngestSizeInBytes().inc(request.estimatedSizeInBytes());
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (enableBulkLogging && logger.isDebugEnabled()) {
|
||||
logger.debug("before bulk [{}] [actions={}] [bytes={}] [concurrent requests={}]",
|
||||
executionId,
|
||||
request.numberOfActions(),
|
||||
|
@ -282,7 +290,7 @@ public class DefaultBulkController implements BulkController {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (bulkMetric != null && logger.isDebugEnabled()) {
|
||||
if (enableBulkLogging && logger.isDebugEnabled() && bulkMetric != null) {
|
||||
logger.debug("after bulk [{}] [succeeded={}] [failed={}] [{}ms] {} concurrent requests",
|
||||
executionId,
|
||||
bulkMetric.getSucceeded().getCount(),
|
||||
|
@ -291,7 +299,7 @@ public class DefaultBulkController implements BulkController {
|
|||
l);
|
||||
}
|
||||
if (n > 0) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
if (enableBulkLogging && logger.isErrorEnabled()) {
|
||||
logger.error("bulk [{}] failed with {} failed items, failure message = {}",
|
||||
executionId, n, response.buildFailureMessage());
|
||||
}
|
||||
|
@ -309,7 +317,7 @@ public class DefaultBulkController implements BulkController {
|
|||
}
|
||||
lastBulkError = failure;
|
||||
active.set(false);
|
||||
if (logger.isErrorEnabled()) {
|
||||
if (enableBulkLogging && logger.isErrorEnabled()) {
|
||||
logger.error("after bulk [" + executionId + "] error", failure);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class DefaultBulkProcessor implements BulkProcessor {
|
|||
closed = true;
|
||||
if (scheduledFuture != null) {
|
||||
FutureUtils.cancel(scheduledFuture);
|
||||
this.scheduler.shutdown();
|
||||
scheduler.shutdown();
|
||||
}
|
||||
if (bulkRequest.numberOfActions() > 0) {
|
||||
execute();
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.xbib.elx.common;
|
|||
|
||||
public enum Parameters {
|
||||
|
||||
ENABLE_BULK_LOGGING(false),
|
||||
|
||||
DEFAULT_MAX_ACTIONS_PER_REQUEST(1000),
|
||||
|
||||
DEFAULT_MAX_CONCURRENT_REQUESTS(Runtime.getRuntime().availableProcessors()),
|
||||
|
@ -18,10 +20,16 @@ public enum Parameters {
|
|||
|
||||
FLUSH_INTERVAL("flush_interval");
|
||||
|
||||
boolean flag;
|
||||
|
||||
int num;
|
||||
|
||||
String string;
|
||||
|
||||
Parameters(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
Parameters(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
@ -30,6 +38,10 @@ public enum Parameters {
|
|||
this.string = string;
|
||||
}
|
||||
|
||||
boolean getValue() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
*
|
||||
* I/O helpers for Elasticsearch client extensions.
|
||||
*/
|
||||
package org.xbib.elx.common.io;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
*
|
||||
* Common classes for Elasticsearch client extensions.
|
||||
*/
|
||||
package org.xbib.elx.common;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
*
|
||||
* Utilities for Elasticsearch client extensions.
|
||||
*/
|
||||
package org.xbib.elx.common.util;
|
||||
|
|
|
@ -71,15 +71,14 @@ class AliasTest {
|
|||
indexRequest = new CreateIndexRequest("test20160103");
|
||||
client.execute(CreateIndexAction.INSTANCE, indexRequest).actionGet();
|
||||
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
|
||||
String[] indices = new String[]{"test20160101", "test20160102", "test20160103"};
|
||||
String[] aliases = new String[]{alias};
|
||||
String[] indices = new String[] { "test20160101", "test20160102", "test20160103" };
|
||||
String[] aliases = new String[] { alias };
|
||||
IndicesAliasesRequest.AliasActions aliasAction =
|
||||
new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.ADD)
|
||||
.indices(indices)
|
||||
.aliases(aliases);
|
||||
indicesAliasesRequest.addAliasAction(aliasAction);
|
||||
client.execute(IndicesAliasesAction.INSTANCE, indicesAliasesRequest).actionGet();
|
||||
|
||||
GetAliasesRequest getAliasesRequest = new GetAliasesRequest();
|
||||
getAliasesRequest.aliases(alias);
|
||||
GetAliasesResponse getAliasesResponse =
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TestExtension implements ParameterResolver, BeforeEachCallback, Aft
|
|||
logger.info("starting cluster with helper " + helper + " at " + helper.getHome());
|
||||
helper.startNode("1");
|
||||
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
|
||||
NodesInfoResponse response = helper.client("1"). execute(NodesInfoAction.INSTANCE, nodesInfoRequest).actionGet();
|
||||
NodesInfoResponse response = helper.client("1").execute(NodesInfoAction.INSTANCE, nodesInfoRequest).actionGet();
|
||||
TransportAddress address = response.getNodes().get(0).getTransport().getAddress().publishAddress();
|
||||
String host = address.address().getHostName();
|
||||
int port = address.address().getPort();
|
||||
|
@ -158,7 +158,7 @@ public class TestExtension implements ParameterResolver, BeforeEachCallback, Aft
|
|||
return helper;
|
||||
}
|
||||
|
||||
class Helper {
|
||||
static class Helper {
|
||||
|
||||
String home;
|
||||
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
dependencies{
|
||||
compile project(':elx-common')
|
||||
compile "org.xbib.elasticsearch:transport-netty4:${rootProject.property('elasticsearch-server.version')}"
|
||||
compile "org.xbib:netty-http-client:${project.property('xbib-netty-http.version')}"
|
||||
runtime "org.bouncycastle:bcpkix-jdk15on:${project.property('bouncycastle.version')}"
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
runtime "io.netty:netty-tcnative-boringssl-static:${project.property('tcnative-legacy-macosx.version')}"
|
||||
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
|
||||
runtime "io.netty:netty-tcnative-boringssl-static:${project.property('tcnative.version')}"
|
||||
runtime "org.xbib:netty-http-epoll:${project.property('xbib-netty-http.version')}"
|
||||
}
|
||||
testCompile "org.xbib.elasticsearch:elasticsearch-analysis-common:${rootProject.property('elasticsearch-server.version')}"
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -23,7 +23,7 @@ public class HttpGetMappingsAction extends HttpAction<GetMappingsRequest, GetMap
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, GetMappingsRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, GetMappingsRequest request) {
|
||||
String index = request.indices() != null ? "/" + String.join(",", request.indices()) : "";
|
||||
return newGetRequest(url, index + "/_mapping");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
import org.xbib.elx.common.AbstractExtendedClient;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.netty.http.client.Client;
|
||||
import org.xbib.netty.http.client.ClientBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -75,7 +74,7 @@ public class ExtendedHttpClient extends AbstractExtendedClient implements Elasti
|
|||
httpAction.setSettings(settings);
|
||||
actionMap.put(httpAction.getActionInstance(), httpAction);
|
||||
}
|
||||
ClientBuilder clientBuilder = Client.builder();
|
||||
Client.Builder clientBuilder = Client.builder();
|
||||
if (settings.hasValue("debug")) {
|
||||
clientBuilder.enableDebug();
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.xbib.netty.http.client.Request;
|
||||
import org.xbib.netty.http.client.RequestBuilder;
|
||||
import org.xbib.netty.http.client.transport.Transport;
|
||||
import org.xbib.net.URL;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
import org.xbib.netty.http.client.api.Transport;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -56,17 +56,17 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
listener.onFailure(validationException);
|
||||
return;
|
||||
}
|
||||
RequestBuilder httpRequestBuilder =
|
||||
Request.Builder httpRequestBuilder =
|
||||
createHttpRequest(httpActionContext.getUrl(), httpActionContext.getRequest());
|
||||
Request httpRequest = httpRequestBuilder.build();
|
||||
httpRequest.setResponseListener(fullHttpResponse -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.log(Level.DEBUG, "got response: " + fullHttpResponse.status().code() +
|
||||
" headers = " + fullHttpResponse.headers().entries() +
|
||||
" content = " + fullHttpResponse.content().toString(StandardCharsets.UTF_8));
|
||||
logger.log(Level.DEBUG, "got response: " + fullHttpResponse.getStatus().getCode() +
|
||||
" headers = " + fullHttpResponse.getHeaders() +
|
||||
" content = " + fullHttpResponse.getBody().toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
httpActionContext.setHttpResponse(fullHttpResponse);
|
||||
if (fullHttpResponse.status().equals(HttpResponseStatus.OK)) {
|
||||
if (fullHttpResponse.getStatus().getCode() == HttpResponseStatus.OK.code()) {
|
||||
listener.onResponse(parseToResponse(httpActionContext));
|
||||
} else {
|
||||
ElasticsearchStatusException statusException = parseToError(httpActionContext);
|
||||
|
@ -88,68 +88,68 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
}
|
||||
}
|
||||
|
||||
protected RequestBuilder newGetRequest(String url, String path) {
|
||||
protected Request.Builder newGetRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.GET, url, path);
|
||||
}
|
||||
|
||||
protected RequestBuilder newGetRequest(String url, String path, BytesReference content) {
|
||||
protected Request.Builder newGetRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.GET, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newHeadRequest(String url, String path) {
|
||||
protected Request.Builder newHeadRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.HEAD, url, path);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPostRequest(String url, String path) {
|
||||
protected Request.Builder newPostRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.POST, url, path);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPostRequest(String url, String path, BytesReference content) {
|
||||
protected Request.Builder newPostRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.POST, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPostRequest(String url, String path, String content) {
|
||||
protected Request.Builder newPostRequest(String url, String path, String content) {
|
||||
return newRequest(HttpMethod.POST, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPutRequest(String url, String path) {
|
||||
protected Request.Builder newPutRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.PUT, url, path);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPutRequest(String url, String path, String content) {
|
||||
protected Request.Builder newPutRequest(String url, String path, String content) {
|
||||
return newRequest(HttpMethod.PUT, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newPutRequest(String url, String path, BytesReference content) {
|
||||
protected Request.Builder newPutRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.PUT, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newDeleteRequest(String url, String path) {
|
||||
protected Request.Builder newDeleteRequest(String url, String path) {
|
||||
return newRequest(HttpMethod.DELETE, url, path);
|
||||
}
|
||||
|
||||
protected RequestBuilder newDeleteRequest(String url, String path, BytesReference content) {
|
||||
protected Request.Builder newDeleteRequest(String url, String path, BytesReference content) {
|
||||
return newRequest(HttpMethod.DELETE, url, path, content);
|
||||
}
|
||||
|
||||
protected RequestBuilder newRequest(HttpMethod method, String baseUrl, String path) {
|
||||
return Request.builder(method).url(baseUrl).uri(path);
|
||||
protected Request.Builder newRequest(HttpMethod method, String baseUrl, String path) {
|
||||
return Request.builder(method).url(URL.from(baseUrl).resolve(path));
|
||||
}
|
||||
|
||||
protected RequestBuilder newRequest(HttpMethod method, String baseUrl, String path, BytesReference content) {
|
||||
return Request.builder(method).url(baseUrl).uri(path).content(content.toBytesRef().bytes, APPLICATION_JSON);
|
||||
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 RequestBuilder newRequest(HttpMethod method, String baseUrl, String path, String content) {
|
||||
return Request.builder(method).url(baseUrl).uri(path).content(content, 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 RequestBuilder newRequest(HttpMethod method, String baseUrl, String path, ByteBuf byteBuf) {
|
||||
return Request.builder(method).url(baseUrl).uri(path).content(byteBuf, 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) {
|
||||
String mediaType = httpActionContext.getHttpResponse().headers().get(HttpHeaderNames.CONTENT_TYPE);
|
||||
String mediaType = httpActionContext.getHttpResponse().getHeaders().getHeader(HttpHeaderNames.CONTENT_TYPE);
|
||||
XContentType xContentType = XContentType.fromMediaTypeOrFormat(mediaType);
|
||||
if (xContentType == null) {
|
||||
throw new IllegalStateException("unsupported content-type: " + mediaType);
|
||||
|
@ -157,7 +157,7 @@ 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().content().toString(StandardCharsets.UTF_8))) {
|
||||
httpActionContext.getHttpResponse().getBody().toString(StandardCharsets.UTF_8))) {
|
||||
return entityParser().apply(parser);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
@ -169,7 +169,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().content().toString(StandardCharsets.UTF_8))) {
|
||||
httpActionContext.getHttpResponse().getBody().toString(StandardCharsets.UTF_8))) {
|
||||
return errorParser().apply(parser);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
@ -181,7 +181,7 @@ public abstract class HttpAction<R extends ActionRequest, T extends ActionRespon
|
|||
return BytesRestResponse::errorFromXContent;
|
||||
}
|
||||
|
||||
protected abstract RequestBuilder createHttpRequest(String baseUrl, R request) throws IOException;
|
||||
protected abstract Request.Builder createHttpRequest(String baseUrl, R request) throws IOException;
|
||||
|
||||
protected abstract CheckedFunction<XContentParser, T, IOException> entityParser();
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.xbib.elx.http;
|
||||
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.xbib.netty.http.client.transport.Transport;
|
||||
import org.xbib.netty.http.client.api.Transport;
|
||||
import org.xbib.netty.http.common.HttpResponse;
|
||||
|
||||
/**
|
||||
* HTTP action context.
|
||||
|
@ -21,7 +21,7 @@ public class HttpActionContext<R extends ActionRequest, T extends ActionResponse
|
|||
|
||||
private Transport httpClientTransport;
|
||||
|
||||
private FullHttpResponse httpResponse;
|
||||
private HttpResponse httpResponse;
|
||||
|
||||
HttpActionContext(ExtendedHttpClient extendedHttpClient, R request, String url) {
|
||||
this.extendedHttpClient = extendedHttpClient;
|
||||
|
@ -49,12 +49,12 @@ public class HttpActionContext<R extends ActionRequest, T extends ActionResponse
|
|||
return httpClientTransport;
|
||||
}
|
||||
|
||||
public HttpActionContext<R, T> setHttpResponse(FullHttpResponse fullHttpResponse) {
|
||||
this.httpResponse = fullHttpResponse;
|
||||
public HttpActionContext<R, T> setHttpResponse(HttpResponse httpResponse) {
|
||||
this.httpResponse = httpResponse;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FullHttpResponse getHttpResponse() {
|
||||
public HttpResponse getHttpResponse() {
|
||||
return httpResponse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.BaseFuture;
|
||||
import org.elasticsearch.common.util.concurrent.UncategorizedExecutionException;
|
||||
import org.xbib.netty.http.client.transport.Transport;
|
||||
import org.xbib.netty.http.client.api.Transport;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -6,7 +6,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class HttpClusterHealthAction extends HttpAction<ClusterHealthRequest, Cl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, ClusterHealthRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, ClusterHealthRequest request) {
|
||||
return newGetRequest(url, "/_cluster/health");
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.elasticsearch.threadpool.ThreadPoolInfo;
|
|||
import org.elasticsearch.transport.TransportInfo;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.elx.http.HttpActionContext;
|
||||
import org.xbib.netty.http.client.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
@ -53,7 +53,7 @@ public class HttpNodesInfoAction extends HttpAction<NodesInfoRequest, NodesInfoR
|
|||
* @return HTTP request
|
||||
*/
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, NodesInfoRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, NodesInfoRequest request) {
|
||||
StringBuilder path = new StringBuilder("/_nodes");
|
||||
if (request.nodesIds() != null) {
|
||||
String nodeIds = String.join(",", request.nodesIds());
|
||||
|
@ -104,13 +104,17 @@ public class HttpNodesInfoAction extends HttpAction<NodesInfoRequest, NodesInfoR
|
|||
return new NodesInfoResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Broken.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected NodesInfoResponse createResponse(HttpActionContext<NodesInfoRequest, NodesInfoResponse> httpContext) {
|
||||
Map<String, Object> map = null;
|
||||
String string = (String)map.get("cluster_name");
|
||||
ClusterName clusterName = new ClusterName(string);
|
||||
//String string = (String)map.get("cluster_name");
|
||||
ClusterName clusterName = new ClusterName("");
|
||||
List<NodeInfo> nodeInfoList = new LinkedList<>();
|
||||
map = (Map<String, Object>)map.get("nodes");
|
||||
//map = (Map<String, Object>)map.get("nodes");
|
||||
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String nodeId = entry.getKey();
|
||||
String ephemeralId = null;
|
||||
|
|
|
@ -9,7 +9,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
@ -24,7 +24,7 @@ public class HttpClusterUpdateSettingsAction extends HttpAction<ClusterUpdateSet
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, ClusterUpdateSettingsRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, ClusterUpdateSettingsRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject().startObject("persistent");
|
||||
|
|
|
@ -19,7 +19,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,7 +48,7 @@ public class HttpClusterStateAction extends HttpAction<ClusterStateRequest, Clus
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, ClusterStateRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, ClusterStateRequest request) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (request.metaData()) {
|
||||
list.add("metadata");
|
||||
|
|
|
@ -11,7 +11,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class HttpIndicesAliasesAction extends HttpAction<IndicesAliasesRequest,
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, IndicesAliasesRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, IndicesAliasesRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||
request.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
|
|
|
@ -9,7 +9,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,7 +20,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect
|
|||
public class HttpGetAliasAction extends HttpAction<GetAliasesRequest, GetAliasesResponse> {
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, GetAliasesRequest request) {
|
||||
protected Request.Builder 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,7 +10,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, Create
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, CreateIndexRequest createIndexRequest) throws IOException {
|
||||
protected Request.Builder createHttpRequest(String url, CreateIndexRequest createIndexRequest) throws IOException {
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder = createIndexRequest.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
return newPutRequest(url, "/" + createIndexRequest.index(), BytesReference.bytes(builder));
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class HttpDeleteIndexAction extends HttpAction<DeleteIndexRequest, Delete
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, DeleteIndexRequest deleteIndexRequest) {
|
||||
protected Request.Builder createHttpRequest(String url, DeleteIndexRequest deleteIndexRequest) {
|
||||
return newDeleteRequest(url, "/" + String.join(",", deleteIndexRequest.indices()));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class HttpIndicesExistsAction extends HttpAction<IndicesExistsRequest, In
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, IndicesExistsRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, IndicesExistsRequest request) {
|
||||
String index = String.join(",", request.indices());
|
||||
return newHeadRequest(url, index);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class HttpRefreshIndexAction extends HttpAction<RefreshRequest, RefreshRe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, RefreshRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, RefreshRequest request) {
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
return newPostRequest(url, "/" + index + "_refresh");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParserUtils;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -23,7 +23,7 @@ public class HttpGetSettingsAction extends HttpAction<GetSettingsRequest, GetSet
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, GetSettingsRequest request) {
|
||||
protected Request.Builder 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,7 +10,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
@ -23,7 +23,7 @@ public class HttpUpdateSettingsAction extends HttpAction<UpdateSettingsRequest,
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, UpdateSettingsRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, UpdateSettingsRequest request) {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
|
|
|
@ -13,7 +13,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class HttpBulkAction extends HttpAction<BulkRequest, BulkResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, BulkRequest request) throws IOException {
|
||||
protected Request.Builder createHttpRequest(String url, BulkRequest request) throws IOException {
|
||||
StringBuilder bulkContent = new StringBuilder();
|
||||
for (DocWriteRequest<?> actionRequest : request.requests()) {
|
||||
if (actionRequest instanceof IndexRequest) {
|
||||
|
|
|
@ -7,7 +7,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpExistsAction extends HttpAction<GetRequest, GetResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, GetRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, GetRequest request) {
|
||||
return newHeadRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpGetAction extends HttpAction<GetRequest, GetResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, GetRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, GetRequest request) {
|
||||
return newGetRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpIndexAction extends HttpAction<IndexRequest, IndexResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, IndexRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, IndexRequest request) {
|
||||
return newPutRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id(),
|
||||
request.source());
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class HttpMainAction extends HttpAction<MainRequest, MainResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, MainRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, MainRequest request) {
|
||||
return newGetRequest(url, "/");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.common.CheckedFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.xbib.elx.http.HttpAction;
|
||||
import org.xbib.netty.http.client.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class HttpSearchAction extends HttpAction<SearchRequest, SearchResponse>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, SearchRequest request) {
|
||||
protected Request.Builder createHttpRequest(String url, SearchRequest request) {
|
||||
// request.indices() always empty array
|
||||
String index = request.indices() != null ? String.join(",", request.indices()) + "/" : "";
|
||||
return newPostRequest(url, index + "_search", request.source().toString());
|
||||
|
|
|
@ -11,7 +11,7 @@ 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.RequestBuilder;
|
||||
import org.xbib.netty.http.client.api.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class HttpUpdateAction extends HttpAction<UpdateRequest, UpdateResponse>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RequestBuilder createHttpRequest(String url, UpdateRequest updateRequest) {
|
||||
protected Request.Builder 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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</Console>
|
||||
</appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
*
|
||||
* Node client extensions.
|
||||
*/
|
||||
package org.xbib.elx.node;
|
||||
|
|
|
@ -141,7 +141,7 @@ class ClientTest {
|
|||
void testThreadedRandomDocs() throws Exception {
|
||||
int maxthreads = Runtime.getRuntime().availableProcessors();
|
||||
Long maxActionsPerRequest = MAX_ACTIONS_PER_REQUEST;
|
||||
final Long actions = ACTIONS;
|
||||
final long actions = ACTIONS;
|
||||
logger.info("maxthreads={} maxactions={} maxloop={}", maxthreads, maxActionsPerRequest, actions);
|
||||
final ExtendedNodeClient client = ClientBuilder.builder(helper.client("1"))
|
||||
.provider(ExtendedNodeClientProvider.class)
|
||||
|