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


Java OFError.setErrorCode方法代码示例

本文整理汇总了Java中org.openflow.protocol.OFError.setErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java OFError.setErrorCode方法的具体用法?Java OFError.setErrorCode怎么用?Java OFError.setErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openflow.protocol.OFError的用法示例。


在下文中一共展示了OFError.setErrorCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReassertMaster

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
/**
 * Test re-assert MASTER
 *
 */
@Test
public void testReassertMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    OFError err = (OFError)
            BasicFactory.getInstance().getMessage(OFType.ERROR);
    err.setXid(42);
    err.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
    err.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);

    reset(controller);
    controller.reassertRole(handler, Role.MASTER);
    expectLastCall().once();
    controller.handleMessage(sw, err, null);
    expectLastCall().once();

    sendMessageToHandlerNoControllerReset(
            Collections.<OFMessage>singletonList(err));

    verify(sw);
    verify(controller);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:OFChannelHandlerTest.java

示例2: testDeliverRoleRequestErrorWrongXid

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
public void testDeliverRoleRequestErrorWrongXid() {
    // wrong xid received 
    // wrong xid received 
    int xid = (int) System.currentTimeMillis();
    long cookie = System.nanoTime();
    Role role = Role.MASTER;
    OFSwitchImpl sw = new OFSwitchImpl();
    setupPendingRoleRequest(sw, xid, role, cookie);
    Channel ch = createMock(Channel.class);
    SocketAddress sa = new InetSocketAddress(42);
    expect(ch.getRemoteAddress()).andReturn(sa).anyTimes();
    expect(ch.close()).andReturn(null);
    sw.setChannel(ch);
    replay(ch);
    OFError error = new OFError();
    error.setErrorCode(OFError.OFErrorType.OFPET_BAD_REQUEST.getValue());
    error.setXid(xid + 1);
    roleChanger.deliverRoleRequestError(sw, error);
    verify(ch);
    assertEquals(null, sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE));
    assertEquals(1, roleChanger.pendingRequestMap.get(sw).size());
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:24,代码来源:RoleChangerTest.java

