Example #1
0
  /**
   * Create a Tree structure adding the reference to passed As. The Tree is created starting from
   * {@link DPCNode} as parent node containing 'n' {@link OPCNode} leafs where 'n' is list of OPC
   * passed. For each {@link OPCNode} there will be 'm' {@link SINode} leafs where 'm' is number of
   * Service Indicator passed.
   *
   * <p>DPC is mandatory while OPC and SI list are optional. If OPC or SI is not passed the wild
   * card '-1' leaf will be added to parent node
   *
   * @param rk
   * @param asImpl
   * @throws Exception
   */
  public void addRk(RoutingKey rk, AsImpl asImpl) throws Exception {
    int dpc = rk.getDestinationPointCodes()[0].getPointCode();
    OPCList[] opcArray = rk.getOPCLists();

    int[] opcIntArr = null;
    if (opcArray == null) {
      opcIntArr = new int[] {-1};
    } else {
      opcIntArr = opcArray[0].getPointCodes();
    }

    ServiceIndicators[] siArray = rk.getServiceIndicators();
    short[] siShortArr = null;
    if (siArray == null) {
      siShortArr = new short[] {-1};
    } else {
      siShortArr = siArray[0].getIndicators();
    }

    for (FastList.Node<DPCNode> n = dpcList.head(), end = dpcList.tail();
        (n = n.getNext()) != end; ) {
      DPCNode dpcNode = n.getValue();
      if (dpcNode.dpc == dpc) {
        this.addSi(dpcNode, opcIntArr, siShortArr, asImpl);
        return;
      }
    }

    DPCNode dpcNode = new DPCNode(dpc);
    this.addSi(dpcNode, opcIntArr, siShortArr, asImpl);
    this.dpcList.add(dpcNode);
  }
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    ServletInputStream is = request.getInputStream();
    try {
      XmlCAPDialog original = factory.deserialize(is);
      HttpSession session = request.getSession(true);
      if (logger.isInfoEnabled()) {
        logger.info("doPost. HttpSession=" + session.getId() + " Dialog = " + original);
      }

      if ((original.getNoActivityTimeout() != null) && (original.getNoActivityTimeout())) {
        try {
          original.close(true);
          this.sendResponse(response, original);
        } catch (CAPException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        return;
      }

      FastList<CAPMessage> capMessages = original.getCAPMessages();

      for (FastList.Node<CAPMessage> n = capMessages.head(), end = capMessages.tail();
          (n = n.getNext()) != end; ) {

        CAPMessage capMessage = n.getValue();
        switch (capMessage.getMessageType()) {
          case initialDP_Request:
            InitialDPRequestImpl initialDPRequest = (InitialDPRequestImpl) capMessage;
            this.handleIdp(original, initialDPRequest);
            break;
          case applyChargingReport_Request:
            ApplyChargingReportRequestImpl applyChargingReportRequest =
                (ApplyChargingReportRequestImpl) capMessage;
            logger.info(
                String.format(
                    "Received applyChargingReportRequest=%s", applyChargingReportRequest));
            break;
          case eventReportBCSM_Request:
            EventReportBCSMRequestImpl eventReportBCSMRequest =
                (EventReportBCSMRequestImpl) capMessage;
            logger.info(
                String.format("Received eventReportBCSMRequest=%s", eventReportBCSMRequest));
            break;
          default:
            logger.info(String.format("unrecognized capMessage=%s", capMessage));
            break;
        }
      }

      // send response
      this.sendResponse(response, original);
    } catch (XMLStreamException e) {
      logger.error("Error while processing received XML", e);
    }
  }
Example #3
0
 /**
  * Match the passed dpc, opc and si with Tree structure and return the As from corresponding
  * matched {@link SINode}.
  *
  * <p>For example if AS1 is added for Routing Key with DPC=123 only. The tree will be formed with
  * 123 as {@link DPCNode} parent node and -1 as {@link OPCNode} leaf and within {@link OPCNode} -1
  * as {@link SINode}
  *
  * @param dpc
  * @param opc
  * @param si
  * @return
  */
 public AsImpl getAs(int dpc, int opc, short si) {
   for (FastList.Node<DPCNode> n = dpcList.head(), end = dpcList.tail();
       (n = n.getNext()) != end; ) {
     DPCNode dpcNode = n.getValue();
     if (dpcNode.dpc == dpc) {
       return dpcNode.getAs(opc, si);
     }
   }
   return null;
 }
