Beispiel #1
0
  private boolean handleProtectionChangeEvent(
      AbstractNe ne, Map<String, String> values, CHANGE oper) {
    try {
      String workingAid = values.get("AID1");
      String protectionAid = values.get("AID2");
      NetworkElement omeNe = (NetworkElement) ne;

      // Set up the data for event
      HashMap<String, String> eventData = new HashMap<String, String>();
      eventData.put("workingAid", workingAid);
      eventData.put("proctectingAid", protectionAid);
      eventData.put("operation", oper.asString());
      dbchgEvent.addDataElement(eventData);
      getParameters().put(AbstractCommandlet.RESULT_KEY, dbchgEvent);
      // String command = values.get("COMMAND");
      if (oper == CHANGE.DELETE) {
        // don't handle any thing, for now
        log.debug("Got the DLT-FFP report for " + workingAid + ":" + protectionAid);

        DbUtility.INSTANCE.updateOrAddFacilityAttr(
            ne, workingAid, AbstractFacilityXml.PROTECTIONSCHEME_ATTR, "N/A");
        DbUtility.INSTANCE.updateOrAddFacilityAttr(
            ne, protectionAid, AbstractFacilityXml.PROTECTIONSCHEME_ATTR, "N/A");
        omeNe.getProtectionAid().remove(workingAid);
        omeNe.getProtectionAid().remove(protectionAid);
        eventData.put(AbstractFacilityXml.PROTECTIONSCHEME_ATTR, "N/A");
        return true;
      }
      log.debug("Got the ENT-FFP report for " + workingAid + ":" + protectionAid);
      String[] aidMap = workingAid.split("-");
      Map<String, String> paramList = new HashMap<String, String>();
      paramList.put(ObjectElement.OPERATION_KEY, "RTRV-FFP-" + aidMap[0]);
      paramList.put("WRKGAID", aidMap[0] + "-1-ALL");

      List<Map<String, String>> result = omeNe.getTl1Session().sendToNE(paramList);
      if (result != null) {
        Iterator<Map<String, String>> ir = result.iterator();
        while (ir.hasNext()) {
          Map<String, String> aResult = ir.next();
          String protectionScheme = aResult.get("PS");
          omeNe.getProtectionAid().add(workingAid);
          omeNe.getProtectionAid().add(protectionAid);

          DbUtility.INSTANCE.updateOrAddFacilityAttr(
              ne, workingAid, AbstractFacilityXml.PROTECTIONSCHEME_ATTR, protectionScheme);
          DbUtility.INSTANCE.updateOrAddFacilityAttr(
              ne, protectionAid, AbstractFacilityXml.PROTECTIONSCHEME_ATTR, protectionScheme);
          eventData.put(AbstractFacilityXml.PROTECTIONSCHEME_ATTR, protectionScheme);
        }
        return true;
      }
    } catch (Exception e) {
      log.error("Failed to handle FFP event", e);
    }
    return false;
  }
