Ejemplo n.º 1
0
  protected void updatePredecessorsFor(Host host) {
    NetID pre = getOverlayPredecessor(host);
    EdgeHandle old_pre = predecessors.get(host);
    // log.debug("PREDECESSORS: " + pre + "|" + ((old_pre !=
    // null)?old_pre.getTo():"null"));

    if (pre == null) {
      if (old_pre != null) {
        old_pre.remove();
      }
    } else if (old_pre == null || !pre.equals(old_pre.getTo())) {
      if (old_pre != null) {
        old_pre.remove();
      }
      EdgeHandle newEdge = this.addEdge(netID(host), pre, Color.CYAN, "predecessor");
      predecessors.put(host, newEdge);
    }
  }
Ejemplo n.º 2
0
  private void refreshRingEdgesForNetId(NetID netid, AbstractChordRoutingTable crt) {
    if (crt == null) {
      return;
    }
    AbstractChordContact[] ue = ((ChordRoutingTable) crt).getRingEdgesAsArray();
    LinkedHashSet<AbstractChordContact> ue_set =
        new LinkedHashSet<AbstractChordContact>(Arrays.asList(ue));
    if (ue_set.contains(null)) {
      ue_set.remove(null);
    }

    if (ue != null) {

      Set<EdgeHandle> vis_ue = ringEdges.get(netid);
      if (vis_ue == null) {
        vis_ue = new LinkedHashSet<EdgeHandle>();
        ringEdges.put(netid, vis_ue);
      }

      // delete all edges that do not exist nomore.
      for (EdgeHandle h : vis_ue) {
        if (h == null) {
          continue;
        }

        boolean stillInUse = false;

        for (AbstractChordContact con : ue_set) {
          NetID newNetID;
          if (((ChordContact) con).isRealNode()) {
            newNetID = con.getTransInfo().getNetId();
          } else {
            newNetID = virtualNodes.get(con.getOverlayID());
          }

          if (h.getTo() == newNetID) {
            stillInUse = true;
          }
        }

        if (!stillInUse) {
          h.remove();
        }
      }

      // add all edges that are new
      for (AbstractChordContact con : ue_set) {
        NetID newNetID;
        if (((ChordContact) con).isRealNode()) {
          newNetID = con.getTransInfo().getNetId();
        } else {
          newNetID = virtualNodes.get(con.getOverlayID());
        }

        boolean inSet = false;
        for (EdgeHandle h : vis_ue) {
          if (h == null) {
            continue;
          }
          if (newNetID == h.getTo()) {
            inSet = true;
          }
        }

        if (!inSet) {
          EdgeHandle e = this.addEdge(netid, newNetID, Color.MAGENTA, "ringEdges");
          vis_ue.add(e);
        }
      }
    }
  }