/** * Exchanges input {@link Channel}. Will also update the {@link Channel}'s consumers appropriately. */ public void exchangeInputChannel(Channel currentChannel, Channel newChannel) { for (int inputIndex = 0; inputIndex < this.getNumInputChannels(); inputIndex++) { if (this.getInputChannel(inputIndex) == currentChannel) { currentChannel.getConsumers().remove(this); this.setInputChannel(inputIndex, null); newChannel.addConsumer(this, inputIndex); return; } } throw new IllegalArgumentException(String.format("%s is not an input of %s.", currentChannel, this)); }
private void connectToSuccessorTasks(int outputIndex, Platform platform, Collection<Activation> collector) { final OutputSlot<?> output = this.operator.getOutput(outputIndex); // TODO: Make generic: There might be multiple OutputSlots for final loop outputs (one for each iteration). final Junction junction = this.getJunction(output); LoggerFactory.getLogger(this.getClass()).debug("Connecting {} -> {}.", output, junction); assert junction != null : String.format("No junction found for %s.", output); this.executionTask.setOutputChannel(outputIndex, junction.getSourceChannel()); for (int targetIndex = 0; targetIndex < junction.getNumTargets(); targetIndex++) { final Channel targetChannel = junction.getTargetChannel(targetIndex); final InputSlot<?> targetInput = junction.getTargetInput(targetIndex); final ExecutionTask successorTask = ExecutionTaskFlowCompiler.this.getOrCreateExecutionTask((ExecutionOperator) targetInput.getOwner()); targetChannel.addConsumer(successorTask, targetInput.getIndex()); this.createActivation(targetInput.unchecked(), collector); } }
consumerActivator.executionTask = consumerTask; final Channel targetChannel = openJunction.getTargetChannel(targetIndex); targetChannel.addConsumer(consumerTask, targetInput.getIndex()); this.startActivations.add(new Activation(consumerActivator, targetInput.getIndex()));
@Override public Channel convert(Channel sourceChannel, Configuration configuration, Collection<OptimizationContext> optimizationContexts, CardinalityEstimate optCardinality) { // Create the ExecutionOperator. final ExecutionOperator executionOperator = this.executionOperatorFactory.apply(sourceChannel, configuration); assert executionOperator.getNumInputs() <= 1 && executionOperator.getNumOutputs() <= 1; executionOperator.setAuxiliary(true); // Set up the Channels and the ExecutionTask. final ExecutionTask task = new ExecutionTask(executionOperator, 1, 1); sourceChannel.addConsumer(task, 0); final Channel outputChannel = task.initializeOutputChannel(0, configuration); sourceChannel.addSibling(outputChannel); setCardinalityAndTimeEstimates(sourceChannel, optimizationContexts, optCardinality, task); return outputChannel; }