当前位置: 首页>>代码示例>>Java>>正文


Java LsaWrapper类代码示例

本文整理汇总了Java中org.onosproject.ospf.controller.LsaWrapper的典型用法代码示例。如果您正苦于以下问题:Java LsaWrapper类的具体用法?Java LsaWrapper怎么用?Java LsaWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LsaWrapper类属于org.onosproject.ospf.controller包,在下文中一共展示了LsaWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAges

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Verify the checksum for the LSAs who are in bins of 300 and it's multiples.
 */
public void checkAges() {
    //evry 5 min age counter + multiples of 300
    for (int age = OspfParameters.CHECKAGE; age < OspfParameters.MAXAGE;
         age += OspfParameters.CHECKAGE) {
        LsaBin lsaBin = ageBins.get(age2Bin(age));
        if (lsaBin == null) {
            continue;
        }
        Map lsaBinMap = lsaBin.listOfLsa();
        for (Object key : lsaBinMap.keySet()) {
            LsaWrapper lsa = (LsaWrapper) lsaBinMap.get((String) key);
            lsa.setLsaProcessing(OspfParameters.VERIFYCHECKSUM);
            try {
                lsaQueue.put(lsa);
            } catch (InterruptedException e) {
                log.debug("Error::LSDBAge::checkAges::{}", e.getMessage());
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:LsdbAgeImpl.java

示例2: processMaxAgeLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Process max age LSA.
 *
 * @param wrapper LSA wrapper instance
 */
private void processMaxAgeLsa(LsaWrapper wrapper) {
    //set the destination
    OspfInterface ospfInterface = wrapper.ospfInterface();
    if (ospfInterface != null) {
        LsaHeader header = (LsaHeader) wrapper.ospfLsa().lsaHeader();
        header.setAge(OspfParameters.MAXAGE);
        ((LsaWrapperImpl) wrapper).lsaHeader().setAge(OspfParameters.MAXAGE);
        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
                ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT) {
            //remove from db
            ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(((LsaWrapperImpl) wrapper).lsaHeader());
            ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
        } else {
            ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
        }
        log.debug("LSAQueueConsumer: processMaxAgeLsa - Flooded SelfOriginated-Max Age LSA {}",
                  ((LsaWrapperImpl) wrapper).lsaHeader());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:LsaQueueConsumer.java

示例3: addLsaToHeaderList

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Adds the LSAs to summary list.
 *
 * @param summList         summary list
 * @param excludeMaxAgeLsa exclude max age LSA
 * @param lsaMap           map of LSA
 */
private void addLsaToHeaderList(List summList, boolean excludeMaxAgeLsa, Map lsaMap) {
    Iterator slotVals = lsaMap.values().iterator();
    while (slotVals.hasNext()) {
        LsaWrapper wrapper = (LsaWrapper) slotVals.next();
        if (excludeMaxAgeLsa) {
            //if current age of lsa is max age or lsa present in Max Age bin
            if (wrapper.currentAge() != OspfParameters.MAXAGE &&
                    lsdbAge.getMaxAgeBin().ospfLsa(((OspfAreaImpl)
                            ospfArea).getLsaKey(((LsaWrapperImpl) wrapper).lsaHeader())) == null) {
                addToList(wrapper, summList);
            }
        } else {
            addToList(wrapper, summList);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OspfLsdbImpl.java

示例4: isNullorLatest

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * RFC 2328 Section 13 (5).
 *
 * @param lsWrapper ls wrapper instance
 * @param recLsa    received LSA instance
 * @return returns a string status
 */
public String isNullorLatest(LsaWrapper lsWrapper, LsaHeader recLsa) {


    if (lsWrapper != null) {
        LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
        String status = ospfArea.isNewerOrSameLsa(recLsa, ownLsa);

        if (status.equals("latest")) {
            return "isNullorLatest";
        } else {
            return status;
        }
    } else {
        return "isNullorLatest";
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OspfNbrImpl.java

示例5: checkAges

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Verify the checksum for the LSAs who are in bins of 300 and it's multiples.
 */
public void checkAges() {
    //evry 5 min age counter + multiples of 300
    for (int age = OspfParameters.CHECKAGE; age < OspfParameters.MAXAGE;
         age += OspfParameters.CHECKAGE) {
        LsaBin lsaBin = ageBins.get(age2Bin(age));
        if (lsaBin == null) {
            continue;
        }
        Map lsaBinMap = lsaBin.listOfLsa();
        for (Object key : lsaBinMap.keySet()) {
            LsaWrapper lsa = (LsaWrapper) lsaBinMap.get(key);
            lsa.setLsaProcessing(OspfParameters.VERIFYCHECKSUM);
            try {
                lsaQueue.put(lsa);
            } catch (InterruptedException e) {
                log.debug("Error::LSDBAge::checkAges::{}", e.getMessage());
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:LsdbAgeImpl.java

示例6: getLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Gets the LSA from LSDB based on the input.
 *
 * @param lsType            type of lsa to form the key
 * @param linkStateID       link state id to form the key
 * @param advertisingRouter advertising router to form the key
 * @return lsa wrapper instance which contains the Lsa
 */
public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) {
    String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter;
    if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
            lsType == OspfParameters.AS_OPAQUE_LSA) {
        try {
            byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress();

            int opaqueType = linkStateAsBytes[0];
            int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1,
                                                                 linkStateAsBytes.length));
            lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter;
        } catch (UnknownHostException uhe) {
            log.warn("Can't resolve host in Lsa wrapper", uhe);
            return null;
        }
    }
    return database.findLsa(lsType, lsaKey);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:OspfAreaImpl.java

示例7: removeLsaFromBin

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Removes LSA from Bin.
 *
 * @param lsaWrapper wrapper instance
 */
public void removeLsaFromBin(LsaWrapper lsaWrapper) {
    if (ageBins.containsKey(lsaWrapper.binNumber())) {
        LsaBin lsaBin = ageBins.get(lsaWrapper.binNumber());
        lsaBin.removeOspfLsa(((OspfAreaImpl) ospfArea).getLsaKey(((LsaWrapperImpl)
                lsaWrapper).lsaHeader()), lsaWrapper);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:LsdbAgeImpl.java

示例8: refreshLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
public void refreshLsa() {
    int binNumber;
    if (ageCounter < OspfParameters.LSREFRESHTIME) {
        binNumber = ageCounter + OspfParameters.LSREFRESHTIME;
    } else {
        binNumber = ageCounter - OspfParameters.LSREFRESHTIME;
    }
    LsaBin lsaBin = ageBins.get(binNumber);
    if (lsaBin == null) {
        return;
    }
    Map lsaBinMap = lsaBin.listOfLsa();
    for (Object key : lsaBinMap.keySet()) {
        LsaWrapper lsa = (LsaWrapper) lsaBinMap.get((String) key);
        try {
            if (lsa.isSelfOriginated()) {
                log.debug("Lsa picked for refreshLsa. binNumber: {}, LSA Type: {}, LSA Key: {}",
                          binNumber, lsa.lsaType(), key);
                lsa.setLsaProcessing(OspfParameters.REFRESHLSA);
                lsaQueue.put(lsa);
                //remove from bin
                lsaBin.removeOspfLsa((String) key, lsa);
            }
        } catch (InterruptedException e) {
            log.debug("Error::LSDBAge::refreshLsa::{}", e.getMessage());
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:LsdbAgeImpl.java

示例9: run

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Threads run method.
 */
public void run() {
    log.debug("LSAQueueConsumer:run...!!!");
    try {
        while (true) {
            if (!queue.isEmpty()) {
                LsaWrapper wrapper = (LsaWrapper) queue.take();
                String lsaProcessing = wrapper.lsaProcessing();
                switch (lsaProcessing) {
                    case OspfParameters.VERIFYCHECKSUM:
                        log.debug("LSAQueueConsumer: Message - " + OspfParameters.VERIFYCHECKSUM + " consumed.");
                        processVerifyChecksum(wrapper);
                        break;
                    case OspfParameters.REFRESHLSA:
                        log.debug("LSAQueueConsumer: Message - " + OspfParameters.REFRESHLSA + " consumed.");
                        processRefreshLsa(wrapper);
                        break;
                    case OspfParameters.MAXAGELSA:
                        log.debug("LSAQueueConsumer: Message - " + OspfParameters.MAXAGELSA + " consumed.");
                        processMaxAgeLsa(wrapper);
                        break;
                    default:
                        log.debug("Unknown command to process the LSA in queue ...!!!");
                        break;
                }
            }
        }

    } catch (Exception e) {
        log.debug("Error::LSAQueueConsumer::{}", e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:LsaQueueConsumer.java

示例10: processVerifyChecksum

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Processes verify checksum - checkAges.
 *
 * @param wrapper LSA wrapper instance
 */
private void processVerifyChecksum(LsaWrapper wrapper) throws Exception {
    ChecksumCalculator checkSum = new ChecksumCalculator();
    if (!checkSum.isValidLsaCheckSum(wrapper.ospfLsa(), ((LsaWrapperImpl) wrapper).lsaHeader().lsType(),
                                     OspfUtil.LSAPACKET_CHECKSUM_POS1,
                                     OspfUtil.LSAPACKET_CHECKSUM_POS2)) {
        log.debug("LSAQueueConsumer::Checksum mismatch. Received LSA packet type {} ",
                  ((LsaWrapperImpl) wrapper).lsaHeader().lsType());

        //Checksum Invalid
        //RFC 2328 Restart the Router.
        //Currently we are not restarting. We are not handling this case.
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:LsaQueueConsumer.java

示例11: processRefreshLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Process refresh LSA.
 *
 * @param wrapper LSA wrapper instance
 */
private void processRefreshLsa(LsaWrapper wrapper) throws Exception {
    if (wrapper.isSelfOriginated()) { //self originated
        //set the destination
        OspfInterface ospfInterface = wrapper.ospfInterface();
        if (ospfInterface != null) {
            LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
            header.setAge(wrapper.currentAge());
            if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
                if (header.lsType() == OspfLsaType.ROUTER.value()) {
                    RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
                    ((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
                    ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
                } else if (header.lsType() == OspfLsaType.NETWORK.value()) {
                    if (ospfInterface.listOfNeighbors().size() > 0) {
                        NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
                                ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
                        ospfArea.addLsa(networkLsa, true, ospfInterface);
                        ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
                    }
                }
            }

            if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
                    ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
                    ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
                ospfArea.refreshArea(ospfInterface);
            }
            log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
                      ((LsaWrapperImpl) wrapper).lsaHeader());
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:LsaQueueConsumer.java

示例12: addOspfLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Adds the LSA to this bin with the given key.
 *
 * @param lsaKey     key of the LSA
 * @param lsaWrapper wrapper instance to store
 */
public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
    if (!listOfLsa.containsKey(lsaKey)) {
        listOfLsa.put(lsaKey, lsaWrapper);
        lsaWrapper.setBinNumber(this.binNumber);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:LsaBinImpl.java

示例13: addToList

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Adds the LSWrapper to summary list.
 *
 * @param wrapper  LSA wrapper instance
 * @param summList LSA summary list
 */
private void addToList(LsaWrapper wrapper, List summList) {
    LsaHeader header = (LsaHeader) wrapper.ospfLsa();
    //set the current age
    header.setAge(wrapper.currentAge());
    summList.add(header);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:OspfLsdbImpl.java

示例14: getLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Gets the LSA from LSDB based on the input.
 *
 * @param lsType            type of lsa to form the key
 * @param linkStateID       link state id to form the key
 * @param advertisingRouter advertising router to form the key
 * @return lsa wrapper instance which contains the Lsa
 * @throws Exception might throws exception
 */
public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception {
    String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter;
    if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
            lsType == OspfParameters.AS_OPAQUE_LSA) {
        byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress();
        int opaqueType = linkStateAsBytes[0];
        int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1,
                                                                 linkStateAsBytes.length));
        lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter;
    }
    return database.findLsa(lsType, lsaKey);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:OspfAreaImpl.java

示例15: testAddOspfLsa

import org.onosproject.ospf.controller.LsaWrapper; //导入依赖的package包/类
/**
 * Tests addOspfLsa() method.
 */
@Test
public void testAddOspfLsa() throws Exception {
    LsaWrapper lsaWrapper = new LsaWrapperImpl();
    lsaBin.addOspfLsa("lsa1", lsaWrapper);
    assertThat(lsaBin, is(notNullValue()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:LsaBinImplTest.java


注:本文中的org.onosproject.ospf.controller.LsaWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。