Package eu.stratosphere.compiler

Examples of eu.stratosphere.compiler.CompilerException


            continue;
          }
         
          SourceAndDamReport res = in1.getSource().hasDamOnPathDownTo(candAtBrancher);
          if (res == NOT_FOUND) {
            throw new CompilerException("Bug: Tracing dams for deadlock detection is broken.");
          } else if (res == FOUND_SOURCE) {
            damOnAllLeftPaths = false;
          } else if (res == FOUND_SOURCE_AND_DAM) {
            someDamOnLeftPaths = true;
          } else {
            throw new CompilerException();
          }
        }
      }
     
      if (strategy.secondDam() == DamBehavior.FULL_DAM || in2.getLocalStrategy().dams() || in2.getTempMode().breaksPipeline()) {
        someDamOnRightPaths = true;
      } else {
        for (OptimizerNode brancher : this.hereJoinedBranches) {
          PlanNode candAtBrancher = in2.getSource().getCandidateAtBranchPoint(brancher);
         
          // not all candidates are found, because this list includes joined branched from both regular inputs and broadcast vars
          if (candAtBrancher == null) {
            continue;
          }
         
          SourceAndDamReport res = in2.getSource().hasDamOnPathDownTo(candAtBrancher);
          if (res == NOT_FOUND) {
            throw new CompilerException("Bug: Tracing dams for deadlock detection is broken.");
          } else if (res == FOUND_SOURCE) {
            damOnAllRightPaths = false;
          } else if (res == FOUND_SOURCE_AND_DAM) {
            someDamOnRightPaths = true;
          } else {
            throw new CompilerException();
          }
        }
      }
     
      // okay combinations are both all dam or both no dam
View Full Code Here


    if (merge) {
      final PlanNode successor = pspn.getOutgoingChannels().get(0).getTarget();
      headVertex = (JobTaskVertex) this.vertices.get(successor);
     
      if (headVertex == null) {
        throw new CompilerException(
          "Bug: Trying to merge solution set with its sucessor, but successor has not been created.");
      }
     
      // reset the vertex type to iteration head
      headVertex.setTaskClass(IterationHeadPactTask.class);
      headConfig = new TaskConfig(headVertex.getConfiguration());
      toReturn = null;
    } else {
      // instantiate the head vertex and give it a no-op driver as the driver strategy.
      // everything else happens in the post visit, after the input (the initial partial solution)
      // is connected.
      headVertex = new JobTaskVertex("PartialSolution ("+iteration.getNodeName()+")", this.jobGraph);
      headVertex.setTaskClass(IterationHeadPactTask.class);
      headConfig = new TaskConfig(headVertex.getConfiguration());
      headConfig.setDriver(NoOpDriver.class);
      toReturn = headVertex;
    }
   
    // create the iteration descriptor and the iteration to it
    IterationDescriptor descr = this.iterations.get(iteration);
    if (descr == null) {
      throw new CompilerException("Bug: Iteration descriptor was not created at when translating the iteration node.");
    }
    descr.setHeadTask(headVertex, headConfig);
   
    return toReturn;
  }
View Full Code Here

    if (merge) {
      final PlanNode successor = wspn.getOutgoingChannels().get(0).getTarget();
      headVertex = (JobTaskVertex) this.vertices.get(successor);
     
      if (headVertex == null) {
        throw new CompilerException(
          "Bug: Trying to merge solution set with its sucessor, but successor has not been created.");
      }
     
      // reset the vertex type to iteration head
      headVertex.setTaskClass(IterationHeadPactTask.class);
      headConfig = new TaskConfig(headVertex.getConfiguration());
      toReturn = null;
    } else {
      // instantiate the head vertex and give it a no-op driver as the driver strategy.
      // everything else happens in the post visit, after the input (the initial partial solution)
      // is connected.
      headVertex = new JobTaskVertex("IterationHead("+iteration.getNodeName()+")", this.jobGraph);
      headVertex.setTaskClass(IterationHeadPactTask.class);
      headConfig = new TaskConfig(headVertex.getConfiguration());
      headConfig.setDriver(NoOpDriver.class);
      toReturn = headVertex;
    }
   
    // create the iteration descriptor and the iteration to it
    IterationDescriptor descr = this.iterations.get(iteration);
    if (descr == null) {
      throw new CompilerException("Bug: Iteration descriptor was not created at when translating the iteration node.");
    }
    descr.setHeadTask(headVertex, headConfig);
   
    return toReturn;
  }
