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


Java IOFSwitchListener类代码示例

本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitchListener的典型用法代码示例。如果您正苦于以下问题:Java IOFSwitchListener类的具体用法?Java IOFSwitchListener怎么用?Java IOFSwitchListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testNewSwitchActivatedWhileSlave

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Test switchActivated for a new switch while in slave: disconnect the switch
 */
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
    doSetUp(HARole.STANDBY);
    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);

    expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
    expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
    sw.disconnect();
    expectLastCall().once();
    expect(sw.getOFFactory()).andReturn(factory).once();
    replay(sw, listener); // nothing recorded
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    controller.processUpdateQueueForTesting();
    verify(listener);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:OFSwitchManagerTest.java

示例2: testSwitchDisconnectedOther

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Try to remove a switch that's different from what's in the active
 * switch map. Should be ignored
 */
@Test
public void testSwitchDisconnectedOther() throws Exception {
    IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
    // create a new mock switch
    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);
    replay(sw, listener);
    switchManager.switchDisconnected(sw);
    controller.processUpdateQueueForTesting();
    verify(sw, listener);

    expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
    replay(origSw);
    assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:OFSwitchManagerTest.java

示例3: testNewSwitchActivatedWhileSlave

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Test switchActivated for a new switch while in slave: disconnect the switch
 */
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
    doSetUp(HARole.STANDBY);
    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);

    expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
    expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
    sw.disconnect();
    expectLastCall().once();
    replay(sw, listener); // nothing recorded
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    controller.processUpdateQueueForTesting();
    verify(listener);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:OFSwitchManagerTest.java

示例4: doTestSwitchConnectReconnect

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Disconnect a switch. normal program flow
 */
@Test
private void doTestSwitchConnectReconnect(boolean reconnect)
        throws Exception {
    IOFSwitch sw = doActivateNewSwitch(1L, null, null);
    expect(sw.getId()).andReturn(1L).anyTimes();
    expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
    sw.cancelAllStatisticsReplies();
    expectLastCall().once();
    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    listener.switchRemoved(1L);
    expectLastCall().once();
    controller.addOFSwitchListener(listener);
    replay(sw, listener);
    controller.switchDisconnected(sw);
    controller.processUpdateQueueForTesting();
    verify(sw, listener);

    assertNull(controller.getSwitch(1L));
    assertNull(storeClient.getValue(1L));
    if (reconnect) {
        controller.removeOFSwitchListener(listener);
        sw = doActivateOldSwitch(1L, null, null);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:28,代码来源:ControllerTest.java

示例5: testNonexistingSwitchDisconnected

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Remove a nonexisting switch. should be ignored
 */
@Test
public void testNonexistingSwitchDisconnected() throws Exception {
    IOFSwitch sw = createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(1L).anyTimes();
    expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    controller.addOFSwitchListener(listener);
    replay(sw, listener);
    controller.switchDisconnected(sw);
    controller.processUpdateQueueForTesting();
    verify(sw, listener);

    assertNull(controller.getSwitch(1L));
    assertNull(storeClient.getValue(1L));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:ControllerTest.java

示例6: testSwitchDisconnectedOther

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Try to remove a switch that's different from what's in the active
 * switch map. Should be ignored
 */
@Test
public void testSwitchDisconnectedOther() throws Exception {
    IOFSwitch origSw = doActivateNewSwitch(1L, null, null);
    // create a new mock switch
    IOFSwitch sw = createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(1L).anyTimes();
    expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    controller.addOFSwitchListener(listener);
    replay(sw, listener);
    controller.switchDisconnected(sw);
    controller.processUpdateQueueForTesting();
    verify(sw, listener);

    assertSame(origSw, controller.getSwitch(1L));
    assertNotNull(storeClient.getValue(1L));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:22,代码来源:ControllerTest.java

示例7: dispatch

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
public void dispatch() {
    if (log.isTraceEnabled()) {
        log.trace("Dispatching switch update {} {}",
                sw, switchUpdateType);
    }
    if (switchListeners != null) {
        for (IOFSwitchListener listener : switchListeners) {
            switch(switchUpdateType) {
                case ADDED:
                    listener.addedSwitch(sw);
                    break;
                case REMOVED:
                    listener.removedSwitch(sw);
                    break;
                case PORTCHANGED:
                    listener.switchPortChanged(sw.getId());
                    break;
            }
        }
    }
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:22,代码来源:Controller.java

示例8: init

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Initialize internal data structures
 */
public void init(Map<String, String> configParams) {
    // These data structures are initialized here because other
    // module's startUp() might be called before ours
    this.messageListeners =
            new ConcurrentHashMap<OFType, 
                                  ListenerDispatcher<OFType, 
                                                     IOFMessageListener>>();
    this.switchListeners = new CopyOnWriteArraySet<IOFSwitchListener>();
    this.haListeners = new CopyOnWriteArraySet<IHAListener>();
    this.activeSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
    this.connectedSwitches = new HashSet<OFSwitchImpl>();
    this.controllerNodeIPsCache = new HashMap<String, String>();
    this.updates = new LinkedBlockingQueue<IUpdate>();
    this.factory = new BasicFactory();
    this.providerMap = new HashMap<String, List<IInfoProvider>>();
    setConfigParams(configParams);
    this.role = getInitialRole(configParams);
    this.roleChanger = new RoleChanger();
    initVendorMessages();
    this.systemStartTime = System.currentTimeMillis();
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:25,代码来源:Controller.java

示例9: testSwitchActivatedMaster

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Test adding a new switch in the MASTER role.
 * We expect a switchActivatedMaster event fired to the switch listeners.
 */
@Test
public void testSwitchActivatedMaster() throws Exception {
    long dpid = 1L;

    controller.setAlwaysClearFlowsOnSwActivate(false);
    controller.setAlwaysClearFlowsOnSwAdd(false);

    // Create a 1.0 switch. There's no difference between 1.0 and 1.3 here.
    IOFSwitch sw = createMockSwitch(dpid, OFVersion.OF_10);

    // strict mock. Order of events matters!
    IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
    listener.switchActivatedMaster(dpid);
    expectLastCall().once();
    replay(listener);
    controller.addOFSwitchListener(listener);

    replay(sw);
    controller.addConnectedSwitch(dpid, new OFChannelHandler(controller));
    controller.addActivatedMasterSwitch(dpid, sw);
    verify(sw);
    assertEquals(sw, controller.getMasterSwitch(dpid));
    controller.processUpdateQueueForTesting();
    verify(listener);
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:30,代码来源:ControllerTest.java

示例10: testSwitchActivatedEqual

import net.floodlightcontroller.core.IOFSwitchListener; //导入依赖的package包/类
/**
 * Test adding a new switch in the EQUAL role.
 * We expect a switchActivatedEqual event fired to the switch listeners.
 */
@Test
public void testSwitchActivatedEqual() throws Exception {
    long dpid = 1L;
    // Create a 1.0 switch. There's no difference between 1.0 and 1.3 here.
    IOFSwitch sw = createMockSwitch(dpid, OFVersion.OF_10);

    IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
    controller.addOFSwitchListener(listener);

    listener.switchActivatedEqual(dpid);
    replay(sw, listener); // nothing recorded
    controller.addConnectedSwitch(dpid, new OFChannelHandler(controller));
    controller.addActivatedEqualSwitch(dpid, sw);
    verify(sw);
    controller.processUpdateQueueForTesting();
    verify(listener);
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:22,代码来源:ControllerTest.java


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