|
|
@ -2,6 +2,7 @@ package org.xbib.elx.common;
|
|
|
|
|
|
|
|
|
|
|
|
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
|
|
|
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
|
|
|
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
|
|
|
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
|
|
|
|
|
|
|
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;
|
|
|
|
import org.elasticsearch.ElasticsearchTimeoutException;
|
|
|
|
import org.elasticsearch.ElasticsearchTimeoutException;
|
|
|
@ -58,6 +59,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|
|
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|
|
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
|
|
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
|
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
@ -67,7 +69,6 @@ import org.elasticsearch.search.sort.SortBuilder;
|
|
|
|
import org.elasticsearch.search.sort.SortBuilders;
|
|
|
|
import org.elasticsearch.search.sort.SortBuilders;
|
|
|
|
import org.elasticsearch.search.sort.SortOrder;
|
|
|
|
import org.elasticsearch.search.sort.SortOrder;
|
|
|
|
import org.xbib.elx.api.BulkController;
|
|
|
|
import org.xbib.elx.api.BulkController;
|
|
|
|
import org.xbib.elx.api.BulkMetric;
|
|
|
|
|
|
|
|
import org.xbib.elx.api.ExtendedClient;
|
|
|
|
import org.xbib.elx.api.ExtendedClient;
|
|
|
|
import org.xbib.elx.api.IndexAliasAdder;
|
|
|
|
import org.xbib.elx.api.IndexAliasAdder;
|
|
|
|
import org.xbib.elx.api.IndexDefinition;
|
|
|
|
import org.xbib.elx.api.IndexDefinition;
|
|
|
@ -85,7 +86,6 @@ import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -108,22 +108,11 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LogManager.getLogger(AbstractExtendedClient.class.getName());
|
|
|
|
private static final Logger logger = LogManager.getLogger(AbstractExtendedClient.class.getName());
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* The one and only index type name used in the extended client.
|
|
|
|
|
|
|
|
* Notr that all Elasticsearch version < 6.2.0 do not allow a prepending "_".
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static final String TYPE_NAME = "doc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* The Elasticsearch client.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ElasticsearchClient client;
|
|
|
|
private ElasticsearchClient client;
|
|
|
|
|
|
|
|
|
|
|
|
private BulkMetric bulkMetric;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BulkController bulkController;
|
|
|
|
private BulkController bulkController;
|
|
|
|
|
|
|
|
|
|
|
|
private AtomicBoolean closed;
|
|
|
|
private final AtomicBoolean closed;
|
|
|
|
|
|
|
|
|
|
|
|
private static final IndexShiftResult EMPTY_INDEX_SHIFT_RESULT = new IndexShiftResult() {
|
|
|
|
private static final IndexShiftResult EMPTY_INDEX_SHIFT_RESULT = new IndexShiftResult() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -178,11 +167,6 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
return client;
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public BulkMetric getBulkMetric() {
|
|
|
|
|
|
|
|
return bulkMetric;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BulkController getBulkController() {
|
|
|
|
public BulkController getBulkController() {
|
|
|
|
return bulkController;
|
|
|
|
return bulkController;
|
|
|
@ -190,15 +174,12 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public AbstractExtendedClient init(Settings settings) throws IOException {
|
|
|
|
public AbstractExtendedClient init(Settings settings) throws IOException {
|
|
|
|
|
|
|
|
logger.info("initializing with settings = " + settings.toDelimitedString(','));
|
|
|
|
if (client == null) {
|
|
|
|
if (client == null) {
|
|
|
|
client = createClient(settings);
|
|
|
|
client = createClient(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bulkMetric == null) {
|
|
|
|
|
|
|
|
this.bulkMetric = new DefaultBulkMetric();
|
|
|
|
|
|
|
|
this.bulkMetric.init(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bulkController == null) {
|
|
|
|
if (bulkController == null) {
|
|
|
|
this.bulkController = new DefaultBulkController(this, bulkMetric);
|
|
|
|
this.bulkController = new DefaultBulkController(this);
|
|
|
|
bulkController.init(settings);
|
|
|
|
bulkController.init(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -213,12 +194,8 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void close() throws IOException {
|
|
|
|
public void close() throws IOException {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
if (closed.compareAndSet(false, true)) {
|
|
|
|
if (closed.compareAndSet(false, true)) {
|
|
|
|
if (bulkMetric != null) {
|
|
|
|
|
|
|
|
logger.info("closing bulk metric");
|
|
|
|
|
|
|
|
bulkMetric.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bulkController != null) {
|
|
|
|
if (bulkController != null) {
|
|
|
|
logger.info("closing bulk controller");
|
|
|
|
logger.info("closing bulk controller");
|
|
|
|
bulkController.close();
|
|
|
|
bulkController.close();
|
|
|
@ -229,9 +206,9 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getClusterName() {
|
|
|
|
public String getClusterName() {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().all();
|
|
|
|
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().clear();
|
|
|
|
ClusterStateResponse clusterStateResponse =
|
|
|
|
ClusterStateResponse clusterStateResponse =
|
|
|
|
client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet();
|
|
|
|
client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet();
|
|
|
|
return clusterStateResponse.getClusterName().value();
|
|
|
|
return clusterStateResponse.getClusterName().value();
|
|
|
@ -249,7 +226,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient newIndex(IndexDefinition indexDefinition) throws IOException {
|
|
|
|
public ExtendedClient newIndex(IndexDefinition indexDefinition) throws IOException {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
waitForCluster("YELLOW", 30L, TimeUnit.SECONDS);
|
|
|
|
waitForCluster("YELLOW", 30L, TimeUnit.SECONDS);
|
|
|
|
URL indexSettings = indexDefinition.getSettingsUrl();
|
|
|
|
URL indexSettings = indexDefinition.getSettingsUrl();
|
|
|
|
if (indexSettings == null) {
|
|
|
|
if (indexSettings == null) {
|
|
|
@ -284,7 +261,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient newIndex(String index) throws IOException {
|
|
|
|
public ExtendedClient newIndex(String index) throws IOException {
|
|
|
|
return newIndex(index, Settings.EMPTY, (Map<String, Object>) null);
|
|
|
|
return newIndex(index, Settings.EMPTY, (Map<String, ?>) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -296,7 +273,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient newIndex(String index, Settings settings) throws IOException {
|
|
|
|
public ExtendedClient newIndex(String index, Settings settings) throws IOException {
|
|
|
|
return newIndex(index, settings, (Map<String, Object>) null);
|
|
|
|
return newIndex(index, settings, (Map<String, ?>) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -306,8 +283,8 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient newIndex(String index, Settings settings, Map<String, Object> mapping) {
|
|
|
|
public ExtendedClient newIndex(String index, Settings settings, XContentBuilder mapping) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
if (index == null) {
|
|
|
|
if (index == null) {
|
|
|
|
logger.warn("no index name given to create index");
|
|
|
|
logger.warn("no index name given to create index");
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -317,12 +294,36 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
createIndexRequest.settings(settings);
|
|
|
|
createIndexRequest.settings(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mapping != null) {
|
|
|
|
if (mapping != null) {
|
|
|
|
createIndexRequest.mapping(TYPE_NAME, mapping);
|
|
|
|
createIndexRequest.mapping("doc", mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CreateIndexResponse createIndexResponse = client.execute(CreateIndexAction.INSTANCE, createIndexRequest).actionGet();
|
|
|
|
CreateIndexResponse createIndexResponse = client.execute(CreateIndexAction.INSTANCE, createIndexRequest).actionGet();
|
|
|
|
logger.info("index {} created: {}", index, createIndexResponse);
|
|
|
|
if (createIndexResponse.isAcknowledged()) {
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new IllegalStateException("index creation not acknowledged: " + index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public ExtendedClient newIndex(String index, Settings settings, Map<String, ?> mapping) {
|
|
|
|
|
|
|
|
ensureClient();
|
|
|
|
|
|
|
|
if (index == null) {
|
|
|
|
|
|
|
|
logger.warn("no index name given to create index");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest().index(index);
|
|
|
|
|
|
|
|
if (settings != null) {
|
|
|
|
|
|
|
|
createIndexRequest.settings(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mapping != null) {
|
|
|
|
|
|
|
|
createIndexRequest.mapping("doc", mapping);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateIndexResponse createIndexResponse = client.execute(CreateIndexAction.INSTANCE, createIndexRequest).actionGet();
|
|
|
|
|
|
|
|
if (createIndexResponse.isAcknowledged()) {
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new IllegalStateException("index creation not acknowledged: " + index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient deleteIndex(IndexDefinition indexDefinition) {
|
|
|
|
public ExtendedClient deleteIndex(IndexDefinition indexDefinition) {
|
|
|
@ -331,7 +332,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient deleteIndex(String index) {
|
|
|
|
public ExtendedClient deleteIndex(String index) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
if (index == null) {
|
|
|
|
if (index == null) {
|
|
|
|
logger.warn("no index name given to delete index");
|
|
|
|
logger.warn("no index name given to delete index");
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -351,7 +352,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
public ExtendedClient startBulk(String index, long startRefreshIntervalSeconds, long stopRefreshIntervalSeconds)
|
|
|
|
public ExtendedClient startBulk(String index, long startRefreshIntervalSeconds, long stopRefreshIntervalSeconds)
|
|
|
|
throws IOException {
|
|
|
|
throws IOException {
|
|
|
|
if (bulkController != null) {
|
|
|
|
if (bulkController != null) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.startBulkMode(index, startRefreshIntervalSeconds, stopRefreshIntervalSeconds);
|
|
|
|
bulkController.startBulkMode(index, startRefreshIntervalSeconds, stopRefreshIntervalSeconds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -360,7 +361,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient stopBulk(IndexDefinition indexDefinition) throws IOException {
|
|
|
|
public ExtendedClient stopBulk(IndexDefinition indexDefinition) throws IOException {
|
|
|
|
if (bulkController != null) {
|
|
|
|
if (bulkController != null) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.stopBulkMode(indexDefinition);
|
|
|
|
bulkController.stopBulkMode(indexDefinition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -369,7 +370,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient stopBulk(String index, long timeout, TimeUnit timeUnit) throws IOException {
|
|
|
|
public ExtendedClient stopBulk(String index, long timeout, TimeUnit timeUnit) throws IOException {
|
|
|
|
if (bulkController != null) {
|
|
|
|
if (bulkController != null) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.stopBulkMode(index, timeout, timeUnit);
|
|
|
|
bulkController.stopBulkMode(index, timeout, timeUnit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -377,63 +378,63 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient index(String index, String id, boolean create, String source) {
|
|
|
|
public ExtendedClient index(String index, String id, boolean create, String source) {
|
|
|
|
return index(new IndexRequest(index, TYPE_NAME, id).create(create)
|
|
|
|
return index(new IndexRequest().index(index).type("doc").id(id).create(create)
|
|
|
|
.source(source.getBytes(StandardCharsets.UTF_8)));
|
|
|
|
.source(source.getBytes(StandardCharsets.UTF_8)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient index(String index, String id, boolean create, BytesReference source) {
|
|
|
|
public ExtendedClient index(String index, String id, boolean create, BytesReference source) {
|
|
|
|
return index(new IndexRequest(index, TYPE_NAME, id).create(create)
|
|
|
|
return index(new IndexRequest().index(index).type("doc").id(id).create(create)
|
|
|
|
.source(source));
|
|
|
|
.source(source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient index(IndexRequest indexRequest) {
|
|
|
|
public ExtendedClient index(IndexRequest indexRequest) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.index(indexRequest);
|
|
|
|
bulkController.bulkIndex(indexRequest);
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient delete(String index, String id) {
|
|
|
|
public ExtendedClient delete(String index, String id) {
|
|
|
|
return delete(new DeleteRequest(index, TYPE_NAME, id));
|
|
|
|
return delete(new DeleteRequest().index(index).type("doc").id(id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient delete(DeleteRequest deleteRequest) {
|
|
|
|
public ExtendedClient delete(DeleteRequest deleteRequest) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.delete(deleteRequest);
|
|
|
|
bulkController.bulkDelete(deleteRequest);
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient update(String index, String id, BytesReference source) {
|
|
|
|
public ExtendedClient update(String index, String id, BytesReference source) {
|
|
|
|
return update(new UpdateRequest(index, TYPE_NAME, id)
|
|
|
|
return update(new UpdateRequest().index(index).type("doc").id(id)
|
|
|
|
.doc(source));
|
|
|
|
.doc(source));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient update(String index, String id, String source) {
|
|
|
|
public ExtendedClient update(String index, String id, String source) {
|
|
|
|
return update(new UpdateRequest(index, TYPE_NAME, id)
|
|
|
|
return update(new UpdateRequest().index(index).type("doc").id(id)
|
|
|
|
.doc(source.getBytes(StandardCharsets.UTF_8)));
|
|
|
|
.doc(source.getBytes(StandardCharsets.UTF_8)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient update(UpdateRequest updateRequest) {
|
|
|
|
public ExtendedClient update(UpdateRequest updateRequest) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
bulkController.update(updateRequest);
|
|
|
|
bulkController.bulkUpdate(updateRequest);
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean waitForResponses(long timeout, TimeUnit timeUnit) {
|
|
|
|
public boolean waitForResponses(long timeout, TimeUnit timeUnit) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
return bulkController.waitForResponses(timeout, timeUnit);
|
|
|
|
return bulkController.waitForBulkResponses(timeout, timeUnit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean waitForRecovery(String index, long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
public boolean waitForRecovery(String index, long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
ensureIndexGiven(index);
|
|
|
|
ensureIndexGiven(index);
|
|
|
|
GetSettingsRequest settingsRequest = new GetSettingsRequest();
|
|
|
|
GetSettingsRequest settingsRequest = new GetSettingsRequest();
|
|
|
|
settingsRequest.indices(index);
|
|
|
|
settingsRequest.indices(index);
|
|
|
@ -448,7 +449,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
ClusterHealthResponse healthResponse =
|
|
|
|
ClusterHealthResponse healthResponse =
|
|
|
|
client.execute(ClusterHealthAction.INSTANCE, clusterHealthRequest).actionGet();
|
|
|
|
client.execute(ClusterHealthAction.INSTANCE, clusterHealthRequest).actionGet();
|
|
|
|
if (healthResponse != null && healthResponse.isTimedOut()) {
|
|
|
|
if (healthResponse != null && healthResponse.isTimedOut()) {
|
|
|
|
logger.error("timeout waiting for recovery");
|
|
|
|
logger.warn("timeout waiting for recovery");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -457,15 +458,13 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean waitForCluster(String statusString, long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
public boolean waitForCluster(String statusString, long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
ClusterHealthStatus status = ClusterHealthStatus.fromString(statusString);
|
|
|
|
ClusterHealthStatus status = ClusterHealthStatus.fromString(statusString);
|
|
|
|
TimeValue timeout = toTimeValue(maxWaitTime, timeUnit);
|
|
|
|
TimeValue timeout = toTimeValue(maxWaitTime, timeUnit);
|
|
|
|
ClusterHealthResponse healthResponse = client.execute(ClusterHealthAction.INSTANCE,
|
|
|
|
ClusterHealthResponse healthResponse = client.execute(ClusterHealthAction.INSTANCE,
|
|
|
|
new ClusterHealthRequest().timeout(timeout).waitForStatus(status)).actionGet();
|
|
|
|
new ClusterHealthRequest().timeout(timeout).waitForStatus(status)).actionGet();
|
|
|
|
if (healthResponse != null && healthResponse.isTimedOut()) {
|
|
|
|
if (healthResponse != null && healthResponse.isTimedOut()) {
|
|
|
|
if (logger.isErrorEnabled()) {
|
|
|
|
logger.warn("timeout, cluster state is " + healthResponse.getStatus().name() + " and not " + status.name());
|
|
|
|
logger.error("timeout, cluster state is " + healthResponse.getStatus().name() + " and not " + status.name());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -473,7 +472,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getHealthColor(long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
public String getHealthColor(long maxWaitTime, TimeUnit timeUnit) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
TimeValue timeout = toTimeValue(maxWaitTime, timeUnit);
|
|
|
|
TimeValue timeout = toTimeValue(maxWaitTime, timeUnit);
|
|
|
|
ClusterHealthResponse healthResponse = client.execute(ClusterHealthAction.INSTANCE,
|
|
|
|
ClusterHealthResponse healthResponse = client.execute(ClusterHealthAction.INSTANCE,
|
|
|
@ -530,7 +529,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient flushIndex(String index) {
|
|
|
|
public ExtendedClient flushIndex(String index) {
|
|
|
|
if (index != null) {
|
|
|
|
if (index != null) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
client.execute(FlushAction.INSTANCE, new FlushRequest(index)).actionGet();
|
|
|
|
client.execute(FlushAction.INSTANCE, new FlushRequest(index)).actionGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -539,7 +538,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ExtendedClient refreshIndex(String index) {
|
|
|
|
public ExtendedClient refreshIndex(String index) {
|
|
|
|
if (index != null) {
|
|
|
|
if (index != null) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
client.execute(RefreshAction.INSTANCE, new RefreshRequest(index)).actionGet();
|
|
|
|
client.execute(RefreshAction.INSTANCE, new RefreshRequest(index)).actionGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -550,7 +549,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
if (alias == null) {
|
|
|
|
if (alias == null) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
GetAliasesRequest getAliasesRequest = new GetAliasesRequest().aliases(alias);
|
|
|
|
GetAliasesRequest getAliasesRequest = new GetAliasesRequest().aliases(alias);
|
|
|
|
GetAliasesResponse getAliasesResponse = client.execute(GetAliasesAction.INSTANCE, getAliasesRequest).actionGet();
|
|
|
|
GetAliasesResponse getAliasesResponse = client.execute(GetAliasesAction.INSTANCE, getAliasesRequest).actionGet();
|
|
|
|
Pattern pattern = Pattern.compile("^(.*?)(\\d+)$");
|
|
|
|
Pattern pattern = Pattern.compile("^(.*?)(\\d+)$");
|
|
|
@ -574,9 +573,13 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String resolveAlias(String alias) {
|
|
|
|
public String resolveAlias(String alias) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
|
|
|
|
ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
|
|
|
|
|
|
|
|
clusterStateRequest.blocks(false);
|
|
|
|
clusterStateRequest.metaData(true);
|
|
|
|
clusterStateRequest.metaData(true);
|
|
|
|
|
|
|
|
clusterStateRequest.nodes(false);
|
|
|
|
|
|
|
|
clusterStateRequest.routingTable(false);
|
|
|
|
|
|
|
|
clusterStateRequest.customs(false);
|
|
|
|
ClusterStateResponse clusterStateResponse =
|
|
|
|
ClusterStateResponse clusterStateResponse =
|
|
|
|
client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet();
|
|
|
|
client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet();
|
|
|
|
SortedMap<String, AliasOrIndex> map = clusterStateResponse.getState().getMetaData().getAliasAndIndexLookup();
|
|
|
|
SortedMap<String, AliasOrIndex> map = clusterStateResponse.getState().getMetaData().getAliasAndIndexLookup();
|
|
|
@ -612,7 +615,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public IndexShiftResult shiftIndex(String index, String fullIndexName,
|
|
|
|
public IndexShiftResult shiftIndex(String index, String fullIndexName,
|
|
|
|
List<String> additionalAliases, IndexAliasAdder adder) {
|
|
|
|
List<String> additionalAliases, IndexAliasAdder adder) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
if (index == null) {
|
|
|
|
if (index == null) {
|
|
|
|
return EMPTY_INDEX_SHIFT_RESULT; // nothing to shift to
|
|
|
|
return EMPTY_INDEX_SHIFT_RESULT; // nothing to shift to
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -706,11 +709,11 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
if (index.equals(fullIndexName)) {
|
|
|
|
if (index.equals(fullIndexName)) {
|
|
|
|
return EMPTY_INDEX_PRUNE_RESULT;
|
|
|
|
return EMPTY_INDEX_PRUNE_RESULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
GetIndexRequestBuilder getIndexRequestBuilder = new GetIndexRequestBuilder(client, GetIndexAction.INSTANCE);
|
|
|
|
GetIndexRequestBuilder getIndexRequestBuilder = new GetIndexRequestBuilder(client, GetIndexAction.INSTANCE);
|
|
|
|
GetIndexResponse getIndexResponse = getIndexRequestBuilder.execute().actionGet();
|
|
|
|
GetIndexResponse getIndexResponse = getIndexRequestBuilder.execute().actionGet();
|
|
|
|
Pattern pattern = Pattern.compile("^(.*?)(\\d+)$");
|
|
|
|
Pattern pattern = Pattern.compile("^(.*?)(\\d+)$");
|
|
|
|
logger.info("{} indices", getIndexResponse.getIndices().length);
|
|
|
|
logger.info("pruneIndex: total of {} indices", getIndexResponse.getIndices().length);
|
|
|
|
List<String> candidateIndices = new ArrayList<>();
|
|
|
|
List<String> candidateIndices = new ArrayList<>();
|
|
|
|
for (String s : getIndexResponse.getIndices()) {
|
|
|
|
for (String s : getIndexResponse.getIndices()) {
|
|
|
|
Matcher m = pattern.matcher(s);
|
|
|
|
Matcher m = pattern.matcher(s);
|
|
|
@ -746,20 +749,29 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest()
|
|
|
|
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest()
|
|
|
|
.indices(indicesToDelete.toArray(s));
|
|
|
|
.indices(indicesToDelete.toArray(s));
|
|
|
|
DeleteIndexResponse response = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet();
|
|
|
|
DeleteIndexResponse response = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet();
|
|
|
|
|
|
|
|
if (response.isAcknowledged()) {
|
|
|
|
|
|
|
|
logger.log(Level.INFO, "deletion of {} acknowledged, waiting for GREEN", Arrays.asList(s));
|
|
|
|
|
|
|
|
waitForCluster("GREEN", 30L, TimeUnit.SECONDS);
|
|
|
|
return new SuccessPruneResult(candidateIndices, indicesToDelete, response);
|
|
|
|
return new SuccessPruneResult(candidateIndices, indicesToDelete, response);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
logger.log(Level.WARN, "deletion of {} not acknowledged", Arrays.asList(s));
|
|
|
|
|
|
|
|
return new FailPruneResult(candidateIndices, indicesToDelete, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Long mostRecentDocument(String index, String timestampfieldname) {
|
|
|
|
public Long mostRecentDocument(String index, String timestampfieldname) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
SortBuilder sort = SortBuilders.fieldSort(timestampfieldname).order(SortOrder.DESC);
|
|
|
|
SortBuilder sort = SortBuilders
|
|
|
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
|
|
|
.fieldSort(timestampfieldname)
|
|
|
|
sourceBuilder.field(timestampfieldname);
|
|
|
|
.order(SortOrder.DESC);
|
|
|
|
sourceBuilder.size(1);
|
|
|
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
|
|
|
|
sourceBuilder.sort(sort);
|
|
|
|
.sort(sort)
|
|
|
|
SearchRequest searchRequest = new SearchRequest();
|
|
|
|
.field(timestampfieldname)
|
|
|
|
searchRequest.indices(index);
|
|
|
|
.size(1);
|
|
|
|
searchRequest.source(sourceBuilder);
|
|
|
|
SearchRequest searchRequest = new SearchRequest()
|
|
|
|
|
|
|
|
.indices(index)
|
|
|
|
|
|
|
|
.source(sourceBuilder);
|
|
|
|
SearchResponse searchResponse = client.execute(SearchAction.INSTANCE, searchRequest).actionGet();
|
|
|
|
SearchResponse searchResponse = client.execute(SearchAction.INSTANCE, searchRequest).actionGet();
|
|
|
|
if (searchResponse.getHits().getHits().length == 1) {
|
|
|
|
if (searchResponse.getHits().getHits().length == 1) {
|
|
|
|
SearchHit hit = searchResponse.getHits().getHits()[0];
|
|
|
|
SearchHit hit = searchResponse.getHits().getHits()[0];
|
|
|
@ -837,7 +849,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) throws IOException {
|
|
|
|
public void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) throws IOException {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
if (index == null) {
|
|
|
|
if (index == null) {
|
|
|
|
throw new IOException("no index name given");
|
|
|
|
throw new IOException("no index name given");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -854,7 +866,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
client.execute(UpdateSettingsAction.INSTANCE, updateSettingsRequest).actionGet();
|
|
|
|
client.execute(UpdateSettingsAction.INSTANCE, updateSettingsRequest).actionGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ensureActive() {
|
|
|
|
private void ensureClient() {
|
|
|
|
if (this instanceof MockExtendedClient) {
|
|
|
|
if (this instanceof MockExtendedClient) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -886,7 +898,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void checkMapping(String index) {
|
|
|
|
public void checkMapping(String index) {
|
|
|
|
ensureActive();
|
|
|
|
ensureClient();
|
|
|
|
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(index);
|
|
|
|
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(index);
|
|
|
|
GetMappingsResponse getMappingsResponse = client.execute(GetMappingsAction.INSTANCE, getMappingsRequest).actionGet();
|
|
|
|
GetMappingsResponse getMappingsResponse = client.execute(GetMappingsAction.INSTANCE, getMappingsRequest).actionGet();
|
|
|
|
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> map = getMappingsResponse.getMappings();
|
|
|
|
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> map = getMappingsResponse.getMappings();
|
|
|
@ -902,25 +914,24 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
private void checkMapping(String index, String type, MappingMetaData mappingMetaData) {
|
|
|
|
private void checkMapping(String index, String type, MappingMetaData mappingMetaData) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client, SearchAction.INSTANCE);
|
|
|
|
SearchSourceBuilder builder = new SearchSourceBuilder()
|
|
|
|
SearchResponse searchResponse = searchRequestBuilder.setSize(0)
|
|
|
|
.query(QueryBuilders.matchAllQuery())
|
|
|
|
.setIndices(index)
|
|
|
|
.size(0);
|
|
|
|
.setTypes(type)
|
|
|
|
SearchRequest searchRequest = new SearchRequest()
|
|
|
|
.setQuery(QueryBuilders.matchAllQuery())
|
|
|
|
.indices(index)
|
|
|
|
.execute()
|
|
|
|
.source(builder);
|
|
|
|
.actionGet();
|
|
|
|
SearchResponse searchResponse =
|
|
|
|
|
|
|
|
client.execute(SearchAction.INSTANCE, searchRequest).actionGet();
|
|
|
|
long total = searchResponse.getHits().getTotalHits();
|
|
|
|
long total = searchResponse.getHits().getTotalHits();
|
|
|
|
if (total > 0L) {
|
|
|
|
if (total > 0L) {
|
|
|
|
Map<String, Long> fields = new TreeMap<>();
|
|
|
|
Map<String, Long> fields = new TreeMap<>();
|
|
|
|
Map<String, Object> root = mappingMetaData.getSourceAsMap();
|
|
|
|
Map<String, Object> root = mappingMetaData.getSourceAsMap();
|
|
|
|
checkMapping(index, type, "", "", root, fields);
|
|
|
|
checkMapping(index, "", "", root, fields);
|
|
|
|
AtomicInteger empty = new AtomicInteger();
|
|
|
|
AtomicInteger empty = new AtomicInteger();
|
|
|
|
Map<String, Long> map = sortByValue(fields);
|
|
|
|
Map<String, Long> map = sortByValue(fields);
|
|
|
|
map.forEach((key, value) -> {
|
|
|
|
map.forEach((key, value) -> {
|
|
|
|
logger.info("{} {} {}",
|
|
|
|
logger.info("{} {} {}",
|
|
|
|
key,
|
|
|
|
key, value, (double) value * 100 / total);
|
|
|
|
value,
|
|
|
|
|
|
|
|
(double) value * 100 / total);
|
|
|
|
|
|
|
|
if (value == 0) {
|
|
|
|
if (value == 0) {
|
|
|
|
empty.incrementAndGet();
|
|
|
|
empty.incrementAndGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -934,7 +945,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
private void checkMapping(String index, String type,
|
|
|
|
private void checkMapping(String index,
|
|
|
|
String pathDef, String fieldName, Map<String, Object> map,
|
|
|
|
String pathDef, String fieldName, Map<String, Object> map,
|
|
|
|
Map<String, Long> fields) {
|
|
|
|
Map<String, Long> fields) {
|
|
|
|
String path = pathDef;
|
|
|
|
String path = pathDef;
|
|
|
@ -959,18 +970,19 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
String fieldType = o instanceof String ? o.toString() : null;
|
|
|
|
String fieldType = o instanceof String ? o.toString() : null;
|
|
|
|
// do not recurse into our custom field mapper
|
|
|
|
// do not recurse into our custom field mapper
|
|
|
|
if (!"standardnumber".equals(fieldType) && !"ref".equals(fieldType)) {
|
|
|
|
if (!"standardnumber".equals(fieldType) && !"ref".equals(fieldType)) {
|
|
|
|
checkMapping(index, type, path, key, child, fields);
|
|
|
|
checkMapping(index, path, key, child, fields);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ("type".equals(key)) {
|
|
|
|
} else if ("type".equals(key)) {
|
|
|
|
QueryBuilder filterBuilder = QueryBuilders.existsQuery(path);
|
|
|
|
QueryBuilder filterBuilder = QueryBuilders.existsQuery(path);
|
|
|
|
QueryBuilder queryBuilder = QueryBuilders.constantScoreQuery(filterBuilder);
|
|
|
|
QueryBuilder queryBuilder = QueryBuilders.constantScoreQuery(filterBuilder);
|
|
|
|
SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client, SearchAction.INSTANCE);
|
|
|
|
SearchSourceBuilder builder = new SearchSourceBuilder()
|
|
|
|
SearchResponse searchResponse = searchRequestBuilder.setSize(0)
|
|
|
|
.query(queryBuilder)
|
|
|
|
.setIndices(index)
|
|
|
|
.size(0);
|
|
|
|
.setTypes(type)
|
|
|
|
SearchRequest searchRequest = new SearchRequest()
|
|
|
|
.setQuery(queryBuilder)
|
|
|
|
.indices(index)
|
|
|
|
.execute()
|
|
|
|
.source(builder);
|
|
|
|
.actionGet();
|
|
|
|
SearchResponse searchResponse =
|
|
|
|
|
|
|
|
client.execute(SearchAction.INSTANCE, searchRequest).actionGet();
|
|
|
|
fields.put(path, searchResponse.getHits().getTotalHits());
|
|
|
|
fields.put(path, searchResponse.getHits().getTotalHits());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -978,7 +990,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
|
|
|
|
|
|
|
|
private static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
|
|
|
|
private static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
|
|
|
|
Map<K, V> result = new LinkedHashMap<>();
|
|
|
|
Map<K, V> result = new LinkedHashMap<>();
|
|
|
|
map.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getValue))
|
|
|
|
map.entrySet().stream().sorted(Map.Entry.comparingByValue())
|
|
|
|
.forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
|
|
|
|
.forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1062,6 +1074,42 @@ public abstract class AbstractExtendedClient implements ExtendedClient {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class FailPruneResult implements IndexPruneResult {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> candidateIndices;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> indicesToDelete;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeleteIndexResponse response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FailPruneResult(List<String> candidateIndices, List<String> indicesToDelete,
|
|
|
|
|
|
|
|
DeleteIndexResponse response) {
|
|
|
|
|
|
|
|
this.candidateIndices = candidateIndices;
|
|
|
|
|
|
|
|
this.indicesToDelete = indicesToDelete;
|
|
|
|
|
|
|
|
this.response = response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public IndexPruneResult.State getState() {
|
|
|
|
|
|
|
|
return IndexPruneResult.State.FAIL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<String> getCandidateIndices() {
|
|
|
|
|
|
|
|
return candidateIndices;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<String> getDeletedIndices() {
|
|
|
|
|
|
|
|
return indicesToDelete;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean isAcknowledged() {
|
|
|
|
|
|
|
|
return response.isAcknowledged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class NothingToDoPruneResult implements IndexPruneResult {
|
|
|
|
private static class NothingToDoPruneResult implements IndexPruneResult {
|
|
|
|
|
|
|
|
|
|
|
|
List<String> candidateIndices;
|
|
|
|
List<String> candidateIndices;
|
|
|
|