Beispiel #2
0
  @Override
  public boolean start() {
    // <edge id="Connection 1" type="2WAY" source="aa-00-00-00-00-10"
    // sourceAid="OC192-1-5-1"
    // target="aa-00-00-00-00-09" targetAid="OC192-1-6-1"/>
    try {
      String aCommand = (String) getParameters().get(NePoxyDefinitionsParser.COMMANDNAME_KEY);
      getParameters().remove(NePoxyDefinitionsParser.COMMANDNAME_KEY);
      NetworkElement ne =
          (NetworkElement) getParameters().get(NePoxyDefinitionsParser.NETWORKELEMENT_KEY);
      getParameters().remove(NePoxyDefinitionsParser.NETWORKELEMENT_KEY);

      Map<String, String> paramList = new HashMap<String, String>();
      paramList.put(ObjectElement.OPERATION_KEY, aCommand);

      Iterator<String> anotherIr = getParameters().keySet().iterator();
      while (anotherIr.hasNext()) {
        String aParam = anotherIr.next();
        String aValue = (String) getParameters().get(aParam);
        paramList.put(aParam, aValue);
      }

      DbUtility.INSTANCE.deleteAllXConnection(ne);
      List<String> data = new ArrayList<String>();
      List<Map<String, String>> result = ne.getTl1Session().sendToNE(paramList);
      String neId = ne.getNeId();
      String neIp = ne.getIpAddress();
      Map<String, String> cacheFacility = new HashMap<String, String>();
      Set<String> cacheConnection = new HashSet<String>();
      if (result != null) {
        Iterator<Map<String, String>> resultIr = result.iterator();
        while (resultIr.hasNext()) {
          Map<String, String> aResult = resultIr.next();

          String fromAid = aResult.get("FROMAID");
          String toAid = aResult.get("TOAID");

          String[] fromAidArray = fromAid.split("-");
          String rate = fromAidArray[0];

          String shelfSlotPort = fromAidArray[1] + "-" + fromAidArray[2] + "-" + fromAidArray[3];
          String aFacility = null;
          aFacility = cacheFacility.get(shelfSlotPort);
          if (aFacility == null) {
            String facilityRecord =
                DbUtility.INSTANCE.retrieveAFacility(
                    ne, fromAidArray[1], fromAidArray[2], fromAidArray[3]);
            if (facilityRecord == null) {
              // can't find the Facility, so skip this connection
              log.debug("Skip this connection:" + neIp + " - fromAid=" + fromAid);
              continue;
            }

            int startTypeIndex = facilityRecord.indexOf("type=") + 6;
            int endTypeIndex = facilityRecord.indexOf('"', startTypeIndex);
            aFacility = facilityRecord.substring(startTypeIndex, endTypeIndex);
            cacheFacility.put(shelfSlotPort, aFacility);
          }

          StringBuilder temp = new StringBuilder(aFacility);
          for (int i = 1; i < fromAidArray.length; i++) {
            temp.append("-" + fromAidArray[i]);
          }
          fromAid = temp.toString();

          String[] toAidArray = toAid.split("-");
          shelfSlotPort = toAidArray[1] + "-" + toAidArray[2] + "-" + toAidArray[3];
          aFacility = cacheFacility.get(shelfSlotPort);
          if (aFacility == null) {
            String facilityRecord =
                DbUtility.INSTANCE.retrieveAFacility(
                    ne, toAidArray[1], toAidArray[2], toAidArray[3]);
            if (facilityRecord == null) {
              // can't find the Facility, so skip this connection
              log.debug("Skip this connection: " + neIp + " - " + fromAid + " to " + toAid);
              continue;
            }
            int startTypeIndex = facilityRecord.indexOf("type=") + 6;
            int endTypeIndex = facilityRecord.indexOf('"', startTypeIndex);
            aFacility = facilityRecord.substring(startTypeIndex, endTypeIndex);
            cacheFacility.put(shelfSlotPort, aFacility);
          }
          temp = new StringBuilder(aFacility);
          for (int i = 1; i < toAidArray.length; i++) {
            temp.append("-" + toAidArray[i]);
          }
          toAid = temp.toString();

          if (cacheConnection.contains(fromAid + ":" + toAid)) {
            log.error(ne.getNeName() + ": connection " + fromAid + ":" + toAid + " already exists");
          } else {
            cacheConnection.add(fromAid + ":" + toAid);

            // 1+1
            String swMateAid = aResult.get("SWMATE");
            if (swMateAid != null && swMateAid.length() > 0) {

              String[] swMateAidArray = swMateAid.split("-");
              shelfSlotPort = swMateAidArray[1] + "-" + swMateAidArray[2] + "-" + swMateAidArray[3];
              aFacility = cacheFacility.get(shelfSlotPort);
              if (aFacility == null) {
                String facilityRecord =
                    DbUtility.INSTANCE.retrieveAFacility(
                        ne, swMateAidArray[1], swMateAidArray[2], swMateAidArray[3]);

                if (facilityRecord == null) {
                  // can't find the Facility, so skip this connection
                  log.debug("Skip this connection:" + neIp + " - swMateAid=" + swMateAid);
                  continue;
                }

                int startTypeIndex = facilityRecord.indexOf("type=") + 6;
                int endTypeIndex = facilityRecord.indexOf('"', startTypeIndex);
                aFacility = facilityRecord.substring(startTypeIndex, endTypeIndex);
                cacheFacility.put(shelfSlotPort, aFacility);
              }

              temp = new StringBuilder(aFacility);
              for (int i = 1; i < swMateAidArray.length; i++) {
                temp.append("-" + swMateAidArray[i]);
              }
              swMateAid = temp.toString();

              data.add(
                  "<edge"
                      + " id=\""
                      + aResult.get("CKTID").replaceAll("&", " and ")
                      + "\" type=\""
                      + aResult.get("CCT")
                      + "\" rate=\""
                      + rate
                      + "\" source=\""
                      + neId
                      + "\" sShelf=\""
                      + fromAidArray[1]
                      + "\" sSlot=\""
                      + fromAidArray[2]
                      + "\" sSubslot=\""
                      + 0
                      + "\" sPort=\""
                      + fromAidArray[3]
                      + "\" sChannel=\""
                      + fromAidArray[4]
                      + "\" sourceAid=\""
                      + fromAid
                      + "\" target=\""
                      + neId
                      + "\" tShelf=\""
                      + toAidArray[1]
                      + "\" tSlot=\""
                      + toAidArray[2]
                      + "\" tSubslot=\""
                      + 0
                      + "\" tPort=\""
                      + toAidArray[3]
                      + "\" tChannel=\""
                      + toAidArray[4]
                      + "\" targetAid=\""
                      + toAid
                      + "\" swmateNeid=\""
                      + neId
                      + "\" swmateShelf=\""
                      + swMateAidArray[1]
                      + "\" swmateSlot=\""
                      + swMateAidArray[2]
                      + "\" swmateSubslot=\""
                      + 0
                      + "\" swmatePort=\""
                      + swMateAidArray[3]
                      + "\" swmateChannel=\""
                      + swMateAidArray[4]
                      + "\" swmateAid=\""
                      + swMateAid
                      + "\" committed=\"true\" />");
            } else {
              data.add(
                  "<edge"
                      + " id=\""
                      + aResult.get("CKTID").replaceAll("&", " and ")
                      + "\" type=\""
                      + aResult.get("CCT")
                      + "\" rate=\""
                      + rate
                      + "\" source=\""
                      + neId
                      + "\" sShelf=\""
                      + fromAidArray[1]
                      + "\" sSlot=\""
                      + fromAidArray[2]
                      + "\" sSubslot=\""
                      + 0
                      + "\" sPort=\""
                      + fromAidArray[3]
                      + "\" sChannel=\""
                      + fromAidArray[4]
                      + "\" sourceAid=\""
                      + fromAid
                      + "\" target=\""
                      + neId
                      + "\" tShelf=\""
                      + toAidArray[1]
                      + "\" tSlot=\""
                      + toAidArray[2]
                      + "\" tSubslot=\""
                      + 0
                      + "\" tPort=\""
                      + toAidArray[3]
                      + "\" tChannel=\""
                      + toAidArray[4]
                      + "\" targetAid=\""
                      + toAid
                      + "\" committed=\"true\" />");
            }
          }
        }
      }
      DbUtility.INSTANCE.addNewXConnect(ne, data);
      return true;
    } catch (Exception e) {
      log.error("Failed to get xConnections", e);
    }
    return false;
  }
