Exemple #1
0
  /**
   * Maps a single vertex vertex on the operator. If updaterank is true, finds a new place for the
   * vertex in the schedule. Otherwise, use the vertex rank to know where to schedule it.
   */
  private final void mapSingleVertex(
      MapperDAGVertex dagvertex, ComponentInstance operator, boolean updateRank)
      throws WorkflowException {
    MapperDAGVertex impvertex = translateInImplementationVertex(dagvertex);

    if (impvertex.getEffectiveOperator() != DesignTools.NO_COMPONENT_INSTANCE) {
      // Unmapping if necessary before mapping
      unmap(dagvertex);
    }

    // Testing if the vertex or its group can be mapped on the
    // target operator
    if (isMapable(impvertex, operator, false)
        || !updateRank
        || impvertex instanceof TransferVertex) {

      // Implementation property is set in both DAG and
      // implementation
      // Modifying effective operator of the vertex and all its
      // mapping set!
      dagvertex.setEffectiveOperator(operator);
      impvertex.setEffectiveOperator(operator);

      fireNewMappedVertex(impvertex, updateRank);

    } else {
      WorkflowLogger.getLogger()
          .log(
              Level.SEVERE,
              impvertex.toString() + " can not be mapped (single) on " + operator.toString());
    }
  }
Exemple #2
0
  /**
   * Looks for an operator able to execute currentvertex (preferably the given operator or an
   * operator with same type) If the boolean protectGroupMapping is true and at least one vertex is
   * mapped in the current vertex group, this unique operator is compared to the prefered one.
   * Otherwise, the prefered operator is checked of belonging to available operators of the group.
   *
   * @throws WorkflowException
   */
  @Override
  public final ComponentInstance findOperator(
      MapperDAGVertex currentvertex,
      ComponentInstance preferedOperator,
      boolean protectGroupMapping)
      throws WorkflowException {

    ComponentInstance adequateOp = null;
    List<ComponentInstance> opList = getCandidateOperators(currentvertex, protectGroupMapping);

    if (DesignTools.contains(opList, preferedOperator)) {
      adequateOp = preferedOperator;
    } else {

      // Search among the operators with same type than the prefered one
      for (ComponentInstance op : opList) {
        if (preferedOperator != null
            && op.getComponent()
                .getVlnv()
                .getName()
                .equals(preferedOperator.getComponent().getVlnv().getName())) {
          adequateOp = op;
        }
      }

      // Search among the operators with other type than the prefered one
      if (adequateOp == null) {
        for (ComponentInstance op : opList) {
          adequateOp = op;
          return adequateOp;
        }
      }
    }

    return adequateOp;
  }
Exemple #3
0
  /**
   * Maps a vertex and its non-trivial group. If the boolean remapGroup is true, the whole group is
   * forced to be unmapped and remapped.
   */
  private final void mapVertexWithGroup(
      MapperDAGVertex dagvertex, ComponentInstance operator, boolean updateRank, boolean remapGroup)
      throws WorkflowException {

    VertexMapping dagprop = dagvertex.getMapping();

    // Generating a list of vertices to remap in topological order
    List<MapperDAGVertex> vList = dagprop.getVertices((MapperDAG) dagvertex.getBase());
    List<MapperDAGVertex> orderedVList = new ArrayList<MapperDAGVertex>();
    // On the whole group otherwise
    CustomTopologicalIterator iterator = new CustomTopologicalIterator(dag, true);
    while (iterator.hasNext()) {
      MapperDAGVertex v = iterator.next();
      if (vList.contains(v)) {
        orderedVList.add(v);
      }
    }

    if (debugTraces) System.out.println("unmap and remap " + orderedVList + " on " + operator);

    for (MapperDAGVertex dv : orderedVList) {

      MapperDAGVertex dvi = translateInImplementationVertex(dv);
      ComponentInstance previousOperator = dvi.getEffectiveOperator();

      // We unmap systematically the main vertex (impvertex) if it has an
      // effectiveComponent and optionally its group
      boolean isToUnmap =
          (previousOperator != DesignTools.NO_COMPONENT_INSTANCE)
              && (dv.equals(dagvertex) || remapGroup);

      // We map transfer vertices, if rank is kept, and if mappable
      boolean isToMap =
          (dv.equals(dagvertex) || remapGroup)
              && (isMapable(dvi, operator, false) || !updateRank || dv instanceof TransferVertex);

      if (isToUnmap) {
        // Unmapping if necessary before mapping
        if (debugTraces) System.out.println("unmap " + dvi);
        unmap(dvi);

        if (debugTraces) System.out.println("unmapped " + dvi);
      }

      if (isToMap) {
        if (debugTraces) System.out.println("map " + dvi + " to " + operator);

        dv.setEffectiveOperator(operator);
        dvi.setEffectiveOperator(operator);

        fireNewMappedVertex(dvi, updateRank);

        if (debugTraces) System.out.println("mapped " + dvi);

      } else if (dv.equals(dagvertex) || remapGroup) {
        WorkflowLogger.getLogger()
            .log(
                Level.SEVERE,
                dagvertex.toString() + " can not be mapped (group) on " + operator.toString());
        dv.setEffectiveOperator(DesignTools.NO_COMPONENT_INSTANCE);
        dv.setEffectiveOperator(DesignTools.NO_COMPONENT_INSTANCE);
      }
    }

    if (debugTraces)
      System.out.println("unmapped and remapped " + orderedVList + " on " + operator);
  }