示例3: getErrorMessage

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
/** Return an OFError of the given type with the given xid */
private OFMessage getErrorMessage(OFErrorType type,
                                  int i,
                                  int xid) {
    OFError e = (OFError) BasicFactory.getInstance()
            .getMessage(OFType.ERROR);
    e.setErrorType(type);
    e.setErrorCode((short)i);
    e.setXid(xid);
    return e;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:12,代码来源:OFChannelHandlerTest.java

示例4: testErrorEPERM

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
 public void testErrorEPERM() throws Exception {
     // Check behavior with a BAD_REQUEST/EPERM error
     // Ensure controller attempts to reset switch role.
     OFChannelState state = new OFChannelState();
     state.hsState = HandshakeState.READY;
     Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
     OFError error = new OFError();
     error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
     error.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
     IOFSwitch sw = createMock(IOFSwitch.class);
     chdlr.sw = sw;
     controller.activeSwitches.put(1L, sw);

     // prepare the switch and lock expectations
     Lock lock = createNiceMock(Lock.class);
     expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
     expect(sw.isConnected()).andReturn(true).anyTimes();
     expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
     expect(sw.getId()).andReturn(1L).anyTimes();

     // Make sure controller attempts to reset switch master
     expect(sw.getAttribute("supportsNxRole")).andReturn(true).anyTimes();
     expect(sw.getNextTransactionId()).andReturn(0).anyTimes();
     sw.write(EasyMock.<List<OFMessage>> anyObject(),
              (ListenerContext)anyObject());

     // test
     replay(sw, lock);
     chdlr.processOFMessage(error);
     // Verify there is a pending role change request
     assertTrue(controller.roleChanger.pendingTasks.peek() != null);
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:34,代码来源:ControllerTest.java

示例5: testRoleNotSupportedError

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
public void testRoleNotSupportedError() throws Exception {
    int xid = 424242;
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    Channel ch = createMock(Channel.class);
    
    // the error returned when role request message is not supported by sw
    OFError msg = new OFError();
    msg.setType(OFType.ERROR);
    msg.setXid(xid);
    msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
    msg.setErrorCode(OFBadRequestCode.OFPBRC_BAD_VENDOR);
    
    // the switch connection should get disconnected when the controller is
    // in SLAVE mode and the switch does not support role-request messages
    state.firstRoleReplyReceived = false;
    controller.role = Role.SLAVE;
    expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
    chdlr.sw.deliverRoleRequestNotSupported(xid);
    expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
    expect(ch.close()).andReturn(null);
    
    replay(ch, chdlr.sw);
    chdlr.processOFMessage(msg);
    verify(ch, chdlr.sw);
    assertTrue("state.firstRoleReplyReceived must be true", 
               state.firstRoleReplyReceived);
    assertTrue("activeSwitches must be empty",
               controller.activeSwitches.isEmpty());
    reset(ch, chdlr.sw);
          
    
    // a different error message - should also reject role request
    msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
    msg.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
    state.firstRoleReplyReceived = false;
    controller.role = Role.SLAVE;
    expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
    chdlr.sw.deliverRoleRequestNotSupported(xid);
    expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
    expect(ch.close()).andReturn(null);
    replay(ch, chdlr.sw);
    
    chdlr.processOFMessage(msg);
    verify(ch, chdlr.sw);
    assertTrue("state.firstRoleReplyReceived must be True even with EPERM",
               state.firstRoleReplyReceived);
    assertTrue("activeSwitches must be empty", 
               controller.activeSwitches.isEmpty());
    reset(ch, chdlr.sw);

    
    // We are MASTER, the switch should be added to the list of active
    // switches.
    state.firstRoleReplyReceived = false;
    controller.role = Role.MASTER;
    expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
    chdlr.sw.deliverRoleRequestNotSupported(xid);
    setupSwitchForAddSwitch(chdlr.sw, 0L);
    chdlr.sw.clearAllFlowMods();
    replay(ch, chdlr.sw);
    
    chdlr.processOFMessage(msg);
    verify(ch, chdlr.sw);
    assertTrue("state.firstRoleReplyReceived must be true", 
               state.firstRoleReplyReceived);
    assertSame("activeSwitches must contain this switch",
               chdlr.sw, controller.activeSwitches.get(0L));
    reset(ch, chdlr.sw);

}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:75,代码来源:ControllerTest.java

示例6: testErrorEPERM

import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
 public void testErrorEPERM() throws Exception {
     // Check behavior with a BAD_REQUEST/EPERM error
     // Ensure controller attempts to reset switch role.
     OFChannelState state = new OFChannelState();
     state.hsState = HandshakeState.READY;
     Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
     OFError error = new OFError();
     error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
     error.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
     IOFSwitch sw = createMock(IOFSwitch.class);
     chdlr.sw = sw;
     controller.activeSwitches.put(1L, sw);

     // prepare the switch and lock expectations
     Lock lock = createNiceMock(Lock.class);
     expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
     expect(sw.isConnected()).andReturn(true).anyTimes();
     expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
     expect(sw.getId()).andReturn(1L).anyTimes();

     // Make sure controller attempts to reset switch master
     expect(sw.getAttribute("supportsNxRole")).andReturn(true).anyTimes();
     expect(sw.getNextTransactionId()).andReturn(0).anyTimes();
     sw.write(EasyMock.<List<OFMessage>> anyObject(),
              (FloodlightContext)anyObject());

     // test
     replay(sw, lock);
     chdlr.processOFMessage(error);
     DelayQueue<RoleChangeTask> pendingTasks =
             controller.roleChanger.pendingTasks;
     synchronized (pendingTasks) {
         RoleChangeTask t;
         while ((t = pendingTasks.peek()) == null ||
                 RoleChanger.RoleChangeTask.Type.TIMEOUT != t.type) {
             pendingTasks.wait();
         }
     }
     // Now there should be exactly one timeout task pending
     assertEquals(1, pendingTasks.size());
}
 
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:43,代码来源:ControllerTest.java


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