/** * Prints the instance's {@link ExecutionTask}s and {@link Channel}s. * * @return a {@link String} containing the textual representation */ public String getPlanAsString() { return this.getPlanAsString(""); }
/** * Prints the instance's {@link ExecutionTask}s and {@link Channel}s. * * @param indent will be used to indent every line of the textual representation * @return a {@link String} containing the textual representation */ public String getPlanAsString(String indent) { final StringBuilder sb = new StringBuilder(); this.getPlanAsString(sb, indent); if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\n') sb.setLength(sb.length() - 1); return sb.toString(); }
private void logStages(ExecutionPlan executionPlan) { if (this.logger.isInfoEnabled()) { StringBuilder sb = new StringBuilder(); Set<ExecutionStage> seenStages = new HashSet<>(); Queue<ExecutionStage> stagedStages = new LinkedList<>(executionPlan.getStartingStages()); ExecutionStage nextStage; while ((nextStage = stagedStages.poll()) != null) { sb.append(nextStage).append(":\n"); nextStage.getPlanAsString(sb, "* "); nextStage.getSuccessors().stream() .filter(seenStages::add) .forEach(stagedStages::add); } this.logger.info("Current execution plan:\n{}", executionPlan.toExtensiveString()); } }
/** * 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(); }
CrossPlatformExecutor.this.logger.info("Having {} execute {}:\n{}", executor, stage, stage.getPlanAsString("> ")); long startTime = System.currentTimeMillis();
/** * 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(); } }
assert this.stage.getAllTasks().size() == 1 : String.format("Loop head stage looks like this:\n%s", this.stage.getPlanAsString("! "));