Ejemplo n.º 1
0
  public BandwidthTopology(Topology topology, NetworkTrackerService networkTrackerService) {
    nodeNum = topology.getNode().toArray().length;
    // Map<NodeId, Integer> tpIdMap = new HashMap<>();
    int switchIndex = 0;
    for (int i = 0; i < nodeNum; i++) {
      NodeId nodeId = topology.getNode().get(i).getNodeId();
      if (!(nodeId.getValue().contains("host"))) {
        tpIdMap.put(nodeId, switchIndex);
        ++switchNum;
        ++switchIndex;
      }
    }
    this.BandwidthMap = new long[switchNum][switchNum];
    for (int i = 0; i < switchNum; i++) {
      for (int j = 0; j < switchNum; j++) {
        this.BandwidthMap[i][j] = 0;
      }
    }
    for (Link link : topology.getLink()) {
      TpId tpId = link.getSource().getSourceTp();

      Integer src = tpIdMap.get(link.getSource().getSourceNode());
      Integer dst = tpIdMap.get(link.getDestination().getDestNode());
      if (null != src && null != dst)
        this.BandwidthMap[src][dst] =
            getBandwidthByTp(link.getSource().getSourceTp(), networkTrackerService);
    }
  }