View Full Code Here

 
  @Override
  public void accept(Visitor<OptimizerNode> visitor) {
    if (visitor.preVisit(this)) {
      if (this.input1 == null || this.input2 == null) {
        throw new CompilerException();
      }
     
      getFirstPredecessorNode().accept(visitor);
      getSecondPredecessorNode().accept(visitor);
     
View Full Code Here

    // serializer
    if (isBroadcastChannel) {
      config.setBroadcastInputSerializer(channel.getSerializer(), inputNum);
     
      if (channel.getLocalStrategy() != LocalStrategy.NONE || (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE)) {
        throw new CompilerException("Found local strategy or temp mode on a broadcast variable channel.");
      } else {
        return;
      }
    } else {
      config.setInputSerializer(channel.getSerializer(), inputNum);
    }
   
    // local strategy
    if (channel.getLocalStrategy() != LocalStrategy.NONE) {
      config.setInputLocalStrategy(inputNum, channel.getLocalStrategy());
      if (channel.getLocalStrategyComparator() != null) {
        config.setInputComparator(channel.getLocalStrategyComparator(), inputNum);
      }
    }
   
    assignLocalStrategyResources(channel, config, inputNum);
   
    // materialization / caching
    if (channel.getTempMode() != null) {
      final TempMode tm = channel.getTempMode();

      boolean needsMemory = false;
      if (tm.breaksPipeline()) {
        config.setInputAsynchronouslyMaterialized(inputNum, true);
        needsMemory = true;
      }
      if (tm.isCached()) {
        config.setInputCached(inputNum, true);
        needsMemory = true;
      }
     
      if (needsMemory) {
        // sanity check
        if (tm == null || tm == TempMode.NONE || channel.getTempMemory() < 1) {
          throw new CompilerException("Bug in compiler: Inconsistent description of input materialization.");
        }
        config.setInputMaterializationMemory(inputNum, channel.getTempMemory());
      }
    }
  }
View Full Code Here

    final int numFinalOuts = headFinalOutputConfig.getNumOutputs();
    headConfig.setIterationHeadFinalOutputConfig(headFinalOutputConfig);
    headConfig.setIterationHeadIndexOfSyncOutput(numStepFunctionOuts + numFinalOuts);
    final long memForBackChannel = bulkNode.getMemoryPerSubTask();
    if (memForBackChannel <= 0) {
      throw new CompilerException("Bug: No memory has been assigned to the iteration back channel.");
    }
    headConfig.setBackChannelMemory(memForBackChannel);
   
    // --------------------------- create the sync task ---------------------------
    final JobOutputVertex sync = new JobOutputVertex("Sync(" +
          bulkNode.getNodeName() + ")", this.jobGraph);
    sync.setOutputClass(IterationSynchronizationSinkTask.class);
    sync.setNumberOfSubtasks(1);
    this.auxVertices.add(sync);
   
    final TaskConfig syncConfig = new TaskConfig(sync.getConfiguration());
    syncConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, headVertex.getNumberOfSubtasks());

    // set the number of iteration / convergence criterion for the sync
    final int maxNumIterations = bulkNode.getIterationNode().getIterationContract().getMaximumNumberOfIterations();
    if (maxNumIterations < 1) {
      throw new CompilerException("Cannot create bulk iteration with unspecified maximum number of iterations.");
    }
    syncConfig.setNumberOfIterations(maxNumIterations);
   
    // connect the sync task
    try {
      headVertex.connectTo(sync, ChannelType.NETWORK, DistributionPattern.POINTWISE);
    } catch (JobGraphDefinitionException e) {
      throw new CompilerException("Bug: Cannot connect head vertex to sync task.");
    }
   
   
    // ----------------------------- create the iteration tail ------------------------------
   
    final PlanNode rootOfTerminationCriterion = bulkNode.getRootOfTerminationCriterion();
    final PlanNode rootOfStepFunction = bulkNode.getRootOfStepFunction();
    final TaskConfig tailConfig;
   
    JobTaskVertex rootOfStepFunctionVertex = (JobTaskVertex) this.vertices.get(rootOfStepFunction);
    if (rootOfStepFunctionVertex == null) {
      // last op is chained
      final TaskInChain taskInChain = this.chainedTasks.get(rootOfStepFunction);
      if (taskInChain == null) {
        throw new CompilerException("Bug: Tail of step function not found as vertex or chained task.");
      }
      rootOfStepFunctionVertex = (JobTaskVertex) taskInChain.getContainingVertex();

      // the fake channel is statically typed to pact record. no data is sent over this channel anyways.
      tailConfig = taskInChain.getTaskConfig();
    } else {
      tailConfig = new TaskConfig(rootOfStepFunctionVertex.getConfiguration());
    }
   
    tailConfig.setIsWorksetUpdate();
   
    // No following termination criterion
    if(rootOfStepFunction.getOutgoingChannels().isEmpty()) {
     
      rootOfStepFunctionVertex.setTaskClass(IterationTailPactTask.class);
     
      tailConfig.setOutputSerializer(bulkNode.getSerializerForIterationChannel());
      tailConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
     
      // create the fake output task
      JobOutputVertex fakeTail = new JobOutputVertex("Fake Tail", this.jobGraph);
      fakeTail.setOutputClass(FakeOutputTask.class);
      fakeTail.setNumberOfSubtasks(headVertex.getNumberOfSubtasks());
      fakeTail.setNumberOfSubtasksPerInstance(headVertex.getNumberOfSubtasksPerInstance());
      this.auxVertices.add(fakeTail);
     
      // connect the fake tail
      try {
        rootOfStepFunctionVertex.connectTo(fakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
      } catch (JobGraphDefinitionException e) {
        throw new CompilerException("Bug: Cannot connect iteration tail vertex fake tail task");
      }
     
    }
   
   
    // create the fake output task for termination criterion, if needed
    final TaskConfig tailConfigOfTerminationCriterion;
    // If we have a termination criterion and it is not an intermediate node
    if(rootOfTerminationCriterion != null && rootOfTerminationCriterion.getOutgoingChannels().isEmpty()) {
      JobTaskVertex rootOfTerminationCriterionVertex = (JobTaskVertex) this.vertices.get(rootOfTerminationCriterion);
     
     
      if (rootOfTerminationCriterionVertex == null) {
        // last op is chained
        final TaskInChain taskInChain = this.chainedTasks.get(rootOfTerminationCriterion);
        if (taskInChain == null) {
          throw new CompilerException("Bug: Tail of termination criterion not found as vertex or chained task.");
        }
        rootOfTerminationCriterionVertex = (JobTaskVertex) taskInChain.getContainingVertex();

        // the fake channel is statically typed to pact record. no data is sent over this channel anyways.
        tailConfigOfTerminationCriterion = taskInChain.getTaskConfig();
      } else {
        tailConfigOfTerminationCriterion = new TaskConfig(rootOfTerminationCriterionVertex.getConfiguration());
      }
     
      rootOfTerminationCriterionVertex.setTaskClass(IterationTailPactTask.class);
      // Hack
      tailConfigOfTerminationCriterion.setIsSolutionSetUpdate();
      tailConfigOfTerminationCriterion.setOutputSerializer(bulkNode.getSerializerForIterationChannel());
      tailConfigOfTerminationCriterion.addOutputShipStrategy(ShipStrategyType.FORWARD);
     
      JobOutputVertex fakeTailTerminationCriterion = new JobOutputVertex("Fake Tail for Termination Criterion", this.jobGraph);
      fakeTailTerminationCriterion.setOutputClass(FakeOutputTask.class);
      fakeTailTerminationCriterion.setNumberOfSubtasks(headVertex.getNumberOfSubtasks());
      fakeTailTerminationCriterion.setNumberOfSubtasksPerInstance(headVertex.getNumberOfSubtasksPerInstance());
      this.auxVertices.add(fakeTailTerminationCriterion);
   
      // connect the fake tail
      try {
        rootOfTerminationCriterionVertex.connectTo(fakeTailTerminationCriterion, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
      } catch (JobGraphDefinitionException e) {
        throw new CompilerException("Bug: Cannot connect iteration tail vertex fake tail task for termination criterion");
      }
     
      // tell the head that it needs to wait for the solution set updates
      headConfig.setWaitForSolutionSetUpdate();
    }
   
    // ------------------- register the aggregators -------------------
    AggregatorRegistry aggs = bulkNode.getIterationNode().getIterationContract().getAggregators();
    Collection<AggregatorWithName<?>> allAggregators = aggs.getAllRegisteredAggregators();
   
    headConfig.addIterationAggregators(allAggregators);
    syncConfig.addIterationAggregators(allAggregators);
   
    String convAggName = aggs.getConvergenceCriterionAggregatorName();
    Class<? extends ConvergenceCriterion<?>> convCriterion = aggs.getConvergenceCriterion();
   
    if (convCriterion != null || convAggName != null) {
      if (convCriterion == null) {
        throw new CompilerException("Error: Convergence criterion aggregator set, but criterion is null.");
      }
      if (convAggName == null) {
        throw new CompilerException("Error: Aggregator convergence criterion set, but aggregator is null.");
      }
     
      syncConfig.setConvergenceCriterion(convAggName, convCriterion);
    }
  }
View Full Code Here

      final int numFinalOuts = headFinalOutputConfig.getNumOutputs();
      headConfig.setIterationHeadFinalOutputConfig(headFinalOutputConfig);
      headConfig.setIterationHeadIndexOfSyncOutput(numStepFunctionOuts + numFinalOuts);
      final long mem = iterNode.getMemoryPerSubTask();
      if (mem <= 0) {
        throw new CompilerException("Bug: No memory has been assigned to the workset iteration.");
      }
     
      headConfig.setIsWorksetIteration();
      headConfig.setBackChannelMemory(mem / 2);
      headConfig.setSolutionSetMemory(mem / 2);
     
      // set the solution set serializer and comparator
      headConfig.setSolutionSetSerializer(iterNode.getSolutionSetSerializer());
      headConfig.setSolutionSetComparator(iterNode.getSolutionSetComparator());
    }
   
    // --------------------------- create the sync task ---------------------------
    final TaskConfig syncConfig;
    {
      final JobOutputVertex sync = new JobOutputVertex("Sync (" +
            iterNode.getNodeName() + ")", this.jobGraph);
      sync.setOutputClass(IterationSynchronizationSinkTask.class);
      sync.setNumberOfSubtasks(1);
      this.auxVertices.add(sync);
     
      syncConfig = new TaskConfig(sync.getConfiguration());
      syncConfig.setGateIterativeWithNumberOfEventsUntilInterrupt(0, headVertex.getNumberOfSubtasks());
 
      // set the number of iteration / convergence criterion for the sync
      final int maxNumIterations = iterNode.getIterationNode().getIterationContract().getMaximumNumberOfIterations();
      if (maxNumIterations < 1) {
        throw new CompilerException("Cannot create workset iteration with unspecified maximum number of iterations.");
      }
      syncConfig.setNumberOfIterations(maxNumIterations);
     
      // connect the sync task
      try {
        headVertex.connectTo(sync, ChannelType.NETWORK, DistributionPattern.POINTWISE);
      } catch (JobGraphDefinitionException e) {
        throw new CompilerException("Bug: Cannot connect head vertex to sync task.");
      }
    }
   
    // ----------------------------- create the iteration tails -----------------------------
    // ----------------------- for next workset and solution set delta-----------------------

    {
      // we have three possible cases:
      // 1) Two tails, one for workset update, one for solution set update
      // 2) One tail for workset update, solution set update happens in an intermediate task
      // 3) One tail for solution set update, workset update happens in an intermediate task
     
      final PlanNode nextWorksetNode = iterNode.getNextWorkSetPlanNode();
      final PlanNode solutionDeltaNode = iterNode.getSolutionSetDeltaPlanNode();
     
      final boolean hasWorksetTail = nextWorksetNode.getOutgoingChannels().isEmpty();
      final boolean hasSolutionSetTail = (!iterNode.isImmediateSolutionSetUpdate()) || (!hasWorksetTail);
     
      {
        // get the vertex for the workset update
        final TaskConfig worksetTailConfig;
        JobTaskVertex nextWorksetVertex = (JobTaskVertex) this.vertices.get(nextWorksetNode);
        if (nextWorksetVertex == null) {
          // nextWorksetVertex is chained
          TaskInChain taskInChain = this.chainedTasks.get(nextWorksetNode);
          if (taskInChain == null) {
            throw new CompilerException("Bug: Next workset node not found as vertex or chained task.");
          }
          nextWorksetVertex = (JobTaskVertex) taskInChain.getContainingVertex();
          worksetTailConfig = taskInChain.getTaskConfig();
        } else {
          worksetTailConfig = new TaskConfig(nextWorksetVertex.getConfiguration());
        }
       
        // mark the node to perform workset updates
        worksetTailConfig.setIsWorksetIteration();
        worksetTailConfig.setIsWorksetUpdate();
       
        if (hasWorksetTail) {
          nextWorksetVertex.setTaskClass(IterationTailPactTask.class);
         
          worksetTailConfig.setOutputSerializer(iterNode.getWorksetSerializer());
          worksetTailConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
         
          // create the fake output task
          JobOutputVertex fakeTail = new JobOutputVertex("Fake Tail", this.jobGraph);
          fakeTail.setOutputClass(FakeOutputTask.class);
          fakeTail.setNumberOfSubtasks(headVertex.getNumberOfSubtasks());
          fakeTail.setNumberOfSubtasksPerInstance(headVertex.getNumberOfSubtasksPerInstance());
          this.auxVertices.add(fakeTail);
         
          // connect the fake tail
          try {
            nextWorksetVertex.connectTo(fakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
          } catch (JobGraphDefinitionException e) {
            throw new CompilerException("Bug: Cannot connect iteration tail vertex fake tail task");
          }
        }
      }
      {
        final TaskConfig solutionDeltaConfig;
        JobTaskVertex solutionDeltaVertex = (JobTaskVertex) this.vertices.get(solutionDeltaNode);
        if (solutionDeltaVertex == null) {
          // last op is chained
          TaskInChain taskInChain = this.chainedTasks.get(solutionDeltaNode);
          if (taskInChain == null) {
            throw new CompilerException("Bug: Solution Set Delta not found as vertex or chained task.");
          }
          solutionDeltaVertex = (JobTaskVertex) taskInChain.getContainingVertex();
          solutionDeltaConfig = taskInChain.getTaskConfig();
        } else {
          solutionDeltaConfig = new TaskConfig(solutionDeltaVertex.getConfiguration());
        }
       
        solutionDeltaConfig.setIsWorksetIteration();
        solutionDeltaConfig.setIsSolutionSetUpdate();
       
        if (hasSolutionSetTail) {
          solutionDeltaVertex.setTaskClass(IterationTailPactTask.class);
         
          solutionDeltaConfig.setOutputSerializer(iterNode.getSolutionSetSerializer());
          solutionDeltaConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
 
          // create the fake output task
          JobOutputVertex fakeTail = new JobOutputVertex("Fake Tail", this.jobGraph);
          fakeTail.setOutputClass(FakeOutputTask.class);
          fakeTail.setNumberOfSubtasks(headVertex.getNumberOfSubtasks());
          fakeTail.setNumberOfSubtasksPerInstance(headVertex.getNumberOfSubtasksPerInstance());
          this.auxVertices.add(fakeTail);
         
          // connect the fake tail
          try {
            solutionDeltaVertex.connectTo(fakeTail, ChannelType.IN_MEMORY, DistributionPattern.POINTWISE);
          } catch (JobGraphDefinitionException e) {
            throw new CompilerException("Bug: Cannot connect iteration tail vertex fake tail task");
          }
         
          // tell the head that it needs to wait for the solution set updates
          headConfig.setWaitForSolutionSetUpdate();
        }
        else {
          // no tail, intermediate update. must be immediate update
          if (!iterNode.isImmediateSolutionSetUpdate()) {
            throw new CompilerException("A solution set update without dedicated tail is not set to perform immediate updates.");
          }
          solutionDeltaConfig.setIsSolutionSetUpdateWithoutReprobe();
        }
      }
    }
   
    // ------------------- register the aggregators -------------------
    AggregatorRegistry aggs = iterNode.getIterationNode().getIterationContract().getAggregators();
    Collection<AggregatorWithName<?>> allAggregators = aggs.getAllRegisteredAggregators();
   
    for (AggregatorWithName<?> agg : allAggregators) {
      if (agg.getName().equals(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME)) {
        throw new CompilerException("User defined aggregator used the same name as built-in workset " +
            "termination check aggregator: " + WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);
      }
    }
   
    headConfig.addIterationAggregators(allAggregators);
    syncConfig.addIterationAggregators(allAggregators);
   
    String convAggName = aggs.getConvergenceCriterionAggregatorName();
    Class<? extends ConvergenceCriterion<?>> convCriterion = aggs.getConvergenceCriterion();
   
    if (convCriterion != null || convAggName != null) {
      throw new CompilerException("Error: Cannot use custom convergence criterion with workset iteration. Workset iterations have implicit convergence criterion where workset is empty.");
    }
   
    headConfig.addIterationAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, LongSumAggregator.class);
    syncConfig.addIterationAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, LongSumAggregator.class);
    syncConfig.setConvergenceCriterion(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, WorksetEmptyConvergenceCriterion.class);
View Full Code Here

  public void accept(Visitor<OptimizerNode> visitor) {
    if (visitor.preVisit(this)) {
      if (getPredecessorNode() != null) {
        getPredecessorNode().accept(visitor);
      } else {
        throw new CompilerException();
      }
      visitor.postVisit(this);
    }
  }
View Full Code Here

          PactCompiler.LOG.warn("Strategy hint for Reduce Pact '" + getPactContract().getName() +
            "' desires combinable reduce, but user function is not marked combinable.");
        }
        useCombiner = true;
      } else {
        throw new CompilerException("Invalid local strategy hint for match contract: " + localStrategy);
      }
    } else {
      useCombiner = isCombineable();
    }
   
View Full Code Here

        break;
      case RANGE_PARTITIONED:
        channel.setShipStrategy(ShipStrategyType.PARTITION_RANGE, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
        break;
      default:
        throw new CompilerException();
    }
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.compiler.CompilerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.