当前位置: 首页>>代码示例>>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;未经允许,请勿转载。