本文整理汇总了Java中org.openflow.protocol.OFPortStatus.getReason方法的典型用法代码示例。如果您正苦于以下问题:Java OFPortStatus.getReason方法的具体用法?Java OFPortStatus.getReason怎么用?Java OFPortStatus.getReason使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.OFPortStatus
的用法示例。
在下文中一共展示了OFPortStatus.getReason方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePortStatusMessage
import org.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
protected void handlePortStatusMessage(IOFSwitch sw, OFPortStatus m) {
short portNumber = m.getDesc().getPortNumber();
OFPhysicalPort port = m.getDesc();
if (m.getReason() == (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
sw.setPort(port);
log.debug("Port #{} modified for {}", portNumber, sw);
} else if (m.getReason() == (byte)OFPortReason.OFPPR_ADD.ordinal()) {
sw.setPort(port);
log.debug("Port #{} added for {}", portNumber, sw);
} else if (m.getReason() ==
(byte)OFPortReason.OFPPR_DELETE.ordinal()) {
sw.deletePort(portNumber);
log.debug("Port #{} deleted for {}", portNumber, sw);
}
SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.PORTCHANGED);
try {
this.updates.put(update);
} catch (InterruptedException e) {
log.error("Failure adding update to queue", e);
}
}
示例2: handlePortStatusMessage
import org.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
protected void handlePortStatusMessage(ISwitch sw, OFPortStatus m) {
Node node = NodeCreator.createOFNode(sw.getId());
NodeConnector nodeConnector = PortConverter.toNodeConnector(
m.getDesc().getPortNumber(), node);
// get node connector properties
Set<Property> props = InventoryServiceHelper.OFPortToProps(m.getDesc());
UpdateType type = null;
if (m.getReason() == (byte) OFPortReason.OFPPR_ADD.ordinal()) {
type = UpdateType.ADDED;
nodeConnectorProps.put(nodeConnector, props);
} else if (m.getReason() == (byte) OFPortReason.OFPPR_DELETE.ordinal()) {
type = UpdateType.REMOVED;
nodeConnectorProps.remove(nodeConnector);
} else if (m.getReason() == (byte) OFPortReason.OFPPR_MODIFY.ordinal()) {
type = UpdateType.CHANGED;
nodeConnectorProps.put(nodeConnector, props);
}
logger.trace("handlePortStatusMessage {} type {}", nodeConnector, type);
if (type != null) {
notifyInventoryShimListener(nodeConnector, type, props);
}
}
示例3: handlePortStatusMessage
import org.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
protected void handlePortStatusMessage(IOFSwitch sw,
OFPortStatus m,
boolean updateStorage) {
short portNumber = m.getDesc().getPortNumber();
OFPhysicalPort port = m.getDesc();
if (m.getReason() == (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
sw.setPort(port);
if (updateStorage)
updatePortInfo(sw, port);
log.debug("Port #{} modified for {}", portNumber, sw);
} else if (m.getReason() == (byte)OFPortReason.OFPPR_ADD.ordinal()) {
sw.setPort(port);
if (updateStorage)
updatePortInfo(sw, port);
log.debug("Port #{} added for {}", portNumber, sw);
} else if (m.getReason() ==
(byte)OFPortReason.OFPPR_DELETE.ordinal()) {
sw.deletePort(portNumber);
if (updateStorage)
removePortInfo(sw, portNumber);
log.debug("Port #{} deleted for {}", portNumber, sw);
}
SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.PORTCHANGED);
try {
this.updates.put(update);
} catch (InterruptedException e) {
log.error("Failure adding update to queue", e);
}
}
示例4: processPortStatusMsg
import org.openflow.protocol.OFPortStatus; //导入方法依赖的package包/类
private void processPortStatusMsg(OFPortStatus msg) {
OFPhysicalPort port = msg.getDesc();
if (msg.getReason() == (byte) OFPortReason.OFPPR_MODIFY.ordinal()) {
updatePhysicalPort(port);
} else if (msg.getReason() == (byte) OFPortReason.OFPPR_ADD.ordinal()) {
updatePhysicalPort(port);
} else if (msg.getReason() == (byte) OFPortReason.OFPPR_DELETE
.ordinal()) {
deletePhysicalPort(port);
}
}
示例5: handlePortStatusMessage
import org.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
*/
public OrderedCollection<PortChangeEvent> handlePortStatusMessage(OFPortStatus ps) {
if (ps == null) {
throw new NullPointerException("OFPortStatus message must " +
"not be null");
}
lock.writeLock().lock();
try {
ImmutablePort port =
ImmutablePort.fromOFPhysicalPort(ps.getDesc());
OFPortReason reason = OFPortReason.fromReasonCode(ps.getReason());
if (reason == null) {
throw new IllegalArgumentException("Unknown PortStatus " +
"reason code " + ps.getReason());
}
if (log.isDebugEnabled()) {
log.debug("Handling OFPortStatus: {} for {}",
reason, port.toBriefString());
}
if (reason == OFPortReason.OFPPR_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<Short,ImmutablePort> newPortByNumber =
new HashMap<Short, ImmutablePort>(portsByNumber);
OrderedCollection<PortChangeEvent> events = getSinglePortChanges(port);
for (PortChangeEvent e: events) {
switch(e.type) {
case DELETE:
newPortByNumber.remove(e.port.getPortNumber());
break;
case ADD:
if (reason != OFPortReason.OFPPR_ADD) {
// weird case
}
// fall through
case DOWN:
case OTHER_UPDATE:
case UP:
// update or add the port in the map
newPortByNumber.put(e.port.getPortNumber(), e.port);
break;
}
}
updatePortsWithNewPortsByNumber(newPortByNumber);
return events;
} finally {
lock.writeLock().unlock();
}
}