本文整理汇总了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);
}
}
}
示例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();
}
}
示例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);
}