use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessorWithParallelism_thenUseSlicingBasedOnGlobalValues.
@Test
public void when_runProcessorWithParallelism_thenUseSlicingBasedOnGlobalValues() throws Exception {
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(0, EQUAL_TO), Float.NaN));
TestSupport testSupport = runProcessor((r) -> RequestOptions.DEFAULT, emptyList(), true, false);
testSupport.localProcessorIndex(1);
testSupport.localParallelism(2);
testSupport.globalProcessorIndex(4);
testSupport.totalParallelism(6);
testSupport.expectOutput(emptyList());
ArgumentCaptor<SearchRequest> captor = forClass(SearchRequest.class);
verify(mockClient).search(captor.capture(), any());
SearchRequest request = captor.getValue();
SliceBuilder slice = request.source().slice();
// Slicing across all, should use global index / total parallelism
assertThat(slice.getId()).isEqualTo(4);
assertThat(slice.getMax()).isEqualTo(6);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessorWithCoLocation_thenSearchShardsWithPreference.
@Test
public void when_runProcessorWithCoLocation_thenSearchShardsWithPreference() throws Exception {
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(0, EQUAL_TO), Float.NaN));
TestSupport processor = runProcessorWithCoLocation(newArrayList(new Shard("my-index", 0, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1"), new Shard("my-index", 1, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1"), new Shard("my-index", 2, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1")));
processor.expectOutput(emptyList());
ArgumentCaptor<SearchRequest> captor = forClass(SearchRequest.class);
verify(mockClient).search(captor.capture(), any());
SearchRequest request = captor.getValue();
assertThat(request.preference()).isEqualTo("_shards:0,1,2|_only_local");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessor_then_executeSearchRequestWithScroll.
@Test
public void when_runProcessor_then_executeSearchRequestWithScroll() throws Exception {
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(0, EQUAL_TO), Float.NaN));
TestSupport support = runProcessor();
support.expectOutput(emptyList());
ArgumentCaptor<SearchRequest> captor = forClass(SearchRequest.class);
verify(mockClient).search(captor.capture(), any());
SearchRequest request = captor.getValue();
assertThat(request.scroll().keepAlive().getStringRep()).isEqualTo(KEEP_ALIVE);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project hazelcast by hazelcast.
the class ElasticSourcePTest method when_runProcessorWithCoLocationAndSlicing_thenUseSlicingBasedOnLocalValues.
@Test
public void when_runProcessorWithCoLocationAndSlicing_thenUseSlicingBasedOnLocalValues() throws Exception {
when(response.getHits()).thenReturn(new SearchHits(new SearchHit[] {}, new TotalHits(0, EQUAL_TO), Float.NaN));
TestSupport testSupport = runProcessor((r) -> RequestOptions.DEFAULT, newArrayList(new Shard("my-index", 0, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1"), new Shard("my-index", 1, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1"), new Shard("my-index", 2, Prirep.p, 42, "STARTED", "10.0.0.1", "10.0.0.1:9200", "es1")), true, true);
testSupport.localProcessorIndex(1);
testSupport.localParallelism(2);
testSupport.globalProcessorIndex(4);
testSupport.totalParallelism(6);
testSupport.expectOutput(emptyList());
ArgumentCaptor<SearchRequest> captor = forClass(SearchRequest.class);
verify(mockClient).search(captor.capture(), any());
SearchRequest request = captor.getValue();
SliceBuilder slice = request.source().slice();
// Slicing across single node, should use local values
assertThat(slice.getId()).isEqualTo(1);
assertThat(slice.getMax()).isEqualTo(2);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project hazelcast by hazelcast.
the class BaseElasticTest method assertSingleDocument.
protected void assertSingleDocument(String id, String name) throws IOException {
SearchResponse response = elasticClient.search(new SearchRequest("my-index"), DEFAULT);
SearchHit[] hits = response.getHits().getHits();
assertThat(hits).hasSize(1);
Map<String, Object> document = hits[0].getSourceAsMap();
assertThat(document).contains(entry("id", id), entry("name", name));
}
Aggregations