use of org.elasticsearch.search.slice.SliceBuilder in project elasticsearch by elastic.
the class ReindexRequestTests method testNoSliceWithWorkers.
public void testNoSliceWithWorkers() {
ReindexRequest reindex = newRequest();
reindex.getSearchRequest().source().slice(new SliceBuilder(0, 4));
reindex.setSlices(between(2, Integer.MAX_VALUE));
ActionRequestValidationException e = reindex.validate();
assertEquals("Validation Failed: 1: can't specify both slice and workers;", e.getMessage());
}
use of org.elasticsearch.search.slice.SliceBuilder in project hazelcast by hazelcast.
the class ElasticSourceP method init.
@Override
protected void init(@Nonnull Context context) throws Exception {
super.init(context);
logger = context.logger();
logger.fine("init");
client = configuration.clientFn().get();
SearchRequest sr = configuration.searchRequestFn().get();
sr.scroll(configuration.scrollKeepAlive());
if (configuration.isSlicingEnabled()) {
if (configuration.isCoLocatedReadingEnabled()) {
int sliceId = context.localProcessorIndex();
int totalSlices = context.localParallelism();
if (totalSlices > 1) {
logger.fine("Slice id=" + sliceId + ", max=" + totalSlices);
sr.source().slice(new SliceBuilder(sliceId, totalSlices));
}
} else {
int sliceId = context.globalProcessorIndex();
int totalSlices = context.totalParallelism();
if (totalSlices > 1) {
logger.fine("Slice id=" + sliceId + ", max=" + totalSlices);
sr.source().slice(new SliceBuilder(sliceId, totalSlices));
}
}
}
if (configuration.isCoLocatedReadingEnabled()) {
logger.fine("Assigned shards: " + shards);
if (shards.isEmpty()) {
traverser = Traversers.empty();
return;
}
Node node = createLocalElasticNode();
client.getLowLevelClient().setNodes(singleton(node));
String preference = "_shards:" + shards.stream().map(shard -> String.valueOf(shard.getShard())).collect(joining(",")) + "|_only_local";
sr.preference(preference);
}
scrollTraverser = new ElasticScrollTraverser(configuration, client, sr, logger);
traverser = scrollTraverser.map(configuration.mapToItemFn());
}
Aggregations