Program: 56108
Project: 56108
Buggy source:
/** 
 * Translates the given pact plan in to an OptimizedPlan, where all nodes have their local strategy assigned and all channels have a shipping strategy assigned. The process goes through several phases: <ol> <li>Create <tt>OptimizerNode</tt> representations of the PACTs, assign parallelism and compute size estimates.</li> <li>Compute interesting properties and auxiliary structures.</li> <li>Enumerate plan alternatives. This cannot be done in the same step as the interesting property computation (as opposed to the Database approaches), because we support plans that are not trees.</li> </ol>
 * @param pactPlan The PACT plan to be translated.
 * @return The optimized plan.
 * @throws CompilerException Thrown, if the plan is invalid or the optimizer encountered an inconsistent situation during the compilation process.
 */
public OptimizedPlan compile(Plan pactPlan) throws CompilerException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + pactPlan.getJobName() + '\'');
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str");
  }
  Map<InstanceType,InstanceTypeDescription> instances=null;
  JobManagerConnector jmc=new JobManagerConnector(this.jobManagerAddress);
  Thread connectorThread=new Thread(jmc,"String_Node_Str");
  connectorThread.setDaemon(true);
  connectorThread.start();
  try {
    jmc.waitForCompletion();
    instances=jmc.instances;
    if (instances == null) {
      throw new NullPointerException("String_Node_Str");
    }
  }
 catch (  Throwable t) {
    throw new CompilerException("String_Node_Str" + t.getMessage(),t);
  }
  int maxMachinesJob=pactPlan.getMaxNumberMachines();
  if (maxMachinesJob < 1) {
    maxMachinesJob=this.maxMachines;
  }
 else   if (this.maxMachines >= 1) {
    if (maxMachinesJob > this.maxMachines && LOG.isWarnEnabled()) {
      LOG.warn("String_Node_Str" + maxMachinesJob + "String_Node_Str"+ this.maxMachines+ "String_Node_Str");
    }
    maxMachinesJob=Math.min(maxMachinesJob,this.maxMachines);
  }
  InstanceTypeDescription type=getType(instances);
  String instanceName=type.getInstanceType().getIdentifier();
  long memoryPerInstance=type.getHardwareDescription().getSizeOfFreeMemory();
  int memoryMegabytes=(int)(memoryPerInstance >>> 20);
  int numInstances=type.getMaximumNumberOfAvailableInstances();
  if (maxMachinesJob < 1) {
    maxMachinesJob=numInstances;
  }
 else   if (maxMachinesJob > numInstances) {
    maxMachinesJob=numInstances;
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + maxMachinesJob + "String_Node_Str");
    }
  }
  int defaultParallelism=this.defaultDegreeOfParallelism;
  if (defaultParallelism < 1) {
    defaultParallelism=maxMachinesJob * defaultIntraNodeParallelism;
  }
 else   if (defaultParallelism > maxMachinesJob * defaultIntraNodeParallelism) {
    int oldParallelism=defaultParallelism;
    defaultParallelism=maxMachinesJob * defaultIntraNodeParallelism;
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + oldParallelism + "String_Node_Str"+ defaultParallelism+ "String_Node_Str"+ maxMachinesJob+ "String_Node_Str"+ defaultIntraNodeParallelism);
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + defaultParallelism + "String_Node_Str"+ this.defaultIntraNodeParallelism+ '.');
    if (maxMachines > 0) {
      LOG.debug("String_Node_Str" + maxMachines + "String_Node_Str");
    }
  }
  GraphCreatingVisitor graphCreator=new GraphCreatingVisitor(this.statistics,maxMachinesJob,defaultParallelism,this.defaultIntraNodeParallelism,true);
  pactPlan.accept(graphCreator);
  OptimizerNode rootNode=null;
  if (graphCreator.sinks.size() == 1) {
    rootNode=graphCreator.sinks.get(0);
  }
 else   if (graphCreator.sinks.size() > 1) {
    Iterator<DataSinkNode> iter=graphCreator.sinks.iterator();
    rootNode=iter.next();
    int id=graphCreator.getId();
    while (iter.hasNext()) {
      rootNode=new SinkJoiner(rootNode,iter.next());
      rootNode.SetId(id++);
    }
  }
 else {
    throw new CompilerException("String_Node_Str");
  }
  InterestingPropertyAndBranchesVisitor propsVisitor=new InterestingPropertyAndBranchesVisitor(this.costEstimator);
  rootNode.accept(propsVisitor);
  List<? extends OptimizerNode> bestPlan=rootNode.getAlternativePlans(this.costEstimator);
  if (bestPlan.size() != 1) {
    throw new CompilerException("String_Node_Str");
  }
  OptimizerNode bestPlanRoot=bestPlan.get(0);
  List<DataSinkNode> bestPlanSinks=new ArrayList<DataSinkNode>(4);
  if (bestPlanRoot instanceof DataSinkNode) {
    bestPlanSinks.add((DataSinkNode)bestPlanRoot);
  }
 else   if (bestPlanRoot instanceof SinkJoiner) {
    ((SinkJoiner)bestPlanRoot).getDataSinks(bestPlanSinks);
  }
  OptimizedPlan plan=new PlanFinalizer().createFinalPlan(bestPlanSinks,pactPlan.getJobName(),memoryMegabytes);
  plan.setInstanceTypeName(instanceName);
  insertTempConnection(plan);
  return plan;
}

