use of io.crate.execution.engine.collect.sources.ShardCollectorProviderFactory in project crate by crate.
the class RemoteCollectorFactory method createCollector.
/**
* create a RemoteCollector
* The RemoteCollector will collect data from another node using a wormhole as if it was collecting on this node.
* <p>
* This should only be used if a shard is not available on the current node due to a relocation
*/
public CompletableFuture<BatchIterator<Row>> createCollector(ShardId shardId, RoutedCollectPhase collectPhase, CollectTask collectTask, ShardCollectorProviderFactory shardCollectorProviderFactory) {
ShardStateObserver shardStateObserver = new ShardStateObserver(clusterService);
CompletableFuture<ShardRouting> shardBecameActive = shardStateObserver.waitForActiveShard(shardId);
Runnable onClose = () -> {
};
Consumer<Throwable> kill = killReason -> {
shardBecameActive.cancel(true);
shardBecameActive.completeExceptionally(killReason);
};
return shardBecameActive.thenApply(activePrimaryRouting -> CollectingBatchIterator.newInstance(onClose, kill, () -> retrieveRows(activePrimaryRouting, collectPhase, collectTask, shardCollectorProviderFactory), true));
}
Aggregations