本文整理汇总了Java中org.onosproject.vtnrsc.PortChain.addLoadBalancePath方法的典型用法代码示例。如果您正苦于以下问题:Java PortChain.addLoadBalancePath方法的具体用法?Java PortChain.addLoadBalancePath怎么用?Java PortChain.addLoadBalancePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.vtnrsc.PortChain
的用法示例。
在下文中一共展示了PortChain.addLoadBalancePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadBalanceSfc
import org.onosproject.vtnrsc.PortChain; //导入方法依赖的package包/类
/**
* Find the load balanced path set it to port chain for the given five
* tuple.
*
* @param portChainId port chain id
* @param fiveTuple five tuple info
* @return load balance id
*/
private LoadBalanceId loadBalanceSfc(PortChainId portChainId, FiveTuple fiveTuple) {
// Get the port chain
PortChain portChain = portChainService.getPortChain(portChainId);
List<PortPairId> loadBalancePath = Lists.newArrayList();
LoadBalanceId id;
int paths = portChain.getLoadBalancePathSize();
if (paths >= MAX_LOAD_BALANCE_ID) {
log.info("Max limit reached for load balance paths. "
+ "Reusing the created path for port chain {} with five tuple {}", portChainId, fiveTuple);
id = LoadBalanceId.of((byte) ((paths + 1) % MAX_LOAD_BALANCE_ID));
portChain.addLoadBalancePath(fiveTuple, id, portChain.getLoadBalancePath(id));
}
// Get the list of port pair groups from port chain
Iterable<PortPairGroupId> portPairGroups = portChain.portPairGroups();
for (final PortPairGroupId portPairGroupId : portPairGroups) {
PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
// Get the list of port pair ids from port pair group.
Iterable<PortPairId> portPairs = portPairGroup.portPairs();
int minLoad = 0xFFF;
PortPairId minLoadPortPairId = null;
for (final PortPairId portPairId : portPairs) {
int load = portPairGroup.getLoad(portPairId);
if (load == 0) {
minLoadPortPairId = portPairId;
break;
} else {
// Check the port pair which has min load.
if (load < minLoad) {
minLoad = load;
minLoadPortPairId = portPairId;
}
}
}
if (minLoadPortPairId != null) {
loadBalancePath.add(minLoadPortPairId);
portPairGroup.addLoad(minLoadPortPairId);
}
}
// Check if the path already exists, if not create a new id
id = portChain.matchPath(loadBalancePath);
if (id == null) {
id = LoadBalanceId.of((byte) (paths + 1));
}
portChain.addLoadBalancePath(fiveTuple, id, loadBalancePath);
return id;
}