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


Java IOFSwitchBackend.cancelAllPendingRequests方法代码示例

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


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

示例1: switchAdded

import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的package包/类
@Override
public synchronized void switchAdded(IOFSwitchBackend sw) {
	DatapathId dpid = sw.getId();
	IOFSwitchBackend oldSw = this.switches.put(dpid, sw);
	// Update event history
	evSwitch.newEventWithFlush(new SwitchEvent(dpid, "connected"));

	if (oldSw == sw)  {
		// Note == for object equality, not .equals for value
		counters.errorActivatedSwitchNotPresent.increment();
		log.error("Switch {} added twice?", sw);
		return;
	} else if (oldSw != null) {
		// This happens either when we have switches with duplicate
		// DPIDs or when a switch reconnects before we saw the
		// disconnect
		counters.switchWithSameDpidActivated.increment();
		log.warn("New switch added {} for already-added switch {}", sw, oldSw);
		// We need to disconnect and remove the old switch
		// TODO: we notify switch listeners that the switch has been
		// removed and then we notify them that the new one has been
		// added. One could argue that a switchChanged notification
		// might be more appropriate in this case....
		oldSw.cancelAllPendingRequests();
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
		oldSw.disconnect();
	}

	/*
	 * Set some other config options for this switch.
	 */
	if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_13) >= 0) {
		if (forwardToControllerFlowsUpToTableByDpid.containsKey(sw.getId())) {
			sw.setMaxTableForTableMissFlow(forwardToControllerFlowsUpToTableByDpid.get(sw.getId()));
		} else {
			sw.setMaxTableForTableMissFlow(forwardToControllerFlowsUpToTable);
		}
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:OFSwitchManager.java

示例2: switchAdded

import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的package包/类
@Override
public synchronized void switchAdded(IOFSwitchBackend sw) {
	DatapathId dpid = sw.getId();
	IOFSwitchBackend oldSw = this.switches.put(dpid, sw);
	// Update event history
	evSwitch.newEventWithFlush(new SwitchEvent(dpid, "connected"));

	if (oldSw == sw)  {
		// Note == for object equality, not .equals for value
		counters.errorActivatedSwitchNotPresent.increment();
		log.error("Switch {} added twice?", sw);
		return;
	} else if (oldSw != null) {
		// This happens either when we have switches with duplicate
		// DPIDs or when a switch reconnects before we saw the
		// disconnect
		counters.switchWithSameDpidActivated.increment();
		log.warn("New switch added {} for already-added switch {}", sw, oldSw);
		// We need to disconnect and remove the old switch
		// TODO: we notify switch listeners that the switch has been
		// removed and then we notify them that the new one has been
		// added. One could argue that a switchChanged notification
		// might be more appropriate in this case....
		oldSw.cancelAllPendingRequests();
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
		oldSw.disconnect();
	}

}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:30,代码来源:OFSwitchManager.java

示例3: testSwitchActivatedWithAlreadyActiveSwitch

import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的package包/类
/**
 * Try to activate a switch that's already active (which can happen if
 * two different switches have the same DPIP or if a switch reconnects
 * while the old TCP connection is still alive
 */
@Test
public void testSwitchActivatedWithAlreadyActiveSwitch() throws Exception {
    SwitchDescription oldDescription = new SwitchDescription(
            "", "", "", "", "Ye Olde Switch");
    SwitchDescription newDescription = new SwitchDescription(
            "", "", "", "", "The new Switch");
    OFFeaturesReply featuresReply = createOFFeaturesReply(DATAPATH_ID_0);


    // Setup: add a switch to the controller
    IOFSwitchBackend oldsw = createMock(IOFSwitchBackend.class);
    setupSwitchForAddSwitch(oldsw, DATAPATH_ID_0, oldDescription, featuresReply);
    replay(oldsw);
    switchManager.switchAdded(oldsw);
    switchManager.switchStatusChanged(oldsw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(oldsw);
    // drain the queue, we don't care what's in it
    controller.processUpdateQueueForTesting();
    assertEquals(oldsw, switchManager.getSwitch(DATAPATH_ID_0));

    // Now the actual test: add a new switch with the same dpid to
    // the controller
    reset(oldsw);
    expect(oldsw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
    oldsw.cancelAllPendingRequests();
    expectLastCall().once();
    oldsw.disconnect();
    expectLastCall().once();


    IOFSwitchBackend newsw = createMock(IOFSwitchBackend.class);
    setupSwitchForAddSwitch(newsw, DATAPATH_ID_0, newDescription, featuresReply);

    // Strict mock. We need to get the removed notification before the
    // add notification
    IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
    listener.switchRemoved(DATAPATH_ID_0);
    listener.switchAdded(DATAPATH_ID_0);
    listener.switchActivated(DATAPATH_ID_0);
    replay(listener);
    switchManager.addOFSwitchListener(listener);


    replay(newsw, oldsw);
    switchManager.switchAdded(newsw);
    switchManager.switchStatusChanged(newsw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(newsw, oldsw);

    assertEquals(newsw, switchManager.getSwitch(DATAPATH_ID_0));
    controller.processUpdateQueueForTesting();
    verify(listener);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:58,代码来源:OFSwitchManagerTest.java


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