本文整理汇总了Java中net.floodlightcontroller.core.SwitchDescription类的典型用法代码示例。如果您正苦于以下问题:Java SwitchDescription类的具体用法?Java SwitchDescription怎么用?Java SwitchDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SwitchDescription类属于net.floodlightcontroller.core包,在下文中一共展示了SwitchDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
logger = LoggerFactory.getLogger(PathVerificationFlowTest.class);
cntx = new FloodlightContext();
FloodlightModuleContext fmc = new FloodlightModuleContext();
fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
swDescription = factory.buildDescStatsReply().build();
swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();
sw = EasyMock.createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(swDpid).anyTimes();
expect(sw.getOFFactory()).andReturn(factory).anyTimes();
expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
expect(sw.isActive()).andReturn(true).anyTimes();
expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
replay(sw);
pvs = new PathVerificationService();
}
示例2: doActivateSwitchInt
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
/**
* Create and activate a switch, either completely new or reconnected
* The mocked switch instance will be returned. It will be reset.
*/
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
SwitchDescription description,
OFFeaturesReply featuresReply,
boolean clearFlows)
throws Exception {
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
if (featuresReply == null) {
featuresReply = createOFFeaturesReply(datapathId);
}
if (description == null) {
description = createSwitchDescription();
}
setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
replay(sw);
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
assertEquals(sw, switchManager.getSwitch(datapathId));
// drain updates and ignore
controller.processUpdateQueueForTesting();
reset(sw);
return sw;
}
示例3: setUp
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
@Before
public void setUp() throws FloodlightModuleException {
ofSwitchService = createMock(IOFSwitchService.class);
restApiService = createMock(IRestApiService.class);
iofSwitch = createMock(IOFSwitch.class);
switchDescription = createMock(SwitchDescription.class);
dpid = createMock(DatapathId.class);
context.addService(IRestApiService.class, restApiService);
context.addService(IOFSwitchService.class, ofSwitchService);
switchManager = new SwitchManager();
switchManager.init(context);
}
示例4: buildMockIOFSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
public IOFSwitch buildMockIOFSwitch(Long id, OFPortDesc portDesc, OFFactory factory,
OFDescStatsReply swDesc, InetSocketAddress inetAddr) {
IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(DatapathId.of(id)).anyTimes();
expect(sw.getPort(OFPort.of(1))).andReturn(portDesc).anyTimes();
expect(sw.getOFFactory()).andReturn(factory).anyTimes();
expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDesc)).anyTimes();
expect(sw.isActive()).andReturn(true).anyTimes();
expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
expect(sw.getInetAddress()).andReturn(inetAddr).anyTimes();
return sw;
}
示例5: getOFSwitchInstance
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
@Override
public IOFSwitchBackend
getOFSwitchInstance(IOFConnectionBackend connection,
SwitchDescription description,
OFFactory factory, DatapathId datapathId) {
return null;
}
示例6: serializeDescription
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
public void serializeDescription(SwitchDescription swDescription, JsonGenerator jGen)
throws IOException, JsonProcessingException {
if( null == swDescription)
jGen.writeStringField("description","null");
else{
jGen.writeFieldName("description");
jGen.writeStartObject();
jGen.writeStringField("datapath",swDescription.getDatapathDescription());
jGen.writeStringField("hardware",swDescription.getHardwareDescription());
jGen.writeStringField("manufacturer",swDescription.getManufacturerDescription());
jGen.writeStringField("serialNum",swDescription.getSerialNumber());
jGen.writeStringField("software",swDescription.getSoftwareDescription());
jGen.writeEndObject();
}
}
示例7: SwitchSyncRepresentation
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
public SwitchSyncRepresentation(IOFSwitch sw) {
this.dpid = sw.getId();
this.buffers = sw.getBuffers();
this.tables = (short) sw.getNumTables();
this.capabilities = sw.getCapabilities();
this.actions = sw.getActions();
this.ports = toSyncedPortList(sw.getPorts());
SwitchDescription d = sw.getSwitchDescription();
this.manufacturerDescription = d.getManufacturerDescription();
this.hardwareDescription = d.getHardwareDescription();
this.softwareDescription = d.getSoftwareDescription();
this.serialNumber = d.getSerialNumber();
this.datapathDescription = d.getDatapathDescription();
}
示例8: OFSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
public OFSwitch(IOFConnectionBackend connection, @Nonnull OFFactory factory, @Nonnull IOFSwitchManager switchManager,
@Nonnull DatapathId datapathId) {
if(connection == null)
throw new NullPointerException("connection must not be null");
if(!connection.getAuxId().equals(OFAuxId.MAIN))
throw new IllegalArgumentException("connection must be the main connection");
if(factory == null)
throw new NullPointerException("factory must not be null");
if(switchManager == null)
throw new NullPointerException("switchManager must not be null");
this.connected = true;
this.factory = factory;
this.switchManager = switchManager;
this.datapathId = datapathId;
this.attributes = new ConcurrentHashMap<Object, Object>();
this.role = null;
this.description = new SwitchDescription();
this.portManager = new PortManager();
this.status = SwitchStatus.HANDSHAKE;
// Connections
this.connections = new ConcurrentHashMap<OFAuxId, IOFConnectionBackend>();
this.connections.put(connection.getAuxId(), connection);
// Switch's controller connection
this.controllerConnections = ImmutableMap.of();
// Defaults properties for an ideal switch
this.setAttribute(PROP_FASTWILDCARDS, EnumSet.allOf(OFFlowWildcards.class));
this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, Boolean.TRUE);
this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, Boolean.TRUE);
this.tableFeaturesByTableId = new HashMap<TableId, TableFeatures>();
this.tables = new ArrayList<TableId>();
this.securityKernel = switchManager.getSecurityKernelService();
}
示例9: processOFStatsReply
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
@Override
void processOFStatsReply(OFStatsReply m) {
// Read description, if it has been updated
if (m.getStatsType() != OFStatsType.DESC) {
illegalMessageReceived(m);
return;
}
OFDescStatsReply descStatsReply = (OFDescStatsReply) m;
SwitchDescription description = new SwitchDescription(descStatsReply);
sw = switchManager.getOFSwitchInstance(mainConnection, description, factory, featuresReply.getDatapathId());
// set switch information
// set features reply and channel first so we a DPID and
// channel info.
sw.setFeaturesReply(featuresReply);
if (portDescStats != null) {
sw.setPortDescStats(portDescStats);
}
/*
* Need to add after setting the features.
*/
switchManager.switchAdded(sw);
// Handle pending messages now that we have a sw object
handlePendingPortStatusMessages(description);
setState(new WaitTableFeaturesReplyState());
}
示例10: handlePendingPortStatusMessages
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
void handlePendingPortStatusMessages(SwitchDescription description){
for (OFPortStatus ps: pendingPortStatusMsg) {
handlePortStatusMessage(ps, false);
}
pendingPortStatusMsg.clear();
log.info("Switch {} bound to class {}, description {}", new Object[] { sw, sw.getClass(), description });
}
示例11: getOFSwitchInstance
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
@Override
public IOFSwitchBackend getOFSwitchInstance(IOFConnectionBackend connection,
SwitchDescription description,
OFFactory factory, DatapathId datapathId) {
return this.driverRegistry.getOFSwitchInstance(connection, description, factory, datapathId);
}
示例12: setupSwitchForAddSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
/** Set the mock expectations for sw when sw is passed to addSwitch
* The same expectations can be used when a new SwitchSyncRepresentation
* is created from the given mocked switch */
protected void setupSwitchForAddSwitch(IOFSwitch sw, DatapathId datapathId,
SwitchDescription description, OFFeaturesReply featuresReply) {
if (description == null) {
description = createSwitchDescription();
}
if (featuresReply == null) {
featuresReply = createOFFeaturesReply(datapathId);
}
List<OFPortDesc> ports = featuresReply.getPorts();
expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_10)).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
expect(sw.getId()).andReturn(datapathId).anyTimes();
expect(sw.getSwitchDescription()).andReturn(description).anyTimes();
expect(sw.getBuffers())
.andReturn(featuresReply.getNBuffers()).anyTimes();
expect(sw.getNumTables())
.andReturn(featuresReply.getNTables()).anyTimes();
expect(sw.getCapabilities())
.andReturn(featuresReply.getCapabilities()).anyTimes();
expect(sw.getActions())
.andReturn(featuresReply.getActions()).anyTimes();
expect(sw.getPorts())
.andReturn(ports).anyTimes();
expect(sw.attributeEquals(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true))
.andReturn(false).anyTimes();
expect(sw.getInetAddress()).andReturn(null).anyTimes();
}
示例13: doActivateNewSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
/**
* Create and activate a new switch with the given dpid, features reply
* and description. If description and/or features reply are null we'll
* allocate the default one
* The mocked switch instance will be returned. It wil be reset.
*/
private IOFSwitchBackend doActivateNewSwitch(DatapathId dpid,
SwitchDescription description,
OFFeaturesReply featuresReply)
throws Exception {
return doActivateSwitchInt(dpid, description, featuresReply, true);
}
示例14: handleDescStatsAndCreateSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
public void handleDescStatsAndCreateSwitch() throws Exception {
// build the stats reply
OFDescStatsReply sr = createDescriptionStatsReply();
reset(sw);
SwitchDescription switchDescription = new SwitchDescription(sr);
setupSwitchForInstantiationWithReset();
sw.setPortDescStats(anyObject(OFPortDescStatsReply.class));
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw);
reset(switchManager);
expect(switchManager.getHandshakePlugins()).andReturn(plugins).anyTimes();
expect(
switchManager.getOFSwitchInstance(anyObject(OFConnection.class),
eq(switchDescription),
anyObject(OFFactory.class),
anyObject(DatapathId.class))).andReturn(sw).once();
expect(switchManager.getNumRequiredConnections()).andReturn(1).anyTimes();
switchManager.switchAdded(sw);
expectLastCall().once();
replay(switchManager);
// send the description stats reply
switchHandler.processOFMessage(sr);
OFMessage msg = connection.retrieveMessage();
assertThat(msg, CoreMatchers.instanceOf(OFTableFeaturesStatsRequest.class));
verifyUniqueXids(msg);
verify(sw, switchManager);
}
示例15: setupSwitchForAddSwitch
import net.floodlightcontroller.core.SwitchDescription; //导入依赖的package包/类
/** Set the mock expectations for sw when sw is passed to addSwitch
* The same expectations can be used when a new SwitchSyncRepresentation
* is created from the given mocked switch */
protected void setupSwitchForAddSwitch(IOFSwitch sw, DatapathId datapathId,
SwitchDescription description,
OFFeaturesReply featuresReply) {
String dpidString = datapathId.toString();
if (description == null) {
description = createSwitchDescription();
}
if (featuresReply == null) {
featuresReply = createOFFeaturesReply(datapathId);
}
List<OFPortDesc> ports = featuresReply.getPorts();
expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_10)).anyTimes();
expect(sw.getId()).andReturn(datapathId).anyTimes();
expect(sw.getId().toString()).andReturn(dpidString).anyTimes();
expect(sw.getSwitchDescription()).andReturn(description).atLeastOnce();
expect(sw.getBuffers())
.andReturn(featuresReply.getNBuffers()).atLeastOnce();
expect(sw.getNumTables())
.andReturn(featuresReply.getNTables()).atLeastOnce();
expect(sw.getCapabilities())
.andReturn(featuresReply.getCapabilities()).atLeastOnce();
expect(sw.getActions())
.andReturn(featuresReply.getActions()).atLeastOnce();
expect(sw.getPorts())
.andReturn(ports).atLeastOnce();
expect(sw.attributeEquals(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true))
.andReturn(false).anyTimes();
expect(sw.getInetAddress()).andReturn(null).anyTimes();
}