本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitchListener.switchRemoved方法的典型用法代码示例。如果您正苦于以下问题:Java IOFSwitchListener.switchRemoved方法的具体用法?Java IOFSwitchListener.switchRemoved怎么用?Java IOFSwitchListener.switchRemoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.core.IOFSwitchListener
的用法示例。
在下文中一共展示了IOFSwitchListener.switchRemoved方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: dispatch
import net.floodlightcontroller.core.IOFSwitchListener; //导入方法依赖的package包/类
@Override
public void dispatch() {
if (log.isTraceEnabled()) {
log.trace("Dispatching switch update {} {}", swId, switchUpdateType);
}
if (switchListeners != null) {
for (IOFSwitchListener listener : switchListeners) {
switch(switchUpdateType) {
case ADDED:
// don't count here. We have more specific
// counters before the update is created
listener.switchAdded(swId);
break;
case REMOVED:
// don't count here. We have more specific
// counters before the update is created
listener.switchRemoved(swId);
break;
case PORTCHANGED:
counters.switchPortChanged
.increment();
listener.switchPortChanged(swId, port, changeType);
break;
case ACTIVATED:
// don't count here. We have more specific
// counters before the update is created
listener.switchActivated(swId);
break;
case DEACTIVATED:
// ignore
break;
case OTHERCHANGE:
counters.switchOtherChange
.increment();
listener.switchChanged(swId);
break;
}
}
}
}
示例3: dispatch
import net.floodlightcontroller.core.IOFSwitchListener; //导入方法依赖的package包/类
@Override
public void dispatch() {
if (log.isTraceEnabled()) {
log.trace("Dispatching switch update {} {}",
HexString.toHexString(swId), switchUpdateType);
}
if (switchListeners != null) {
for (IOFSwitchListener listener : switchListeners) {
switch(switchUpdateType) {
case ADDED:
// don't count here. We have more specific
// counters before the update is created
listener.switchAdded(swId);
break;
case REMOVED:
// don't count here. We have more specific
// counters before the update is created
listener.switchRemoved(swId);
break;
case PORTCHANGED:
counters.switchPortChanged.updateCounterWithFlush();
listener.switchPortChanged(swId, port, changeType);
break;
case ACTIVATED:
// don't count here. We have more specific
// counters before the update is created
listener.switchActivated(swId);
break;
case DEACTIVATED:
// ignore
break;
case OTHERCHANGE:
counters.switchOtherChange.updateCounterWithFlush();
listener.switchChanged(swId);
break;
}
}
}
}
示例4: testAddSwitchRemoveSwitchStoreSlave
import net.floodlightcontroller.core.IOFSwitchListener; //导入方法依赖的package包/类
/**
* add switch to store then remove it again while slave.
* should get notification and switch should be added and then removed
*/
@Test
public void testAddSwitchRemoveSwitchStoreSlave() throws Exception {
doSetUp(Role.SLAVE);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
//------
// Add switch
listener.switchAdded(1L);
expectLastCall().once();
replay(listener);
OFDescriptionStatistics desc = createOFDescriptionStatistics();
desc.setDatapathDescription("The Switch");
doAddSwitchToStore(1L, desc, null);
controller.processUpdateQueueForTesting();
verify(listener);
IOFSwitch sw = controller.getSwitch(1L);
assertNotNull("Switch should be present", sw);
assertEquals(1L, sw.getId());
assertFalse("Switch should be inactive", sw.isActive());
assertEquals("The Switch",
sw.getDescriptionStatistics().getDatapathDescription());
//------
// remove switch
reset(listener);
listener.switchRemoved(1L);
replay(listener);
doRemoveSwitchFromStore(1L);
controller.processUpdateQueueForTesting();
verify(listener);
assertNull("Switch should not exist anymore", controller.getSwitch(1L));
}
示例5: testSwitchActivatedWithAlreadyActiveSwitch
import net.floodlightcontroller.core.IOFSwitchListener; //导入方法依赖的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);
}
示例6: testSwitchActivatedWithAlreadyActiveSwitch
import net.floodlightcontroller.core.IOFSwitchListener; //导入方法依赖的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 {
OFDescriptionStatistics oldDesc = createOFDescriptionStatistics();
oldDesc.setDatapathDescription("Ye Olde Switch");
OFDescriptionStatistics newDesc = createOFDescriptionStatistics();
newDesc.setDatapathDescription("The new Switch");
OFFeaturesReply featuresReply = createOFFeaturesReply();
// Setup: add a switch to the controller
IOFSwitch oldsw = createMock(IOFSwitch.class);
setupSwitchForAddSwitch(oldsw, 0L, oldDesc, featuresReply);
oldsw.clearAllFlowMods();
expectLastCall().once();
replay(oldsw);
controller.switchActivated(oldsw);
verify(oldsw);
// drain the queue, we don't care what's in it
controller.processUpdateQueueForTesting();
assertEquals(oldsw, controller.getSwitch(0L));
// Now the actual test: add a new switch with the same dpid to
// the controller
reset(oldsw);
expect(oldsw.getId()).andReturn(0L).anyTimes();
oldsw.cancelAllStatisticsReplies();
expectLastCall().once();
oldsw.disconnectOutputStream();
expectLastCall().once();
IOFSwitch newsw = createMock(IOFSwitch.class);
setupSwitchForAddSwitch(newsw, 0L, newDesc, featuresReply);
newsw.clearAllFlowMods();
expectLastCall().once();
// Strict mock. We need to get the removed notification before the
// add notification
IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
listener.switchRemoved(0L);
listener.switchAdded(0L);
listener.switchActivated(0L);
replay(listener);
controller.addOFSwitchListener(listener);
replay(newsw, oldsw);
controller.switchActivated(newsw);
verify(newsw, oldsw);
assertEquals(newsw, controller.getSwitch(0L));
controller.processUpdateQueueForTesting();
verify(listener);
}