コード例 #1
0
ファイル: PodUtil.java プロジェクト: sshravan91/remote-plan
  /**
   * If a pair between the source and destination containers already exists - update it. If one
   * doesn't exist - create a new one
   *
   * @param source
   * @param dest
   * @param containerPairUuid
   * @param f
   * @return
   */
  public static ContainerPair createOrUpdateContainerPair(
      VirtualMachine source, VirtualMachine dest, String containerPairUuid, float f) {

    if (logger.isTraceEnabled())
      logger.trace(
          "Discovered "
              + f
              + " Flow between "
              + source.getDisplayName()
              + " and "
              + dest.getDisplayName());
    ContainerPair pair = null;
    // Go over all of the Flow commodities bought by either the source or the destination and look
    // for a pair containing these two entities
    for (Commodity comm : source.getCommoditiesBought()) {
      if (PodUtil.isInstanceOfFlow(comm)) {

        EList<ContainerPair> communicationMat = source.getCommunicationMatrix();
        for (ContainerPair cp : communicationMat) {
          // If a pair already exists between these two entities, update the traffic value
          if (cp.getObjectId().equals(containerPairUuid)) {
            updateTrafficValue(cp, f);
            pair = cp;
          }
        }
        FlowImpl flow = (FlowImpl) comm;
        flow.calculateUsed();
      }
    }
    for (Commodity comm : dest.getCommoditiesBought()) {
      if (PodUtil.isInstanceOfFlow(comm)) {
        FlowImpl flow = (FlowImpl) comm;
        flow.calculateUsed();
      }
    }
    if (pair != null) {
      return pair;
    }
    // If an existing pair was not found, create a new one with the relevant traffic
    ContainerPair vmPair = new ContainerPair(source, dest);
    vmPair.setTrafficAmount(f);

    // Attach the new pair to the communication matrix of both the source and the destination
    updateContainerCommunicationMatrix(source, vmPair);
    updateContainerCommunicationMatrix(dest, vmPair);

    return vmPair;
  }
コード例 #2
0
ファイル: PodUtil.java プロジェクト: sshravan91/remote-plan
  /**
   * Update the container pair list inside the monitoring extension, adding the entry to the list
   *
   * @param source The container we want to add the pair to
   * @param vmPair The container pair we want to add
   */
  public static void updateContainerCommunicationMatrix(
      VirtualMachine source, ContainerPair vmPair) {

    for (Commodity comm : source.getCommoditiesBought()) {
      if (PodUtil.isInstanceOfFlow(comm)) {

        // For each flow commodity bought by the container update the communication matrix
        EList<ContainerPair> communicationMat = source.getCommunicationMatrix();
        communicationMat.add(vmPair);
      }
    }
  }