本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFEchoRequest类的典型用法代码示例。如果您正苦于以下问题:Java OFEchoRequest类的具体用法?Java OFEchoRequest怎么用?Java OFEchoRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFEchoRequest类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFEchoRequest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOFEchoRequest
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
void processOFEchoRequest(OFChannelHandler h, OFEchoRequest m)
throws IOException {
if (h.ofVersion == null) {
log.error("No OF version set for {}. Not sending Echo REPLY",
h.channel.getRemoteAddress());
return;
}
OFFactory factory = (h.ofVersion == OFVersion.OF_13) ?
h.controller.getOFMessageFactory13() : h.controller.getOFMessageFactory10();
OFEchoReply reply = factory
.buildEchoReply()
.setXid(m.getXid())
.setData(m.getData())
.build();
h.channel.write(Collections.singletonList(reply));
}
示例2: testWriteRequestNotConnectedFailure
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Test(timeout = 5000)
public void testWriteRequestNotConnectedFailure() throws InterruptedException,
ExecutionException {
EasyMock.expect(channel.isActive()).andReturn(Boolean.FALSE).anyTimes();
replay(channel);
OFEchoRequest echoRequest = factory.echoRequest(new byte[] {});
ListenableFuture<OFEchoReply> future = conn.writeRequest(echoRequest);
SwitchDisconnectedException e =
FutureTestUtils.assertFutureFailedWithException(future,
SwitchDisconnectedException.class);
assertThat(e.getId(), equalTo(switchId));
assertThat("Connection should have no pending requests",
conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
示例3: testWriteRequestDisconnectFailure
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Test(timeout = 5000)
public void testWriteRequestDisconnectFailure() throws InterruptedException, ExecutionException {
prepareChannelForWriteList();
OFEchoRequest echoRequest = factory.echoRequest(new byte[] {});
ListenableFuture<OFEchoReply> future = conn.writeRequest(echoRequest);
assertThat("Connection should have 1 pending request", conn.getPendingRequestIds().size(),
equalTo(1));
assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
conn.disconnected();
SwitchDisconnectedException e =
FutureTestUtils.assertFutureFailedWithException(future,
SwitchDisconnectedException.class);
assertThat(e.getId(), equalTo(switchId));
assertThat("Connection should have no pending requests",
conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
示例4: testWriteRequestSuccess
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Test(timeout = 5000)
public void testWriteRequestSuccess() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFEchoRequest echoRequest = factory.echoRequest(new byte[] {});
ListenableFuture<OFEchoReply> future = conn.writeRequest(echoRequest);
assertThat("Connection should have 1 pending request",
conn.getPendingRequestIds().size(), equalTo(1));
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(echoRequest));
assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
OFEchoReply echoReply = factory.buildEchoReply()
.setXid(echoRequest.getXid())
.build();
assertThat("Connection should have accepted the response",
conn.deliverResponse(echoReply),
equalTo(true));
assertThat("Future should be complete ", future.isDone(), equalTo(true));
assertThat(future.get(), equalTo(echoReply));
assertThat("Connection should have no pending requests",
conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
示例5: testWriteRequestNotConnectedFailure
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Test(timeout = 5000)
public void testWriteRequestNotConnectedFailure() throws InterruptedException,
ExecutionException {
EasyMock.expect(channel.isConnected()).andReturn(Boolean.FALSE).anyTimes();
replay(channel);
OFEchoRequest echoRequest = factory.echoRequest(new byte[] {});
ListenableFuture<OFEchoReply> future = conn.writeRequest(echoRequest);
SwitchDisconnectedException e =
FutureTestUtils.assertFutureFailedWithException(future,
SwitchDisconnectedException.class);
assertThat(e.getId(), equalTo(switchId));
assertThat("Connection should have no pending requests",
conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
示例6: createPing
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
/**
* Construct a suitable OpenFlow echo request based upon the OpenFlow version the upstream channel advertised
* version.
*
* @return Container with a suitable echo request
*/
public Container createPing() {
ByteBuf byteBuf = upstream.alloc().buffer(8);
NettyCompatibilityChannelBuffer compatBuffer = new NettyCompatibilityChannelBuffer(byteBuf);
OFEchoRequest request = OFFactories.getFactory(upstreamVersion).echoRequest(ECHO_DATA);
request.writeTo(compatBuffer);
byte[] rawData = new byte[compatBuffer.readableBytes()];
compatBuffer.resetReaderIndex();
compatBuffer.readBytes(rawData);
ReferenceCountUtil.release(byteBuf);
Header header = new Header((short) upstreamVersion.getWireVersion(), (short) Type.OFPT_ECHO_REQUEST.getId(), 8, request.getXid());
return new Container(header, rawData, Type.OFPT_ECHO_REQUEST, request);
}
示例7: processOFMessage
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Override
void processOFMessage(OFChannelHandler h, OFMessage m)
throws IOException, SwitchStateException {
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
h.state.processOFMessage(h, m);
return;
}
if (m.getType() == OFType.ECHO_REQUEST) {
processOFEchoRequest(h, (OFEchoRequest) m);
} else if (m.getType() == OFType.ECHO_REPLY) {
processOFEchoReply(h, (OFEchoReply) m);
} else if (m.getType() == OFType.ROLE_REPLY) {
h.sw.handleRole(m);
} else if (m.getType() == OFType.ERROR) {
if (!h.sw.handleRoleError((OFErrorMsg)m)) {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
}
}
} else {
if (m.getType() == OFType.EXPERIMENTER &&
((OFExperimenter) m).getExperimenter() ==
RoleManager.NICIRA_EXPERIMENTER) {
h.sw.handleNiciraRole(m);
} else {
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
moveToActive(h);
}
}
}
}
示例8: sendEchoRequest
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
private void sendEchoRequest() {
OFEchoRequest request = factory.buildEchoRequest()
.setXid(handshakeTransactionIds--)
.build();
/* Record for latency calculation */
echoSendTime = System.currentTimeMillis();
write(request);
}
示例9: sendEchoReply
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
private void sendEchoReply(OFEchoRequest request) {
OFEchoReply reply = factory.buildEchoReply()
.setXid(request.getXid())
.setData(request.getData())
.build();
write(reply);
}
示例10: testWriteRequestSuccess
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
@Test(timeout = 5000)
public void testWriteRequestSuccess() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFEchoRequest echoRequest = factory.echoRequest(new byte[] {});
ListenableFuture<OFEchoReply> future = conn.writeRequest(echoRequest);
assertThat("Connection should have 1 pending request",
conn.getPendingRequestIds().size(), equalTo(1));
eventLoop.runTasks();
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(echoRequest));
assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
OFEchoReply echoReply = factory.buildEchoReply()
.setXid(echoRequest.getXid())
.build();
assertThat("Connection should have accepted the response",
conn.deliverResponse(echoReply),
equalTo(true));
assertThat("Future should be complete ", future.isDone(), equalTo(true));
assertThat(future.get(), equalTo(echoReply));
assertThat("Connection should have no pending requests",
conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
示例11: sendEchoReply
import org.projectfloodlight.openflow.protocol.OFEchoRequest; //导入依赖的package包/类
private void sendEchoReply(OFEchoRequest request) {
OFEchoReply reply = factory.buildEchoReply()
.setXid(request.getXid())
.setData(request.getData())
.build();
channel.write(Collections.singletonList(reply));
}