本文整理匯總了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());
}
示例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());
}