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


Java OFEchoRequest类代码示例

本文整理汇总了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));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OFChannelHandler.java

示例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));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:OFConnectionTest.java

示例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));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:OFConnectionTest.java

示例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));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:OFConnectionTest.java

示例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));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:OFConnectionTest.java

示例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);
}
 
开发者ID:tignetworking,项目名称:stopcock,代码行数:24,代码来源:ProxiedConnection.java

示例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);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:OFChannelHandler.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:9,代码来源:OFChannelHandler.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:8,代码来源:OFChannelHandler.java

示例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));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:OFConnectionTest.java

示例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));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:8,代码来源:OFChannelHandler.java


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