Example #4
0
  protected AspJmx removeAppServerProcess(String aspName) {
    AspJmx aspJmx = null;
    for (FastList.Node<Asp> n = this.appServerProcs.head(), end = this.appServerProcs.tail();
        (n = n.getNext()) != end; ) {
      Asp asp = n.getValue();
      if (asp.getName().equals(aspName)) {
        aspJmx = (AspJmx) asp;
        break;
      }
    } // for

    this.appServerProcs.remove(aspJmx);

    return aspJmx;
  }
Example #5
0
  @Override
  public void onEvent(FSMState state) {
    // Call listener and indicate of state change only if not already done
    if (!this.asImpl.state.getName().equals(State.STATE_DOWN)) {
      AsState oldState = AsState.getState(this.asImpl.state.getName());
      this.asImpl.state = AsState.DOWN;

      FastList<M3UAManagementEventListener> managementEventListenersTmp =
          this.asImpl.m3UAManagementImpl.managementEventListeners;

      for (FastList.Node<M3UAManagementEventListener> n = managementEventListenersTmp.head(),
              end = managementEventListenersTmp.tail();
          (n = n.getNext()) != end; ) {
        M3UAManagementEventListener m3uaManagementEventListener = n.getValue();
        try {
          m3uaManagementEventListener.onAsDown(this.asImpl, oldState);
        } catch (Throwable ee) {
          logger.error("Exception while invoking onAsDown", ee);
        }
      }
    }
  }
  public boolean process(FSMState state) {
    try {
      AspImpl remAsp = (AspImpl) this.fsm.getAttribute(AsImpl.ATTRIBUTE_ASP);

      if (this.asImpl.getTrafficModeType().getMode() == TrafficModeType.Broadcast) {
        // We don't support this
        return false;
      }

      if (this.asImpl.getTrafficModeType().getMode() == TrafficModeType.Loadshare) {
        this.lbCount = 0;

        for (FastList.Node<Asp> n = this.asImpl.appServerProcs.head(),
                end = this.asImpl.appServerProcs.tail();
            (n = n.getNext()) != end; ) {
          AspImpl remAspImpl = (AspImpl) n.getValue();

          FSM aspPeerFSM = remAspImpl.getPeerFSM();
          AspState aspState = AspState.getState(aspPeerFSM.getState().getName());

          if (aspState == AspState.ACTIVE) {
            this.lbCount++;
          }
        } // for

        if (this.lbCount >= this.asImpl.getMinAspActiveForLb()) {
          // we still have more ASP's ACTIVE for lb. Don't change
          // state
          return false;
        }

        // We are below minAspActiveForLb required for LB
        if (this.lbCount > 0) {
          // But In any case if we have at least one ASP that can take
          // care of traffic, don't change state but send the "Ins.
          // ASPs" to INACTIVE ASP's

          if (asImpl.getFunctionality() != Functionality.IPSP) {
            // In any case send Notify only for ASP or SGW

            for (FastList.Node<Asp> n = this.asImpl.appServerProcs.head(),
                    end = this.asImpl.appServerProcs.tail();
                (n = n.getNext()) != end; ) {
              remAsp = (AspImpl) n.getValue();

              FSM aspPeerFSM = remAsp.getPeerFSM();
              AspState aspState = AspState.getState(aspPeerFSM.getState().getName());

              if (aspState == AspState.INACTIVE) {
                Notify notify =
                    this.createNotify(
                        remAsp, Status.STATUS_Other, Status.INFO_Insufficient_ASP_Resources_Active);
                remAsp.getAspFactory().write(notify);
              }
            }
          }

          return false;
        }
      } // If Loadshare

      // We have reached here means AS is transitioning to be PENDING.
      // Send new AS STATUS to all INACTIVE APS's

      if (asImpl.getFunctionality() != Functionality.IPSP) {
        // Send Notify only for ASP or SGW

        for (FastList.Node<Asp> n = this.asImpl.appServerProcs.head(),
                end = this.asImpl.appServerProcs.tail();
            (n = n.getNext()) != end; ) {
          remAsp = (AspImpl) n.getValue();

          FSM aspPeerFSM = remAsp.getPeerFSM();
          AspState aspState = AspState.getState(aspPeerFSM.getState().getName());

          if (aspState == AspState.INACTIVE) {
            Notify notify =
                this.createNotify(remAsp, Status.STATUS_AS_State_Change, Status.INFO_AS_PENDING);
            remAsp.getAspFactory().write(notify);
          }
        }
      }
    } catch (Exception e) {
      logger.error(
          String.format("Error while translating Rem AS to PENDING. %s", this.fsm.toString()), e);
    }
    return true;
  }