Beispiel #3
0
  private boolean handleBlsrChangeEvent(AbstractNe ne, Map<String, String> values, CHANGE oper) {
    try {
      String workingAid = values.get("AID1");
      String protectionAid = values.get("AID2");
      NetworkElement omeNe = (NetworkElement) ne;

      // Set up the data for event
      HashMap<String, String> eventData = new HashMap<String, String>();
      eventData.put("workingAid", workingAid);
      eventData.put("proctectingAid", protectionAid);
      eventData.put("operation", oper.asString());
      dbchgEvent.addDataElement(eventData);
      getParameters().put(AbstractCommandlet.RESULT_KEY, dbchgEvent);
      // String command = values.get("COMMAND");
      if (oper == CHANGE.DELETE) {
        // don't handle any thing, for now
        log.debug("Got the DLT-BLSRMAP report for " + workingAid + ":" + protectionAid);

        DbUtility.INSTANCE.updateOrAddFacilityAttr(
            ne, workingAid, AbstractFacilityXml.APSID_ATTR, "N/A");
        DbUtility.INSTANCE.updateOrAddFacilityAttr(
            ne, protectionAid, AbstractFacilityXml.APSID_ATTR, "N/A");
        omeNe.getRingName().remove(workingAid);
        omeNe.getRingName().remove(protectionAid);
        omeNe.setApsId(null);
        eventData.put(AbstractFacilityXml.APSID_ATTR, "N/A");
        return true;
      }

      log.debug("Got the ENT-BLSRMAP report for " + workingAid + ":" + protectionAid);
      Map<String, String> paramList = new HashMap<String, String>();
      paramList.put(ObjectElement.OPERATION_KEY, Tl1CommandCode.RTRV_BLSRMAP.toString());
      paramList.put("WRKGAID", workingAid);
      paramList.put("PROTAID", protectionAid);

      List<Map<String, String>> result = omeNe.getTl1Session().sendToNE(paramList);
      if (result != null) {
        Iterator<Map<String, String>> ir = result.iterator();
        while (ir.hasNext()) {
          Map<String, String> blsrResult = ir.next();
          String ringName = blsrResult.get("LABEL");
          omeNe.getRingName().put(workingAid, ringName);
          omeNe.getRingName().put(protectionAid, ringName);

          // ringMap is expected to have the following format
          // "3:3/0:0/1:1/2:2/3:3"
          try {
            String ringMap = blsrResult.get("RINGMAP");
            log.debug("got ringMap info for " + ringName + " in " + ringMap);

            String apsIdStr = ringMap.split("/")[0].split(":")[0];
            omeNe.setApsId(Integer.valueOf(apsIdStr));

            // update the facility in the database with the apsId.
            DbUtility.INSTANCE.updateOrAddFacilityAttr(
                ne, workingAid, AbstractFacilityXml.APSID_ATTR, apsIdStr);
            DbUtility.INSTANCE.updateOrAddFacilityAttr(
                ne, protectionAid, AbstractFacilityXml.APSID_ATTR, apsIdStr);
            eventData.put(AbstractFacilityXml.APSID_ATTR, apsIdStr);
          } catch (Exception ex) {
            log.error("Fail to obtain the ring information", ex);
          }
        }
        return true;
      }

    } catch (Exception e) {
      log.error("Failed to handle BLSRMAP event", e);
    }
    return false;
  }