當前位置: 首頁>>代碼示例>>Java>>正文


Java OspfInterfaceState.value方法代碼示例

本文整理匯總了Java中org.onosproject.ospf.protocol.util.OspfInterfaceState.value方法的典型用法代碼示例。如果您正苦於以下問題:Java OspfInterfaceState.value方法的具體用法?Java OspfInterfaceState.value怎麽用?Java OspfInterfaceState.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.onosproject.ospf.protocol.util.OspfInterfaceState的用法示例。


在下文中一共展示了OspfInterfaceState.value方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: electRouter

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入方法依賴的package包/類
/**
 * Performs DR election.
 *
 * @param ch Netty Channel instance.
 * @throws Exception might throws exception
 */
public void electRouter(Channel ch) throws Exception {

    Ip4Address currentDr = dr();
    Ip4Address currentBdr = bdr();
    OspfInterfaceState oldState = state();
    OspfInterfaceState newState;

    log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
              currentDr, currentBdr);
    List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());

    log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
    OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
    OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);

    setBdr(electedBdr.getIpAddress());
    setDr(electedDr.getIpAddress());

    if (electedBdr.getIpAddress().equals(ipAddress()) &&
            !electedBdr.getIpAddress().equals(currentBdr)) {
        setState(OspfInterfaceState.BDR);
    }

    if (electedDr.getIpAddress().equals(ipAddress()) &&
            !electedDr.getIpAddress().equals(currentDr)) {
        setState(OspfInterfaceState.DR);
    }

    if (state() != oldState &&
            !(state() == OspfInterfaceState.DROTHER &&
                    oldState.value() < OspfInterfaceState.DROTHER.value())) {
        log.debug("Recalculating as the State is changed ");
        log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
                  currentDr, currentBdr);
        eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());

        log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
        electedBdr = electBdr(eligibleRouters);
        electedDr = electDr(eligibleRouters, electedBdr);

        setBdr(electedBdr.getIpAddress());
        setDr(electedDr.getIpAddress());
    }

    if (electedBdr.getIpAddress().equals(ipAddress()) &&
            !electedBdr.getIpAddress().equals(currentBdr)) {
        setState(OspfInterfaceState.BDR);
        ospfArea.refreshArea(this);
    }

    if (electedDr.getIpAddress().equals(ipAddress()) &&
            !electedDr.getIpAddress().equals(currentDr)) {
        setState(OspfInterfaceState.DR);
        //Refresh Router Lsa & Network Lsa
        ospfArea.refreshArea(this);
    }

    if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
        Set<String> negibhorIdList;
        negibhorIdList = listOfNeighbors().keySet();
        for (String routerid : negibhorIdList) {
            OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
            if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
                nbr.adjOk(ch);
            }
        }
    }

    log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
              electedDr.getIpAddress(), electedBdr.getIpAddress());
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:78,代碼來源:OspfInterfaceImpl.java

示例2: electRouter

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入方法依賴的package包/類
/**
 * Performs DR election.
 *
 * @param ch Netty Channel instance.
 */
public void electRouter(Channel ch) {

    Ip4Address currentDr = dr();
    Ip4Address currentBdr = bdr();
    OspfInterfaceState oldState = state();
    OspfInterfaceState newState;

    log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
              currentDr, currentBdr);
    List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());

    log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
    OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
    OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);

    setBdr(electedBdr.getIpAddress());
    setDr(electedDr.getIpAddress());

    if (electedBdr.getIpAddress().equals(ipAddress()) &&
            !electedBdr.getIpAddress().equals(currentBdr)) {
        setState(OspfInterfaceState.BDR);
    }

    if (electedDr.getIpAddress().equals(ipAddress()) &&
            !electedDr.getIpAddress().equals(currentDr)) {
        setState(OspfInterfaceState.DR);
    }

    if (state() != oldState &&
            !(state() == OspfInterfaceState.DROTHER &&
                    oldState.value() < OspfInterfaceState.DROTHER.value())) {
        log.debug("Recalculating as the State is changed ");
        log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
                  currentDr, currentBdr);
        eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());

        log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
        electedBdr = electBdr(eligibleRouters);
        electedDr = electDr(eligibleRouters, electedBdr);

        setBdr(electedBdr.getIpAddress());
        setDr(electedDr.getIpAddress());
    }

    if (electedBdr.getIpAddress().equals(ipAddress()) &&
            !electedBdr.getIpAddress().equals(currentBdr)) {
        setState(OspfInterfaceState.BDR);
        ospfArea.refreshArea(this);
    }

    if (electedDr.getIpAddress().equals(ipAddress()) &&
            !electedDr.getIpAddress().equals(currentDr)) {
        setState(OspfInterfaceState.DR);
        //Refresh Router Lsa & Network Lsa
        ospfArea.refreshArea(this);
    }

    if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
        Set<String> negibhorIdList;
        negibhorIdList = listOfNeighbors().keySet();
        for (String routerid : negibhorIdList) {
            OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
            if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
                nbr.adjOk(ch);
            }
        }
    }

    log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
              electedDr.getIpAddress(), electedBdr.getIpAddress());
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:77,代碼來源:OspfInterfaceImpl.java


注:本文中的org.onosproject.ospf.protocol.util.OspfInterfaceState.value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。