Fixed version (ground truth):
/** 
 * Translates the given pact plan in to an OptimizedPlan, where all nodes have their local strategy assigned and all channels have a shipping strategy assigned. The process goes through several phases: <ol> <li>Create <tt>OptimizerNode</tt> representations of the PACTs, assign parallelism and compute size estimates.</li> <li>Compute interesting properties and auxiliary structures.</li> <li>Enumerate plan alternatives. This cannot be done in the same step as the interesting property computation (as opposed to the Database approaches), because we support plans that are not trees.</li> </ol>
 * @param pactPlan The PACT plan to be translated.
 * @param type The instance type to schedule the execution on. Used also to determine the amount of memoryavailable to the tasks.
 * @return The optimized plan.
 * @throws CompilerException Thrown, if the plan is invalid or the optimizer encountered an inconsistent situation during the compilation process.
 */
public OptimizedPlan compile(Plan pactPlan,InstanceTypeDescription type) throws CompilerException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + pactPlan.getJobName() + '\'');
  }
  String instanceName=type.getInstanceType().getIdentifier();
  long memoryPerInstance=type.getHardwareDescription().getSizeOfFreeMemory();
  int memoryMegabytes=(int)(memoryPerInstance >>> 20);
  int numInstances=type.getMaximumNumberOfAvailableInstances();
  int maxMachinesJob=pactPlan.getMaxNumberMachines();
  if (maxMachinesJob < 1) {
    maxMachinesJob=this.maxMachines;
  }
 else   if (this.maxMachines >= 1) {
    if (maxMachinesJob > this.maxMachines && LOG.isWarnEnabled()) {
      LOG.warn("String_Node_Str" + maxMachinesJob + "String_Node_Str"+ this.maxMachines+ "String_Node_Str");
    }
    maxMachinesJob=Math.min(maxMachinesJob,this.maxMachines);
  }
  if (maxMachinesJob < 1) {
    maxMachinesJob=numInstances;
  }
 else   if (maxMachinesJob > numInstances) {
    maxMachinesJob=numInstances;
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + maxMachinesJob + "String_Node_Str");
    }
  }
  int defaultParallelism=this.defaultDegreeOfParallelism;
  if (defaultParallelism < 1) {
    defaultParallelism=maxMachinesJob * defaultIntraNodeParallelism;
  }
 else   if (defaultParallelism > maxMachinesJob * defaultIntraNodeParallelism) {
    int oldParallelism=defaultParallelism;
    defaultParallelism=maxMachinesJob * defaultIntraNodeParallelism;
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + oldParallelism + "String_Node_Str"+ defaultParallelism+ "String_Node_Str"+ maxMachinesJob+ "String_Node_Str"+ defaultIntraNodeParallelism);
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + defaultParallelism + "String_Node_Str"+ this.defaultIntraNodeParallelism+ '.');
    if (maxMachines > 0) {
      LOG.debug("String_Node_Str" + maxMachines + "String_Node_Str");
    }
  }
  GraphCreatingVisitor graphCreator=new GraphCreatingVisitor(this.statistics,maxMachinesJob,defaultParallelism,this.defaultIntraNodeParallelism,true);
  pactPlan.accept(graphCreator);
  OptimizerNode rootNode=null;
  if (graphCreator.sinks.size() == 1) {
    rootNode=graphCreator.sinks.get(0);
  }
 else   if (graphCreator.sinks.size() > 1) {
    Iterator<DataSinkNode> iter=graphCreator.sinks.iterator();
    rootNode=iter.next();
    int id=graphCreator.getId();
    while (iter.hasNext()) {
      rootNode=new SinkJoiner(rootNode,iter.next());
      rootNode.SetId(id++);
    }
  }
 else {
    throw new CompilerException("String_Node_Str");
  }
  InterestingPropertyAndBranchesVisitor propsVisitor=new InterestingPropertyAndBranchesVisitor(this.costEstimator);
  rootNode.accept(propsVisitor);
  List<? extends OptimizerNode> bestPlan=rootNode.getAlternativePlans(this.costEstimator);
  if (bestPlan.size() != 1) {
    throw new CompilerException("String_Node_Str");
  }
  OptimizerNode bestPlanRoot=bestPlan.get(0);
  List<DataSinkNode> bestPlanSinks=new ArrayList<DataSinkNode>(4);
  if (bestPlanRoot instanceof DataSinkNode) {
    bestPlanSinks.add((DataSinkNode)bestPlanRoot);
  }
 else   if (bestPlanRoot instanceof SinkJoiner) {
    ((SinkJoiner)bestPlanRoot).getDataSinks(bestPlanSinks);
  }
  OptimizedPlan plan=new PlanFinalizer().createFinalPlan(bestPlanSinks,pactPlan.getJobName(),memoryMegabytes);
  plan.setInstanceTypeName(instanceName);
  insertTempConnection(plan);
  return plan;
}