/** * Notifies this instance that it has been activated. */ public void noteActivation() { if (this.stage.isLoopHead()) this.loopContext.activateNextIteration(); } }
/** * Retrieves the {@link LoopHeadOperator} {@link ExecutionTask} in this instance. This instance must be a * loop head. * * @return the {@link LoopHeadOperator} {@link ExecutionTask} * @see #isLoopHead() */ public ExecutionTask getLoopHeadTask() { assert this.isLoopHead(); return RheemCollections.getSingle(this.getAllTasks()); }
/** * Creates a {@link String} representation of this instance. * * @param isStriclyOrdering whether {@link ExecutionStage}s should be listed only after <i>all</i> their predecessors * @return the {@link String} representation */ public String toExtensiveString(boolean isStriclyOrdering) { StringBuilder sb = new StringBuilder(); Counter<ExecutionStage> stageActivationCounter = new Counter<>(); Queue<ExecutionStage> activatedStages = new LinkedList<>(this.startingStages); Set<ExecutionStage> seenStages = new HashSet<>(); while (!activatedStages.isEmpty()) { while (!activatedStages.isEmpty()) { final ExecutionStage stage = activatedStages.poll(); if (!seenStages.add(stage)) continue; sb.append(">>> ").append(stage).append(":\n"); stage.getPlanAsString(sb, "> "); sb.append("\n"); for (ExecutionStage successor : stage.getSuccessors()) { final int count = stageActivationCounter.add(successor, 1); if (!isStriclyOrdering || count == successor.getPredecessors().size() || successor.isLoopHead()) { activatedStages.add(successor); } } } } return sb.toString(); }
public List<Map> toJsonList() { Counter<ExecutionStage> stageActivationCounter = new Counter<>(); Queue<ExecutionStage> activatedStages = new LinkedList<>(this.startingStages); Set<ExecutionStage> seenStages = new HashSet<>(); ArrayList<Map> allStages = new ArrayList<>(); while (!activatedStages.isEmpty()) { final ExecutionStage stage = activatedStages.poll(); if (!seenStages.add(stage)) continue; Map stageMap = stage.toJsonMap(); // Better way to put sequence number ? stageMap.put("sequence_number", allStages.size()); allStages.add(stageMap); for (ExecutionStage successor : stage.getSuccessors()) { final int count = stageActivationCounter.add(successor, 1); if (count == successor.getPredecessors().size() || successor.isLoopHead()) { activatedStages.add(successor); } } } return allStages; }
if (stage.isLoopHead()) { this.crossPlatformExecutor.getOrCreateLoopContext(stage.getLoop()).scrapPreviousTransitionContext();
/** * Tries to execute the given {@link ExecutionStage}. * * @param stageActivator that should be executed * @return whether the {@link ExecutionStage} was really executed */ private void execute(StageActivator stageActivator) { final ExecutionStage stage = stageActivator.getStage(); final OptimizationContext optimizationContext = stageActivator.getOptimizationContext(); // Find parts of the stage to instrument. this.instrumentationStrategy.applyTo(stage); // Obtain an Executor for the stage. Executor executor = this.getOrCreateExecutorFor(stage); // Have the execution done. CrossPlatformExecutor.this.logger.info("Having {} execute {}:\n{}", executor, stage, stage.getPlanAsString("> ")); long startTime = System.currentTimeMillis(); executor.execute(stage, optimizationContext, this); long finishTime = System.currentTimeMillis(); CrossPlatformExecutor.this.logger.info("Executed {} in {}.", stage, Formats.formatDuration(finishTime - startTime, true)); // Remember that we have executed the stage. this.completedStages.add(stage); if (stage.isLoopHead()) { this.getOrCreateLoopContext(stage.getLoop()).scrapPreviousTransitionContext(); } }
/** * Try to satisfy the input {@link ChannelInstance} requirements by updating {@link #inputChannelInstances}. * * @return whether the activation is possible */ boolean updateInputChannelInstances() { boolean isMiscChannelsReady = this.updateChannelInstances(this.miscInboundChannels, false); boolean isLoopChannelsReady = true; if (this.stage.isLoopHead()) { LoopHeadOperator loopOperator = (LoopHeadOperator) this.stage.getLoopHeadTask().getOperator(); switch (loopOperator.getState()) { case NOT_STARTED: isLoopChannelsReady = this.updateChannelInstances(this.initializationInboundChannels, false); break; case RUNNING: isLoopChannelsReady = this.updateChannelInstances(this.iterationInboundChannels, true); break; default: logger.warn("Tried to update input channel instances for finished {}.", this.stage); isLoopChannelsReady = false; } } return isMiscChannelsReady && isLoopChannelsReady; }
if (this.stage.isLoopHead()) { assert this.stage.getAllTasks().size() == 1 : String.format("Loop head stage looks like this:\n%s", this.stage.getPlanAsString("! "));
if (processedStage.getLoop() == successorStage.getLoop()) { if (successorStage.isLoopHead()) {