本文整理汇总了Java中org.openflow.protocol.OFPortStatus类的典型用法代码示例。如果您正苦于以下问题:Java OFPortStatus类的具体用法?Java OFPortStatus怎么用?Java OFPortStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFPortStatus类属于org.openflow.protocol包,在下文中一共展示了OFPortStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePortStatusMessage
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
/**
* Handle a port status message.
*
* Handle a port status message by updating the port maps in the
* IOFSwitch instance and notifying Controller about the change so
* it can dispatch a switch update.
*
* @param h The OFChannelHhandler that received the message
* @param m The PortStatus message we received
* @param doNotify if true switch port changed events will be
* dispatched
*/
protected void handlePortStatusMessage(OFChannelHandler h,
OFPortStatus m,
boolean doNotify) {
if (h.sw == null) {
String msg = getSwitchStateMessage(h, m,
"State machine error: switch is null. Should never " +
"happen");
throw new SwitchStateException(msg);
}
Collection<PortChangeEvent> changes = h.sw.processOFPortStatus(m);
if (doNotify) {
for (PortChangeEvent ev: changes)
h.controller.notifyPortChanged(h.sw, ev.port, ev.type);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: OFChannelHandler
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
/**
* Create a new unconnecte OFChannelHandler.
* @param controller
*/
OFChannelHandler(Controller controller) {
this.controller = controller;
this.counters = controller.getCounters();
this.roleChanger = new RoleChanger(DEFAULT_ROLE_TIMEOUT_MS);
this.state = ChannelState.INIT;
this.pendingPortStatusMsg = new ArrayList<OFPortStatus>();
}
示例5: receive
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.handlePacketIn(sw.getId(), (OFPacketIn) msg, cntx);
case PORT_STATUS:
return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
default:
break;
}
return Command.CONTINUE;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:13,代码来源:LinkDiscoveryManager.java
示例6: testHandlePortStatus
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Test
public void testHandlePortStatus() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
OFPhysicalPort port = new OFPhysicalPort();
port.setName("myPortName1");
port.setPortNumber((short)42);
OFPortStatus ofps = new OFPortStatus();
ofps.setDesc(port);
ofps.setReason((byte)OFPortReason.OFPPR_ADD.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps, false);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_MODIFY.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps, false);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_DELETE.ordinal());
sw.deletePort(port.getPortNumber());
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps, false);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:38,代码来源:ControllerTest.java
示例7: 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);
}
}
示例8: processOFStatisticsReply
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
void processOFStatisticsReply(final SwitchChannelHandler h,
final OFStatisticsReply m) {
// Read description, if it has been updated
final OVXDescriptionStatistics description = new OVXDescriptionStatistics();
final ChannelBuffer data = ChannelBuffers.buffer(description
.getLength());
final OFStatistics f = m.getFirstStatistics();
f.writeTo(data);
description.readFrom(data);
OFFlowMod fm = new OFFlowMod();
fm.setCommand(OFFlowMod.OFPFC_DELETE);
fm.setMatch(new OFMatch());
h.channel.write(Collections.singletonList(fm));
h.sw = new PhysicalSwitch(h.featuresReply.getDatapathId());
// set switch information
// set features reply and channel first so we have a DPID and
// channel info.
h.sw.setFeaturesReply(h.featuresReply);
h.sw.setDescriptionStats(description);
h.sw.setConnected(true);
h.sw.setChannel(h.channel);
for (final OFPortStatus ps : h.pendingPortStatusMsg) {
this.handlePortStatusMessage(h, ps);
}
h.pendingPortStatusMsg.clear();
h.sw.boot();
h.setState(ACTIVE);
}
示例9: receive
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
ListenerContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
cntx);
case PORT_STATUS:
return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
default:
break;
}
return Command.CONTINUE;
}
示例10: testHandlePortStatus
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Test
public void testHandlePortStatus() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
OFPhysicalPort port = new OFPhysicalPort();
port.setName("myPortName1");
port.setPortNumber((short)42);
OFPortStatus ofps = new OFPortStatus();
ofps.setDesc(port);
ofps.setReason((byte)OFPortReason.OFPPR_ADD.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_MODIFY.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_DELETE.ordinal());
sw.deletePort(port.getPortNumber());
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
}
示例11: receive
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
debugCounters.updateCounter("linkdiscovery-incoming");
return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
cntx);
case PORT_STATUS:
return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
default:
break;
}
return Command.CONTINUE;
}
示例12: receive
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
public void receive(ISwitch sw, OFMessage msg) {
if (msg instanceof OFPortStatus) {
handlePortStatusMessage(sw, (OFPortStatus) msg);
}
return;
}
示例13: 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);
}
}
示例14: receive
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
cntx);
case PORT_STATUS:
return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
default:
break;
}
return Command.CONTINUE;
}
示例15: testHandlePortStatus
import org.openflow.protocol.OFPortStatus; //导入依赖的package包/类
@Test
public void testHandlePortStatus() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
OFPhysicalPort port = new OFPhysicalPort();
port.setName("myPortName1");
port.setPortNumber((short)42);
OFPortStatus ofps = new OFPortStatus();
ofps.setDesc(port);
ofps.setReason((byte)OFPortReason.OFPPR_ADD.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_MODIFY.ordinal());
sw.setPort(port);
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
ofps.setReason((byte)OFPortReason.OFPPR_DELETE.ordinal());
sw.deletePort(port.getPortNumber());
expectLastCall().once();
replay(sw);
controller.handlePortStatusMessage(sw, ofps);
verify(sw);
verifyPortChangedUpdateInQueue(sw);
reset(sw);
}