本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFBarrierReply类的典型用法代码示例。如果您正苦于以下问题:Java OFBarrierReply类的具体用法?Java OFBarrierReply怎么用?Java OFBarrierReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFBarrierReply类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFBarrierReply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkBarrierReplies
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
private boolean checkBarrierReplies(List<OFBarrierReplyFuture> replies) {
for (OFBarrierReplyFuture replyFuture: replies) {
OFBarrierReply br = null;
try {
br = replyFuture.get(2, TimeUnit.SECONDS);
} catch (TimeoutException | InterruptedException | ExecutionException e) {
// XXX for some reason these exceptions are not being thrown
}
if (br == null) {
log.warn("Did not receive barrier-reply for request ID {}",
replyFuture.getTransactionId());
// XXX take corrective action
return false;
}
}
return true;
}
示例2: retrieve
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Implement the API.
*
* @return true if succeeded, false if failed.
*/
@Get("json")
public OFBarrierReply retrieve() {
if (!init()) {
return null;
}
long dpid;
try {
dpid = HexString.toLong((String) getRequestAttributes().get("dpid"));
} catch (NumberFormatException e) {
log.error("Invalid number format");
return null;
}
return pusher.barrier(new Dpid(dpid));
}
示例3: receive
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
if (log.isTraceEnabled()) {
log.trace("Received BARRIER_REPLY from : {}", sw.getStringId());
}
if ((msg.getType() != OFType.BARRIER_REPLY) ||
!(msg instanceof OFBarrierReply)) {
log.error("Unexpected reply message: {}", msg.getType());
return Command.CONTINUE;
}
OFBarrierReply reply = (OFBarrierReply) msg;
BarrierInfo info = BarrierInfo.create(sw.getId(), reply);
// Deliver future if exists
OFBarrierReplyFuture future = barrierFutures.get(info);
if (future != null) {
future.deliverFuture(sw, msg);
barrierFutures.remove(info);
}
return Command.CONTINUE;
}
示例4: processOFMessage
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Process an OF message received on the channel and
* update state accordingly.
*
* The main "event" of the state machine. Process the received message,
* send follow up message if required and update state if required.
*
* Switches on the message type and calls more specific event handlers
* for each individual OF message type. If we receive a message that
* is supposed to be sent from a controller to a switch we throw
* a SwitchStateExeption.
*
* The more specific handlers can also throw SwitchStateExceptions
*
* @param h The OFChannelHandler that received the message
* @param m The message we received.
* @throws SwitchStateException
* @throws IOException
*/
void processOFMessage(OFMessage m) {
roleChanger.checkTimeout();
switch(m.getType()) {
case BARRIER_REPLY:
processOFBarrierReply((OFBarrierReply) m);
break;
case ERROR:
processOFError((OFErrorMsg) m);
break;
case FLOW_REMOVED:
processOFFlowRemoved((OFFlowRemoved) m);
break;
case GET_CONFIG_REPLY:
processOFGetConfigReply((OFGetConfigReply) m);
break;
case PACKET_IN:
processOFPacketIn((OFPacketIn) m);
break;
case PORT_STATUS:
processOFPortStatus((OFPortStatus) m);
break;
case QUEUE_GET_CONFIG_REPLY:
processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
break;
case STATS_REPLY:
processOFStatsReply((OFStatsReply) m);
break;
case ROLE_REPLY:
processOFRoleReply((OFRoleReply) m);
break;
case EXPERIMENTER:
processOFExperimenter((OFExperimenter) m);
break;
default:
illegalMessageReceived(m);
break;
}
}
示例5: sendBarrier
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
private void sendBarrier(IOFSwitch sw) {
OFBarrierRequest barrierRequest = sw.getOFFactory().buildBarrierRequest()
.build();
ListenableFuture<OFBarrierReply> future = sw.writeRequest(barrierRequest);
try {
future.get(10, TimeUnit.SECONDS); /* If successful, we can discard the reply. */
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
log.error("Switch {} doesn't support barrier messages? OVS should.", sw.toString());
}
}
示例6: processOFMessage
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Process an OF message received on the channel and
* update state accordingly.
* 处理从管道接收的OF报文并更新状态
* The main "event" of the state machine. Process the received message,
* send follow up message if required and update state if required.
* 处理接收报文,如果需要发送跟踪报文和更新状态
* Switches on the message type and calls more specific event handlers
* for each individual OF message type. If we receive a message that
* is supposed to be sent from a controller to a switch we throw
* a SwitchStateExeption.
*
* The more specific handlers can also throw SwitchStateExceptions
*
* @param h The OFChannelHandler that received the message
* @param m The message we received.
* @throws SwitchStateException
* @throws IOException
*/
void processOFMessage(OFMessage m) {
roleChanger.checkTimeout();
switch(m.getType()) {
case BARRIER_REPLY:
processOFBarrierReply((OFBarrierReply) m);
break;
case ERROR:
processOFError((OFErrorMsg) m);
break;
case FLOW_REMOVED:
processOFFlowRemoved((OFFlowRemoved) m);
break;
case GET_CONFIG_REPLY:
processOFGetConfigReply((OFGetConfigReply) m);
break;
case PACKET_IN:
processOFPacketIn((OFPacketIn) m);
break;
case PORT_STATUS:
processOFPortStatus((OFPortStatus) m);
break;
case QUEUE_GET_CONFIG_REPLY:
processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
break;
case STATS_REPLY:
processOFStatsReply((OFStatsReply) m);
break;
case ROLE_REPLY:
processOFRoleReply((OFRoleReply) m);
break;
case EXPERIMENTER:
processOFExperimenter((OFExperimenter) m);
break;
default:
illegalMessageReceived(m);
break;
}
}
示例7: barrierAsync
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
@Override
public OFMessageFuture<OFBarrierReply> barrierAsync(Dpid dpid) {
// TODO creation of message and future should be moved to OFSwitchImpl
IOFSwitch sw = floodlightProvider.getMasterSwitch(dpid.value());
if (sw == null) {
return null;
}
OFBarrierRequest msg = createBarrierRequest(sw);
OFBarrierReplyFuture future = new OFBarrierReplyFuture(threadPool, sw,
(int) msg.getXid());
barrierFutures.put(BarrierInfo.create(dpid.value(), msg), future);
addMessageImpl(dpid, msg, MsgPriority.NORMAL);
return future;
}
示例8: deliverBarrierReply
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
public void deliverBarrierReply(OFBarrierReply br) {
OFBarrierReplyFuture f = barrierFutureMap.get(br.getXid());
if (f != null) {
f.deliverFuture(this, br);
barrierFutureMap.remove(br.getXid());
} else {
log.warn("Rcvd unknown barrier reply xid: {} from sw: {}",
br.getXid(), getStringId());
}
}
示例9: testBarrierMessage
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Test barrier message is correctly sent to a switch.
*/
@Test
public void testBarrierMessage() {
beginInitMock();
Dpid dpid = new Dpid(1L);
IOFSwitch sw = createConnectedSwitchMock(dpid.value());
expect(sw.getOFVersion()).andReturn(OFVersion.OF_10).once();
try {
sw.write((OFMessage) anyObject(), eq((FloodlightContext) null));
expectLastCall().once();
} catch (IOException e1) {
fail("Failed in IOFWrite#write()");
}
replay(sw);
endInitMock();
initPusher(1);
OFMessageFuture<OFBarrierReply> future = pusher.barrierAsync(dpid);
assertNotNull(future);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
fail("Failed to sleep");
}
verifyAll();
pusher.stop();
}
示例10: processBarrierRequest
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
@Override
public void processBarrierRequest(Channel channel, OFMessage msg) {
// TODO check previous state requests have been handled before issuing BarrierReply
OFBarrierReply ofBarrierReply = FACTORY.buildBarrierReply()
.setXid(msg.getXid())
.build();
log.trace("request {}; reply {}", msg, ofBarrierReply);
channel.writeAndFlush(Collections.singletonList(ofBarrierReply));
}
示例11: processOFBarrierReply
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
@Override
void processOFBarrierReply(OFChannelHandler h, OFBarrierReply m) {
// do nothing;
}
示例12: processOFBarrierReply
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
void processOFBarrierReply(OFBarrierReply m) {
// do nothing
}
示例13: testMessageDispatchComplete
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Test dispatch of messages while in Complete state
*/
@Test
public void testMessageDispatchComplete() throws Exception {
moveToComplete();
newConnection.getValue().setListener(connectionListener);
resetChannel();
expect(channel.writeAndFlush(capture(writeCapture))).andReturn(null).once();
replay(channel);
// Send echo request. expect reply
OFMessage echoRequest = factory.buildEchoRequest().build();
sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(echoRequest));
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.ECHO_REPLY, msgs.get(0).getType());
// Send barrier reply. expect dispatch
OFBarrierReply barrierReply = factory.buildBarrierReply()
.build();
resetAndExpectConnectionListener(barrierReply);
// Send packet in. expect dispatch
OFFlowRemoved flowRemoved = factory.buildFlowRemoved()
.build();
resetAndExpectConnectionListener(flowRemoved);
// Send get config reply. expect dispatch
OFGetConfigReply getConfigReply = factory.buildGetConfigReply()
.build();
resetAndExpectConnectionListener(getConfigReply);
// Send packet in. expect dispatch
OFPacketIn pi = factory.buildPacketIn()
.setReason(OFPacketInReason.NO_MATCH)
.build();
resetAndExpectConnectionListener(pi);
// Send port status. expect dispatch
OFPortStatus portStatus = factory.buildPortStatus()
.setReason(OFPortReason.DELETE)
.setDesc(portDesc)
.build();
resetAndExpectConnectionListener(portStatus);
// Send queue reply. expect dispatch
OFQueueGetConfigReply queueReply = factory.buildQueueGetConfigReply()
.build();
resetAndExpectConnectionListener(queueReply);
// Send stat reply. expect dispatch
OFFlowStatsReply statReply = factory.buildFlowStatsReply()
.build();
resetAndExpectConnectionListener(statReply);
// Send role reply. expect dispatch
OFRoleReply roleReply = factory.buildRoleReply()
.setRole(OFControllerRole.ROLE_MASTER)
.build();
resetAndExpectConnectionListener(roleReply);
// Send experimenter. expect dispatch
OFBsnSetAuxCxnsReply auxReply = factory.buildBsnSetAuxCxnsReply()
.build();
resetAndExpectConnectionListener(auxReply);
}
示例14: testMessageDispatchComplete
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Test dispatch of messages while in Complete state
*/
@Test
public void testMessageDispatchComplete() throws Exception {
moveToComplete();
newConnection.getValue().setListener(connectionListener);
resetChannel();
expect(channel.writeAndFlush(capture(writeCapture))).andReturn(null).atLeastOnce();
replay(channel);
// Send echo request. expect reply
OFMessage echoRequest = factory.buildEchoRequest().build();
sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(echoRequest));
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.ECHO_REPLY, msgs.get(0).getType());
// Send barrier reply. expect dispatch
OFBarrierReply barrierReply = factory.buildBarrierReply()
.build();
resetAndExpectConnectionListener(barrierReply);
// Send packet in. expect dispatch
OFFlowRemoved flowRemoved = factory.buildFlowRemoved()
.build();
resetAndExpectConnectionListener(flowRemoved);
// Send get config reply. expect dispatch
OFGetConfigReply getConfigReply = factory.buildGetConfigReply()
.build();
resetAndExpectConnectionListener(getConfigReply);
// Send packet in. expect dispatch
OFPacketIn pi = factory.buildPacketIn()
.setReason(OFPacketInReason.NO_MATCH)
.build();
resetAndExpectConnectionListener(pi);
// Send port status. expect dispatch
OFPortStatus portStatus = factory.buildPortStatus()
.setReason(OFPortReason.DELETE)
.setDesc(portDesc)
.build();
resetAndExpectConnectionListener(portStatus);
// Send queue reply. expect dispatch
OFQueueGetConfigReply queueReply = factory.buildQueueGetConfigReply()
.build();
resetAndExpectConnectionListener(queueReply);
// Send stat reply. expect dispatch
OFFlowStatsReply statReply = factory.buildFlowStatsReply()
.build();
resetAndExpectConnectionListener(statReply);
// Send role reply. expect dispatch
OFNiciraControllerRoleReply roleReply = factory.buildNiciraControllerRoleReply()
.setRole(OFNiciraControllerRole.ROLE_MASTER)
.build();
resetAndExpectConnectionListener(roleReply);
}
示例15: setupSwitchRoleChangeUnsupported
import org.projectfloodlight.openflow.protocol.OFBarrierReply; //导入依赖的package包/类
/**
* Setup the mock switch for a role change request where the switch
* does not support roles.
*
* Needs to verify and reset the controller since we need to set
* an expectation
*/
@SuppressWarnings("unchecked")
private void setupSwitchRoleChangeUnsupported(int xid,
OFControllerRole role) {
SwitchStatus newStatus = role != OFControllerRole.ROLE_SLAVE ? SwitchStatus.MASTER : SwitchStatus.SLAVE;
boolean supportsNxRole = false;
verify(switchManager);
reset(sw, switchManager);
expect(sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(supportsNxRole).atLeastOnce();
// TODO: hmmm. While it's not incorrect that we set the attribute
// again it looks odd. Maybe change
expect(sw.getOFFactory()).andReturn(factory).anyTimes();
expect(sw.write(anyObject(OFMessage.class))).andReturn(true).anyTimes();
expect(sw.write(anyObject(Iterable.class))).andReturn(Collections.EMPTY_LIST).anyTimes();
expect(sw.getNumTables()).andStubReturn((short)0);
sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, supportsNxRole);
expectLastCall().anyTimes();
if (SwitchStatus.MASTER == newStatus) {
if (factory.getVersion().compareTo(OFVersion.OF_13) >= 0) {
expect(sw.getTables()).andReturn(Collections.EMPTY_LIST).once();
expect(sw.getTableFeatures(TableId.ZERO)).andReturn(TableFeatures.of(createTableFeaturesStatsReply().getEntries().get(0))).anyTimes();
}
}
sw.setControllerRole(role);
expectLastCall().once();
if (role == OFControllerRole.ROLE_SLAVE) {
sw.disconnect();
expectLastCall().once();
} else {
expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE).once();
sw.setStatus(newStatus);
expectLastCall().once();
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, newStatus);
}
replay(sw, switchManager);
switchHandler.sendRoleRequest(role);
/* Now, trigger transition to master */
OFBarrierReply br = getFactory().buildBarrierReply()
.build();
switchHandler.processOFMessage(br);
verify(sw, switchManager);
}