use of io.crate.operation.NodeOperation in project crate by crate.
the class JobRequest method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeLong(jobId.getMostSignificantBits());
out.writeLong(jobId.getLeastSignificantBits());
out.writeString(coordinatorNodeId);
out.writeVInt(nodeOperations.size());
for (NodeOperation nodeOperation : nodeOperations) {
nodeOperation.writeTo(out);
}
}
use of io.crate.operation.NodeOperation in project crate by crate.
the class ExecutionPhasesTaskTest method testGroupByServer.
@Test
public void testGroupByServer() throws Exception {
Routing twoNodeRouting = new Routing(TreeMapBuilder.<String, Map<String, List<Integer>>>newMapBuilder().put("node1", TreeMapBuilder.<String, List<Integer>>newMapBuilder().put("t1", Arrays.asList(1, 2)).map()).put("node2", TreeMapBuilder.<String, List<Integer>>newMapBuilder().put("t1", Arrays.asList(3, 4)).map()).map());
UUID jobId = UUID.randomUUID();
RoutedCollectPhase c1 = new RoutedCollectPhase(jobId, 1, "c1", twoNodeRouting, RowGranularity.DOC, ImmutableList.of(), ImmutableList.of(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
MergePhase m1 = new MergePhase(jobId, 2, "merge1", 2, Collections.emptyList(), ImmutableList.of(), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
m1.executionNodes(Sets.newHashSet("node3", "node4"));
MergePhase m2 = new MergePhase(jobId, 3, "merge2", 2, Collections.emptyList(), ImmutableList.of(), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
m2.executionNodes(Sets.newHashSet("node1", "node3"));
String localNodeId = "node1";
NodeOperation n1 = NodeOperation.withDownstream(c1, m1, (byte) 0, localNodeId);
NodeOperation n2 = NodeOperation.withDownstream(m1, m2, (byte) 0, localNodeId);
NodeOperation n3 = NodeOperation.withDownstream(m2, mock(ExecutionPhase.class), (byte) 0, localNodeId);
Map<String, Collection<NodeOperation>> groupByServer = NodeOperationGrouper.groupByServer(ImmutableList.of(n1, n2, n3));
assertThat(groupByServer.containsKey("node1"), is(true));
assertThat(groupByServer.get("node1"), Matchers.containsInAnyOrder(n1, n3));
assertThat(groupByServer.containsKey("node2"), is(true));
assertThat(groupByServer.get("node2"), Matchers.containsInAnyOrder(n1));
assertThat(groupByServer.containsKey("node3"), is(true));
assertThat(groupByServer.get("node3"), Matchers.containsInAnyOrder(n2, n3));
assertThat(groupByServer.containsKey("node4"), is(true));
assertThat(groupByServer.get("node4"), Matchers.containsInAnyOrder(n2));
}
use of io.crate.operation.NodeOperation 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);
}
use of io.crate.operation.NodeOperation in project crate by crate.
the class JobRequest method readFrom.
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
jobId = new UUID(in.readLong(), in.readLong());
coordinatorNodeId = in.readString();
int numNodeOperations = in.readVInt();
ArrayList<NodeOperation> nodeOperations = new ArrayList<>(numNodeOperations);
for (int i = 0; i < numNodeOperations; i++) {
nodeOperations.add(new NodeOperation(in));
}
this.nodeOperations = nodeOperations;
}
use of io.crate.operation.NodeOperation in project crate by crate.
the class DistributingDownstreamFactoryTest method createDownstream.
private BatchConsumer createDownstream(Set<String> downstreamExecutionNodes) {
UUID jobId = UUID.randomUUID();
Routing routing = new Routing(TreeMapBuilder.<String, Map<String, List<Integer>>>newMapBuilder().put("n1", TreeMapBuilder.<String, List<Integer>>newMapBuilder().put("i1", Arrays.asList(1, 2)).map()).map());
RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 1, "collect", routing, RowGranularity.DOC, ImmutableList.<Symbol>of(), ImmutableList.<Projection>of(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_MODULO);
MergePhase mergePhase = new MergePhase(jobId, 2, "merge", 1, Collections.emptyList(), ImmutableList.<DataType>of(LongType.INSTANCE), ImmutableList.<Projection>of(), DistributionInfo.DEFAULT_BROADCAST, null);
mergePhase.executionNodes(downstreamExecutionNodes);
NodeOperation nodeOperation = NodeOperation.withDownstream(collectPhase, mergePhase, (byte) 0, "nodeName");
return rowDownstreamFactory.create(nodeOperation, collectPhase.distributionInfo(), jobId, Paging.PAGE_SIZE);
}
Aggregations