Search in sources :

Example 1 with ContextPreparer

use of io.crate.action.job.ContextPreparer in project crate by crate.

the class DocLevelCollectTest method collect.

private Bucket collect(RoutedCollectPhase collectNode) throws Throwable {
    ContextPreparer contextPreparer = internalCluster().getDataNodeInstance(ContextPreparer.class);
    JobContextService contextService = internalCluster().getDataNodeInstance(JobContextService.class);
    SharedShardContexts sharedShardContexts = new SharedShardContexts(internalCluster().getDataNodeInstance(IndicesService.class));
    JobExecutionContext.Builder builder = contextService.newBuilder(collectNode.jobId());
    NodeOperation nodeOperation = NodeOperation.withDownstream(collectNode, mock(ExecutionPhase.class), (byte) 0, "remoteNode");
    List<CompletableFuture<Bucket>> results = contextPreparer.prepareOnRemote(ImmutableList.of(nodeOperation), builder, sharedShardContexts);
    JobExecutionContext context = contextService.createContext(builder);
    context.start();
    return results.get(0).get(2, TimeUnit.SECONDS);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SharedShardContexts(io.crate.action.job.SharedShardContexts) ContextPreparer(io.crate.action.job.ContextPreparer) IndicesService(org.elasticsearch.indices.IndicesService) JobExecutionContext(io.crate.jobs.JobExecutionContext) NodeOperation(io.crate.operation.NodeOperation) ExecutionPhase(io.crate.planner.node.ExecutionPhase) JobContextService(io.crate.jobs.JobContextService)

Aggregations

ContextPreparer (io.crate.action.job.ContextPreparer)1 SharedShardContexts (io.crate.action.job.SharedShardContexts)1 JobContextService (io.crate.jobs.JobContextService)1 JobExecutionContext (io.crate.jobs.JobExecutionContext)1 NodeOperation (io.crate.operation.NodeOperation)1 ExecutionPhase (io.crate.planner.node.ExecutionPhase)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 IndicesService (org.elasticsearch.indices.IndicesService)1