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


Java OFPortDesc.Builder方法代码示例

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


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

示例1: toOFPortDesc

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
public OFPortDesc toOFPortDesc(OFFactory factory) {
	OFPortDesc.Builder builder = factory.buildPortDesc();
    builder.setPortNo(port.getPortNo());
    builder.setHwAddr(port.getHwAddr());
    builder.setName(port.getName());
    builder.setConfig(port.getConfig());
    builder.setState(port.getState());
    builder.setCurr(port.getCurr());
    builder.setAdvertised(port.getAdvertised());
    builder.setSupported(port.getSupported());
    builder.setPeer(port.getPeer());
    return builder.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:14,代码来源:SwitchSyncRepresentation.java

示例2: portDesc

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
private static OFPortDesc portDesc(int port) {
    OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc();
    builder.setPortNo(OFPort.of(port));

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:OpenFlowDeviceProviderTest.java

示例3: portDesc

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
private OFPortDesc portDesc(PortNumber port) {
    OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc();
    builder.setPortNo(OFPort.of((int) port.toLong()));

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:OpenFlowPacketProvider.java

示例4: setUpPorts

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
public void setUpPorts() {
    OFPortDesc.Builder pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    // p1a is disabled
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortState> portState = new HashSet<OFPortState>();
    portState.add(OFPortState.LINK_DOWN);
    pdb.setState(portState);
    p1a = pdb.build();
    assertFalse("Sanity check portEnabled", !p1a.getState().contains(OFPortState.LINK_DOWN));

    // p1b is enabled
    // p1b has different feature from p1a
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortFeatures> portFeatures = new HashSet<OFPortFeatures>();
    portFeatures.add(OFPortFeatures.PF_1GB_FD);
    pdb.setCurr(portFeatures);
    p1b = pdb.build();
    assertTrue("Sanity check portEnabled", !p1b.getState().contains(OFPortState.LIVE));

    // p2 is disabled
    // p2 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    Set<OFPortConfig> portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    p2a = pdb.build();
    // p2b only differs in PortFeatures
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    portFeatures.add(OFPortFeatures.PF_100MB_HD);
    pdb.setCurr(portFeatures);
    p2b = pdb.build();
    assertFalse("Sanity check portEnabled", p2a.getState().contains(OFPortState.LIVE));
    // p3 is enabled
    // p3 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("porT3");
    pdb.setPortNo(OFPort.of(3));
    p3 = pdb.build();
    assertTrue("Sanity check portEnabled", !p3.getState().contains(OFPortState.LINK_DOWN));

}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:56,代码来源:OFSwitchBaseTest.java

示例5: testPortStatusMessageMaster

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
/**
 * Test port status message handling while MASTER
 *
 */
@Test
public void testPortStatusMessageMaster() throws Exception {
	DatapathId dpid = featuresReply.getDatapathId();
	testInitialMoveToMasterWithRole();

	OFPortDesc portDesc = factory.buildPortDesc()
			.setName("Port1")
			.setPortNo(OFPort.of(1))
			.build();
	OFPortStatus.Builder portStatusBuilder = factory.buildPortStatus()
			.setDesc(portDesc);

	// The events we expect sw.handlePortStatus to return
	// We'll just use the same list for all valid OFPortReasons and add
	// arbitrary events for arbitrary ports that are not necessarily
	// related to the port status message. Our goal
	// here is not to return the correct set of events but the make sure
	// that a) sw.handlePortStatus is called
	//      b) the list of events sw.handlePortStatus returns is sent
	//         as IOFSwitchListener notifications.
	OrderedCollection<PortChangeEvent> events =
			new LinkedHashSetWrapper<PortChangeEvent>();
	OFPortDesc.Builder pb = factory.buildPortDesc();
	OFPortDesc p1 = pb.setName("eth1").setPortNo(OFPort.of(1)).build();
	OFPortDesc p2 = pb.setName("eth2").setPortNo(OFPort.of(2)).build();
	OFPortDesc p3 = pb.setName("eth3").setPortNo(OFPort.of(3)).build();
	OFPortDesc p4 = pb.setName("eth4").setPortNo(OFPort.of(4)).build();
	OFPortDesc p5 = pb.setName("eth5").setPortNo(OFPort.of(5)).build();


	events.add(new PortChangeEvent(p1, PortChangeType.ADD));
	events.add(new PortChangeEvent(p2, PortChangeType.DELETE));
	events.add(new PortChangeEvent(p3, PortChangeType.UP));
	events.add(new PortChangeEvent(p4, PortChangeType.DOWN));
	events.add(new PortChangeEvent(p5, PortChangeType.OTHER_UPDATE));


	for (OFPortReason reason: OFPortReason.values()) {
		OFPortStatus portStatus = portStatusBuilder.setReason(reason).build();

		reset(sw);
		expect(sw.getId()).andReturn(dpid).anyTimes();

		expect(sw.processOFPortStatus(portStatus)).andReturn(events).once();
		replay(sw);

		reset(switchManager);
		switchManager.notifyPortChanged(sw, p1, PortChangeType.ADD);
		switchManager.notifyPortChanged(sw, p2, PortChangeType.DELETE);
		switchManager.notifyPortChanged(sw, p3, PortChangeType.UP);
		switchManager.notifyPortChanged(sw, p4, PortChangeType.DOWN);
		switchManager.notifyPortChanged(sw, p5, PortChangeType.OTHER_UPDATE);
		replay(switchManager);

		switchHandler.processOFMessage(portStatus);

		verify(sw);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:64,代码来源:OFSwitchHandlerTestBase.java

示例6: setUpPorts

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
@Before
public void setUpPorts() {
    OFPortDesc.Builder pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    // p1a is disabled
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortState> portState = new HashSet<OFPortState>();
    portState.add(OFPortState.LINK_DOWN);
    pdb.setState(portState);
    p1a = pdb.build();
    assertFalse("Sanity check portEnabled", !p1a.getState().contains(OFPortState.LINK_DOWN));

    // p1b is enabled
    // p1b has different feature from p1a
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortFeatures> portFeatures = new HashSet<OFPortFeatures>();
    portFeatures.add(OFPortFeatures.PF_1GB_FD);
    pdb.setCurr(portFeatures);
    p1b = pdb.build();
    assertTrue("Sanity check portEnabled", !p1b.getState().contains(OFPortState.LIVE));

    // p2 is disabled
    // p2 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    Set<OFPortConfig> portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    p2a = pdb.build();
    // p2b only differs in PortFeatures
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    portFeatures.add(OFPortFeatures.PF_100MB_HD);
    pdb.setCurr(portFeatures);
    p2b = pdb.build();
    assertFalse("Sanity check portEnabled", p2a.getState().contains(OFPortState.LIVE));
    // p3 is enabled
    // p3 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("porT3");
    pdb.setPortNo(OFPort.of(3));
    p3 = pdb.build();
    assertTrue("Sanity check portEnabled", !p3.getState().contains(OFPortState.LINK_DOWN));

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

示例7: testPortStatusMessageMaster

import org.projectfloodlight.openflow.protocol.OFPortDesc; //导入方法依赖的package包/类
/**
 * Test port status message handling while MASTER
 *
 */
@Test
public void testPortStatusMessageMaster() throws Exception {
    DatapathId dpid = featuresReply.getDatapathId();
    testInitialMoveToMasterWithRole();

    OFPortDesc portDesc = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .build();
    OFPortStatus.Builder portStatusBuilder = factory.buildPortStatus()
            .setDesc(portDesc);

    // The events we expect sw.handlePortStatus to return
    // We'll just use the same list for all valid OFPortReasons and add
    // arbitrary events for arbitrary ports that are not necessarily
    // related to the port status message. Our goal
    // here is not to return the correct set of events but the make sure
    // that a) sw.handlePortStatus is called
    //      b) the list of events sw.handlePortStatus returns is sent
    //         as IOFSwitchListener notifications.
    OrderedCollection<PortChangeEvent> events =
            new LinkedHashSetWrapper<PortChangeEvent>();
    OFPortDesc.Builder pb = factory.buildPortDesc();
    OFPortDesc p1 = pb.setName("eth1").setPortNo(OFPort.of(1)).build();
    OFPortDesc p2 = pb.setName("eth2").setPortNo(OFPort.of(2)).build();
    OFPortDesc p3 = pb.setName("eth3").setPortNo(OFPort.of(3)).build();
    OFPortDesc p4 = pb.setName("eth4").setPortNo(OFPort.of(4)).build();
    OFPortDesc p5 = pb.setName("eth5").setPortNo(OFPort.of(5)).build();

    
    events.add(new PortChangeEvent(p1, PortChangeType.ADD));
    events.add(new PortChangeEvent(p2, PortChangeType.DELETE));
    events.add(new PortChangeEvent(p3, PortChangeType.UP));
    events.add(new PortChangeEvent(p4, PortChangeType.DOWN));
    events.add(new PortChangeEvent(p5, PortChangeType.OTHER_UPDATE));


    for (OFPortReason reason: OFPortReason.values()) {
        OFPortStatus portStatus = portStatusBuilder.setReason(reason).build();

        reset(sw);
        expect(sw.getId()).andReturn(dpid).anyTimes();

        expect(sw.processOFPortStatus(portStatus)).andReturn(events).once();
        replay(sw);

        reset(switchManager);
        switchManager.notifyPortChanged(sw, p1, PortChangeType.ADD);
        switchManager.notifyPortChanged(sw, p2, PortChangeType.DELETE);
        switchManager.notifyPortChanged(sw, p3, PortChangeType.UP);
        switchManager.notifyPortChanged(sw, p4, PortChangeType.DOWN);
        switchManager.notifyPortChanged(sw, p5, PortChangeType.OTHER_UPDATE);
        replay(switchManager);

        switchHandler.processOFMessage(portStatus);

        verify(sw);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:64,代码来源:OFSwitchHandlerTestBase.java


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