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


Java OFPortStatus.getReason方法代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFPortStatus.getReason方法的典型用法代码示例。如果您正苦于以下问题:Java OFPortStatus.getReason方法的具体用法?Java OFPortStatus.getReason怎么用?Java OFPortStatus.getReason使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.projectfloodlight.openflow.protocol.OFPortStatus的用法示例。


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

示例1: buildPortDescription

import org.projectfloodlight.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
        return new DefaultPortDescription(portNo, false, type,
                portSpeed(port), annotations);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:OpenFlowDeviceProvider.java

示例2: handlePortStatusMessage

import org.projectfloodlight.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
/**
 * Handle a OFPortStatus message, update the internal data structures
 * that store ports and return the list of OFChangeEvents.
 *
 * This method will increment error/warn counters and log
 *
 * @param ps
 * @return
 */
@SuppressFBWarnings(value="SF_SWITCH_FALLTHROUGH")
public OrderedCollection<PortChangeEvent> handlePortStatusMessage(OFPortStatus ps) {
	if (ps == null) {
		throw new NullPointerException("OFPortStatus message must " +
				"not be null");
	}
	lock.writeLock().lock();
	try {
		OFPortDesc port = ps.getDesc();
		OFPortReason reason = ps.getReason();
		if (reason == null) {
			throw new IllegalArgumentException("Unknown PortStatus " +
					"reason code " + ps.getReason());
		}

		if (log.isDebugEnabled()) {
			log.debug("Handling OFPortStatus: {} for {}",
					reason, String.format("%s (%d)", port.getName(), port.getPortNo().getPortNumber()));
		}

		if (reason == OFPortReason.DELETE)
			return handlePortStatusDelete(port);

		// We handle ADD and MODIFY the same way. Since OpenFlow
		// doesn't specify what uniquely identifies a port the
		// notion of ADD vs. MODIFY can also be hazy. So we just
		// compare the new port to the existing ones.
		Map<OFPort,OFPortDesc> newPortByNumber =
				new HashMap<OFPort, OFPortDesc>(portsByNumber);
		OrderedCollection<PortChangeEvent> events = getSinglePortChanges(port);
		for (PortChangeEvent e: events) {
			switch(e.type) {
			case DELETE:
				newPortByNumber.remove(e.port.getPortNo());
				break;
			case ADD:
				if (reason != OFPortReason.ADD) {
					// weird case
				}
				// fall through
			case DOWN:
			case OTHER_UPDATE:
			case UP:
				// update or add the port in the map
				newPortByNumber.put(e.port.getPortNo(), e.port);
				break;
			}
		}
		updatePortsWithNewPortsByNumber(newPortByNumber);
		return events;
	} finally {
		lock.writeLock().unlock();
	}

}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:65,代码来源:OFSwitch.java


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