本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitchBackend.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java IOFSwitchBackend.disconnect方法的具体用法?Java IOFSwitchBackend.disconnect怎么用?Java IOFSwitchBackend.disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.core.IOFSwitchBackend
的用法示例。
在下文中一共展示了IOFSwitchBackend.disconnect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNewSwitchActivatedWhileSlave
import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的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);
}
示例2: testNewSwitchActivatedWhileSlave
import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的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);
}
示例3: 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);
}
}
}
示例4: 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();
}
}
示例5: switchStatusChanged
import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的package包/类
@Override
public synchronized void switchStatusChanged(IOFSwitchBackend sw, SwitchStatus oldStatus, SwitchStatus newStatus) {
DatapathId dpid = sw.getId();
IOFSwitchBackend presentSw = this.switches.get(dpid);
if (presentSw != sw) {
// Note == for object equality, not .equals for value
counters.errorActivatedSwitchNotPresent
.increment();
log.debug("Switch {} status change but not present in sync manager", sw);
return;
}
evSwitch.newEventWithFlush(new SwitchEvent(dpid,
String.format("%s -> %s",
oldStatus,
newStatus)));
if(newStatus == SwitchStatus.MASTER && role != OFControllerRole.ROLE_MASTER) {
counters.invalidSwitchActivatedWhileSlave.increment();
log.error("Switch {} activated but controller not MASTER", sw);
sw.disconnect();
return; // only react to switch connections when master
}
if(!oldStatus.isVisible() && newStatus.isVisible()) {
// the switch has just become visible. Send 'add' notification to our
// listeners
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
} else if((oldStatus.isVisible() && !newStatus.isVisible())) {
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
}
// note: no else if - both may be true
if(oldStatus != SwitchStatus.MASTER && newStatus == SwitchStatus.MASTER ) {
counters.switchActivated.increment();
addUpdateToQueue(new SwitchUpdate(dpid,
SwitchUpdateType.ACTIVATED));
} else if(oldStatus == SwitchStatus.MASTER && newStatus != SwitchStatus.MASTER ) {
counters.switchDeactivated.increment();
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.DEACTIVATED));
}
}
示例6: 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);
}
示例7: switchStatusChanged
import net.floodlightcontroller.core.IOFSwitchBackend; //导入方法依赖的package包/类
@LogMessageDocs({
@LogMessageDoc(level="ERROR",
message="Switch {switch} activated but was already active",
explanation="A switch that was already activated was " +
"activated again. This should not happen.",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG
),
@LogMessageDoc(level="WARN",
message="New switch added {switch} for already-added switch {switch}",
explanation="A switch with the same DPID as another switch " +
"connected to the controller. This can be caused by " +
"multiple switches configured with the same DPID, or " +
"by a switch reconnected very quickly after " +
"disconnecting.",
recommendation="If this happens repeatedly, it is likely there " +
"are switches with duplicate DPIDs on the network. " +
"Reconfigure the appropriate switches. If it happens " +
"very rarely, then it is likely this is a transient " +
"network problem that can be ignored."
)
})
@Override
public synchronized void switchStatusChanged(IOFSwitchBackend sw, SwitchStatus oldStatus, SwitchStatus newStatus) {
DatapathId dpid = sw.getId();
IOFSwitchBackend presentSw = this.switches.get(dpid);
if (presentSw != sw) {
// Note == for object equality, not .equals for value
counters.errorActivatedSwitchNotPresent
.increment();
log.debug("Switch {} status change but not present in sync manager", sw);
return;
}
evSwitch.newEventWithFlush(new SwitchEvent(dpid,
String.format("%s -> %s",
oldStatus,
newStatus)));
if(newStatus == SwitchStatus.MASTER && role != OFControllerRole.ROLE_MASTER) {
counters.invalidSwitchActivatedWhileSlave.increment();
log.error("Switch {} activated but controller not MASTER", sw);
sw.disconnect();
return; // only react to switch connections when master
}
if(!oldStatus.isVisible() && newStatus.isVisible()) {
// the switch has just become visible. Send 'add' notification to our
// listeners
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
} else if((oldStatus.isVisible() && !newStatus.isVisible())) {
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
}
// note: no else if - both may be true
if(oldStatus != SwitchStatus.MASTER && newStatus == SwitchStatus.MASTER ) {
counters.switchActivated.increment();
addUpdateToQueue(new SwitchUpdate(dpid,
SwitchUpdateType.ACTIVATED));
} else if(oldStatus == SwitchStatus.MASTER && newStatus != SwitchStatus.MASTER ) {
counters.switchDeactivated.increment();
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.DEACTIVATED));
}
}