adapt to upstream java count api removal
Original commit: elastic/x-pack-elasticsearch@ea6c53b88e
This commit is contained in:
parent
f523a476e1
commit
baa36f7bae
|
@ -214,10 +214,6 @@ import org.elasticsearch.action.bulk.BulkAction;
|
|||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
import org.elasticsearch.action.count.CountAction;
|
||||
import org.elasticsearch.action.count.CountRequest;
|
||||
import org.elasticsearch.action.count.CountRequestBuilder;
|
||||
import org.elasticsearch.action.count.CountResponse;
|
||||
import org.elasticsearch.action.delete.DeleteAction;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteRequestBuilder;
|
||||
|
@ -257,8 +253,6 @@ import org.elasticsearch.action.suggest.SuggestAction;
|
|||
import org.elasticsearch.action.suggest.SuggestRequest;
|
||||
import org.elasticsearch.action.suggest.SuggestRequestBuilder;
|
||||
import org.elasticsearch.action.suggest.SuggestResponse;
|
||||
import org.elasticsearch.action.support.AdapterActionFuture;
|
||||
import org.elasticsearch.action.support.DelegatingActionListener;
|
||||
import org.elasticsearch.action.termvectors.*;
|
||||
import org.elasticsearch.action.update.UpdateAction;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
|
@ -506,28 +500,6 @@ public class SecuredClient implements Client {
|
|||
return new MultiSearchRequestBuilder(this, MultiSearchAction.INSTANCE);
|
||||
}
|
||||
|
||||
public ActionFuture<CountResponse> count(CountRequest request) {
|
||||
AdapterActionFuture actionFuture = new AdapterActionFuture<CountResponse, SearchResponse>() {
|
||||
protected CountResponse convert(SearchResponse listenerResponse) {
|
||||
return new CountResponse(listenerResponse);
|
||||
}
|
||||
};
|
||||
this.execute(SearchAction.INSTANCE, request.toSearchRequest(), actionFuture);
|
||||
return actionFuture;
|
||||
}
|
||||
|
||||
public void count(CountRequest request, final ActionListener<CountResponse> listener) {
|
||||
this.execute(SearchAction.INSTANCE, request.toSearchRequest(), new DelegatingActionListener<SearchResponse, CountResponse>(listener) {
|
||||
protected CountResponse getDelegatedFromInstigator(SearchResponse response) {
|
||||
return new CountResponse(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CountRequestBuilder prepareCount(String... indices) {
|
||||
return new CountRequestBuilder(this, CountAction.INSTANCE).setIndices(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<ExistsResponse> exists(ExistsRequest request) {
|
||||
return this.execute(ExistsAction.INSTANCE, request);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
|
|||
|
||||
securedFlush();
|
||||
securedRefresh();
|
||||
assertHitCount(client().prepareCount().get(), nbDocs);
|
||||
assertHitCount(client().prepareSearch().setSize(0).get(), nbDocs);
|
||||
|
||||
Collection<MarvelDoc> results = newClusterStateCollector().doCollect();
|
||||
assertThat(results, hasSize(1));
|
||||
|
@ -99,7 +99,7 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
|
|||
securedFlush();
|
||||
securedRefresh();
|
||||
for (int i = 0; i < nbIndices; i++) {
|
||||
assertHitCount(client().prepareCount("test-" + i).get(), docsPerIndex[i]);
|
||||
assertHitCount(client().prepareSearch("test-" + i).setSize(0).get(), docsPerIndex[i]);
|
||||
}
|
||||
|
||||
Collection<MarvelDoc> results = newClusterStateCollector().doCollect();
|
||||
|
|
|
@ -70,8 +70,8 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
client().prepareIndex("other", "bar").setSource("value", randomInt()).get();
|
||||
|
||||
flushAndRefresh();
|
||||
assertHitCount(client().prepareCount(indexName).get(), numDocs);
|
||||
assertHitCount(client().prepareCount("other").get(), 1L);
|
||||
assertHitCount(client().prepareSearch(indexName).setSize(0).get(), numDocs);
|
||||
assertHitCount(client().prepareSearch("other").setSize(0).get(), 1L);
|
||||
|
||||
logger.info("--> start second node");
|
||||
final String node2 = internalCluster().startNode();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
securedRefresh();
|
||||
securedEnsureGreen(indexName);
|
||||
|
||||
assertHitCount(client().prepareCount().get(), nbDocs);
|
||||
assertHitCount(client().prepareSearch().setSize(0).get(), nbDocs);
|
||||
|
||||
Collection<MarvelDoc> results = newIndexStatsCollector().doCollect();
|
||||
assertThat(results, hasSize(1));
|
||||
|
@ -92,7 +92,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
securedEnsureGreen(indexPrefix + "*");
|
||||
|
||||
for (int i = 0; i < nbIndices; i++) {
|
||||
assertHitCount(client().prepareCount(indexPrefix + i).get(), docsPerIndex[i]);
|
||||
assertHitCount(client().prepareSearch(indexPrefix + i).setSize(0).get(), docsPerIndex[i]);
|
||||
}
|
||||
|
||||
String clusterUUID = client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
|
|||
ensureGreen();
|
||||
refresh();
|
||||
|
||||
assertHitCount(client().prepareCount().get(), nbDocs);
|
||||
assertHitCount(client().prepareSearch().setSize(0).get(), nbDocs);
|
||||
|
||||
Collection<MarvelDoc> results = newShardsCollector().doCollect();
|
||||
assertThat(results, hasSize(getNumShards("test-shards").totalNumShards));
|
||||
|
@ -117,7 +117,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
|
|||
refresh();
|
||||
|
||||
for (int i = 0; i < nbIndices; i++) {
|
||||
assertHitCount(client().prepareCount(indexPrefix + String.valueOf(i)).get(), nbDocsPerIndex[i]);
|
||||
assertHitCount(client().prepareSearch(indexPrefix + String.valueOf(i)).setSize(0).get(), nbDocsPerIndex[i]);
|
||||
}
|
||||
|
||||
Collection<MarvelDoc> results = newShardsCollector().doCollect();
|
||||
|
|
|
@ -116,7 +116,7 @@ public class ClusterInfoTests extends MarvelIntegTestCase {
|
|||
securedFlush();
|
||||
securedRefresh();
|
||||
|
||||
assertHitCount(client().prepareCount()
|
||||
assertHitCount(client().prepareSearch().setSize(0)
|
||||
.setIndices(MarvelSettings.MARVEL_DATA_INDEX_NAME)
|
||||
.setTypes(ClusterInfoCollector.TYPE)
|
||||
.setQuery(QueryBuilders.boolQuery()
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ClusterStateTests extends MarvelIntegTestCase {
|
|||
DiscoveryNodes nodes = client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes();
|
||||
|
||||
logger.debug("--> ensure that the 'nodes' attributes of the cluster state document is not indexed");
|
||||
assertHitCount(client().prepareCount()
|
||||
assertHitCount(client().prepareSearch().setSize(0)
|
||||
.setTypes(ClusterStateCollector.TYPE)
|
||||
.setQuery(QueryBuilders.matchQuery("cluster_state.nodes." + nodes.masterNodeId() + ".name", nodes.masterNode().name())).get(), 0L);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.marvel.agent.renderer.indices;
|
||||
|
||||
import org.elasticsearch.action.count.CountResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -76,11 +75,12 @@ public class IndexStatsTests extends MarvelIntegTestCase {
|
|||
securedFlush(indices);
|
||||
securedRefresh();
|
||||
for (int i = 0; i < nbIndices; i++) {
|
||||
CountResponse count = client().prepareCount()
|
||||
SearchResponse count = client().prepareSearch()
|
||||
.setSize(0)
|
||||
.setTypes(IndexStatsCollector.TYPE)
|
||||
.setQuery(QueryBuilders.termQuery("index_stats.index", indices[i]))
|
||||
.get();
|
||||
assertThat(count.getCount(), greaterThan(0L));
|
||||
assertThat(count.getHits().totalHits(), greaterThan(0L));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -177,8 +177,8 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase {
|
|||
|
||||
protected void assertMarvelDocsCount(Matcher<Long> matcher, String... types) {
|
||||
try {
|
||||
long count = client().prepareCount(MarvelSettings.MARVEL_INDICES_PREFIX + "*")
|
||||
.setTypes(types).get().getCount();
|
||||
long count = client().prepareSearch(MarvelSettings.MARVEL_INDICES_PREFIX + "*").setSize(0)
|
||||
.setTypes(types).get().getHits().totalHits();
|
||||
logger.trace("--> searched for [{}] documents, found [{}]", Strings.arrayToCommaDelimitedString(types), count);
|
||||
assertThat(count, matcher);
|
||||
} catch (IndexNotFoundException e) {
|
||||
|
|
|
@ -51,7 +51,6 @@ indices:monitor/settings/get
|
|||
indices:monitor/shard_stores
|
||||
indices:monitor/stats
|
||||
indices:monitor/upgrade
|
||||
indices:data/read/count
|
||||
indices:data/read/exists
|
||||
indices:data/read/explain
|
||||
indices:data/read/field_stats
|
||||
|
|
|
@ -157,7 +157,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(deleteWatchResponse.isFound(), is(true));
|
||||
|
||||
refresh();
|
||||
assertHitCount(client().prepareCount(WatchStore.INDEX).get(), 0l);
|
||||
assertHitCount(client().prepareSearch(WatchStore.INDEX).setSize(0).get(), 0l);
|
||||
|
||||
// Deleting the same watch for the second time
|
||||
deleteWatchResponse = watcherClient.prepareDeleteWatch("_name").get();
|
||||
|
|
Loading…
Reference in New Issue