コード例 #1
0
ファイル: EoMPLSService.java プロジェクト: modulexcite/oscars
  private List<PSSAction> processActions(List<PSSAction> actions, ActionType actionType)
      throws PSSException {
    ArrayList<PSSAction> results = new ArrayList<PSSAction>();

    for (PSSAction action : actions) {
      ResDetails res = null;
      switch (actionType) {
        case MODIFY:
          res = action.getRequest().getModifyReq().getReservation();
          break;
        case SETUP:
          res = action.getRequest().getSetupReq().getReservation();
          break;
        case TEARDOWN:
          res = action.getRequest().getTeardownReq().getReservation();
          break;
        case STATUS:
          res = action.getRequest().getSetupReq().getReservation();
          break;
        default:
          throw new PSSException("invalid actiontype: " + actionType);
      }

      this.prepareAction(action, res);

      String srcDeviceId = EoMPLSUtils.getDeviceId(res, false);
      String dstDeviceId = EoMPLSUtils.getDeviceId(res, true);
      boolean sameDevice = srcDeviceId.equals(dstDeviceId);
      if (!sameDevice) {
        log.debug("source edge device id is: " + srcDeviceId + ", starting " + actionType);
        action = this.processActionForDevice(action, srcDeviceId);
        log.debug("destination edge device id is: " + dstDeviceId + ", starting " + actionType);
        action = this.processActionForDevice(action, dstDeviceId);
      } else {
        log.debug("only device id is: " + srcDeviceId + ", starting same-device " + actionType);
        action = this.processActionForDevice(action, dstDeviceId);
      }

      action.setStatus(ActionStatus.SUCCESS);
      results.add(action);
      // this notifies the coordinator we have succeeded
      ClassFactory.getInstance().getWorkflow().update(action);

      // now if there's a post-commit for this action, do it
      if (!sameDevice) {
        processPostCommitActionForDevice(action, srcDeviceId);
        log.debug(
            "destination edge device id is: "
                + dstDeviceId
                + ", starting "
                + actionType
                + " post-commit command");
        processPostCommitActionForDevice(action, dstDeviceId);
      } else {
        log.debug(
            "only device id is: "
                + srcDeviceId
                + ", starting same-device "
                + actionType
                + " post-commit command");
        processPostCommitActionForDevice(action, dstDeviceId);
      }
    }
    return results;
  }
コード例 #2
0
ファイル: EoMPLSService.java プロジェクト: modulexcite/oscars
  public void prepareAction(PSSAction action, ResDetails res) throws PSSException {
    ActionType actionType = action.getActionType();
    switch (actionType) {
      case SETUP:
        break;
      case TEARDOWN:
        break;
      case MODIFY:
        return;
      case STATUS:
        return;
    }

    List<String> deviceIds = new ArrayList<String>();
    String srcDeviceId = EoMPLSUtils.getDeviceId(res, false);
    String dstDeviceId = EoMPLSUtils.getDeviceId(res, true);
    deviceIds.add(srcDeviceId);
    if (!srcDeviceId.equals(dstDeviceId)) deviceIds.add(dstDeviceId);

    String gri = res.getGlobalReservationId();
    HashMap<String, VplsImplementation> implMap =
        VPLS_RequestParams.getImplementationMap(deviceIds);

    boolean all_supported = true;
    boolean one_supported = false;
    boolean one_alu = false;
    boolean may_need_secondary_vpls_id = false;

    for (String deviceId : deviceIds) {
      log.debug(deviceId + " implementation: " + implMap.get(deviceId));
      if (implMap.get(deviceId).equals(VplsImplementation.UNSUPPORTED)) {
        all_supported = false;
      } else {
        one_supported = true;
      }
      if (implMap.get(deviceId).equals(VplsImplementation.ALU)) {
        one_alu = true;
      }
    }
    if (one_supported && !all_supported) {
      throw new PSSException("VPLS implementation mismatch");
    }
    if (!all_supported) return;

    if (one_alu) {
      may_need_secondary_vpls_id = true;
    }

    VPLS_RequestParamHolder holder = VPLS_RequestParamHolder.getInstance();
    VPLS_RequestParams rp = new VPLS_RequestParams();
    switch (actionType) {
      case SETUP:
        rp.reserve(res, may_need_secondary_vpls_id);
        break;
      case TEARDOWN:
        rp.release(res);
        break;
    }

    holder.getRequestParams().put(gri, rp);
  }