• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SwitchSyncRepresentation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.floodlightcontroller.core.SwitchSyncRepresentation的典型用法代码示例。如果您正苦于以下问题:Java SwitchSyncRepresentation类的具体用法?Java SwitchSyncRepresentation怎么用?Java SwitchSyncRepresentation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: doAddSwitchToStore

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
/**
 * Create a switch sync representation and add it to the store and
 * notify the store listener.
 * If the description and/or features reply are null, we'll allocate
 * the default one
 */
public void doAddSwitchToStore(long dpid,
                               OFDescriptionStatistics desc,
                               OFFeaturesReply featuresReply)
                               throws Exception {
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply();
        featuresReply.setDatapathId(dpid);
    }
    if (desc == null) {
        desc = createOFDescriptionStatistics();
    }

    SwitchSyncRepresentation ssr =
            new SwitchSyncRepresentation(featuresReply, desc);
    storeClient.put(dpid, ssr);

    Iterator<Long> keysToNotify = Collections.singletonList(dpid).iterator();
    controller.getStoreListener().keysModified(keysToNotify,
                                               UpdateType.REMOTE);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:ControllerTest.java


示例2: keysModified

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
@Override
public void keysModified(Iterator<DatapathId> keys, UpdateType type) {
	if (type == UpdateType.LOCAL) {
		// We only care for remote updates
		return;
	}
	while(keys.hasNext()) {
		DatapathId key = keys.next();
		Versioned<SwitchSyncRepresentation> versionedSwitch = null;
		try {
			versionedSwitch = storeClient.get(key);
		} catch (SyncException e) {
			log.error("Exception while retrieving switch " + key.toString() +
					" from sync store. Skipping", e);
			continue;
		}
		if (log.isTraceEnabled()) {
			log.trace("Reveiced switch store notification: key={}, " +
					"entry={}", key, versionedSwitch.getValue());
		}
		// versionedSwtich won't be null. storeClient.get() always
		// returns a non-null or throws an exception
		if (versionedSwitch.getValue() == null) {
			switchRemovedFromStore(key);
			continue;
		}
		SwitchSyncRepresentation storedSwitch = versionedSwitch.getValue();
		IOFSwitch sw = getSwitch(storedSwitch.getDpid());
		//TODO @Ryan need to get IOFSwitchBackend setFeaturesReply(storedSwitch.getFeaturesReply(sw.getOFFactory()));
		if (!key.equals(storedSwitch.getFeaturesReply(sw.getOFFactory()).getDatapathId())) {
			log.error("Inconsistent DPIDs from switch sync store: " +
					"key is {} but sw.getId() says {}. Ignoring",
					key.toString(), sw.getId());
			continue;
		}
		switchAddedToStore(sw);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:OFSwitchManager.java


示例3: testNewSwitchActivated

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
@Test
/**
 * Test switchActivated for a new switch, i.e., a switch that was not
 * previously known to the controller cluser. We expect that all
 * flow mods are cleared and we expect a switchAdded
 */
public void testNewSwitchActivated() throws Exception {
    // We set AlwaysClearFlowsOnSwActivate to false but we still
    // expect a clearAllFlowMods() because the AlwaysClearFlowsOnSwActivate
    // is only relevant if a switch that was previously known is activated!!
    controller.setAlwaysClearFlowsOnSwActivate(false);

    IOFSwitch sw = createMock(IOFSwitch.class);
    setupSwitchForAddSwitch(sw, 0L, null, null);
    sw.clearAllFlowMods();
    expectLastCall().once();

    // strict mock. Order of events matters!
    IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
    listener.switchAdded(0L);
    expectLastCall().once();
    listener.switchActivated(0L);
    expectLastCall().once();
    replay(listener);
    controller.addOFSwitchListener(listener);

    replay(sw);
    controller.switchActivated(sw);
    verify(sw);
    assertEquals(sw, controller.getSwitch(0L));
    controller.processUpdateQueueForTesting();
    verify(listener);

    SwitchSyncRepresentation storedSwitch = storeClient.getValue(0L);
    assertEquals(createOFFeaturesReply(), storedSwitch.getFeaturesReply());
    assertEquals(createOFDescriptionStatistics(),
                 storedSwitch.getDescription());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:39,代码来源:ControllerTest.java


示例4: doActivateSwitchInt

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It wil be reset.
 */
private IOFSwitch doActivateSwitchInt(long dpid,
                                      OFDescriptionStatistics desc,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {
    controller.setAlwaysClearFlowsOnSwActivate(true);

    IOFSwitch sw = createMock(IOFSwitch.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply();
        featuresReply.setDatapathId(dpid);
    }
    if (desc == null) {
        desc = createOFDescriptionStatistics();
    }
    setupSwitchForAddSwitch(sw, dpid, desc, featuresReply);
    if (clearFlows) {
        sw.clearAllFlowMods();
        expectLastCall().once();
    }

    replay(sw);
    controller.switchActivated(sw);
    verify(sw);
    assertEquals(sw, controller.getSwitch(dpid));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    SwitchSyncRepresentation storedSwitch = storeClient.getValue(dpid);
    assertEquals(featuresReply, storedSwitch.getFeaturesReply());
    assertEquals(desc, storedSwitch.getDescription());
    reset(sw);
    return sw;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:39,代码来源:ControllerTest.java


示例5: testInconsistentStoreDpid

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
/** Add switch to store with inconsistent DPID
 * @throws Exception
 */
@Test
public void testInconsistentStoreDpid() throws Exception {
    doSetUp(Role.SLAVE);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    controller.addOFSwitchListener(listener);
    replay(listener);


    OFFeaturesReply featuresReply = createOFFeaturesReply();
    featuresReply.setDatapathId(42L);
    OFDescriptionStatistics desc = createOFDescriptionStatistics();
    SwitchSyncRepresentation ssr =
            new SwitchSyncRepresentation(featuresReply, desc);
    storeClient.put(1L, ssr);

    Iterator<Long> keysToNotify = Collections.singletonList(1L).iterator();
    controller.getStoreListener().keysModified(keysToNotify,
                                               UpdateType.REMOTE);
    controller.processUpdateQueueForTesting();
    verify(listener);

    assertNull("Switch should not have been added",
               controller.getSwitch(1L));
    assertNull("Switch should not have been added",
               controller.getSwitch(42L));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:31,代码来源:ControllerTest.java


示例6: keysModified

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
@Override
public void keysModified(Iterator<Long> keys, UpdateType type) {
    if (type == UpdateType.LOCAL) {
        // We only care for remote updates
        return;
    }
    counters.remoteStoreNotification.updateCounterWithFlush();
    while(keys.hasNext()) {
        Long key = keys.next();
        Versioned<SwitchSyncRepresentation> versionedSwitch = null;
        try {
            versionedSwitch = storeClient.get(key);
        } catch (SyncException e) {
            counters.storeSyncError.updateCounterWithFlush();
            log.error("Exception while retrieving switch " +
                      HexString.toHexString(key) +
                      " from sync store. Skipping", e);
            continue;
        }
        if (log.isTraceEnabled()) {
            log.trace("Reveiced switch store notification: key={}, " +
                       "entry={}", key, versionedSwitch.getValue());
        }
        // versionedSwtich won't be null. storeClient.get() always
        // returns a non-null or throws an exception
        if (versionedSwitch.getValue() == null) {
            switchRemovedFromStore(key);
            continue;
        }
        SwitchSyncRepresentation storedSwitch =
                versionedSwitch.getValue();
        IOFSwitch sw = getOFSwitchInstance(storedSwitch.getDescription());
        sw.setFeaturesReply(storedSwitch.getFeaturesReply());
        if (!key.equals(storedSwitch.getFeaturesReply().getDatapathId())) {
            counters.storeSyncError.updateCounterWithFlush();
            log.error("Inconsistent DPIDs from switch sync store: " +
                      "key is {} but sw.getId() says {}. Ignoring",
                      HexString.toHexString(key), sw.getStringId());
            continue;
        }
        switchAddedToStore(sw);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:44,代码来源:Controller.java


示例7: testNotifySwitchPoArtChanged

import net.floodlightcontroller.core.SwitchSyncRepresentation; //导入依赖的package包/类
/**
 * Test that notifyPortChanged() results in an IOFSwitchListener
 * update and that its arguments are passed through to
 * the listener call
 */
@Test
public void testNotifySwitchPoArtChanged() throws Exception {
    long dpid = 42L;

    OFFeaturesReply fr1 = createOFFeaturesReply();
    fr1.setDatapathId(dpid);
    OFPhysicalPort p1 = createOFPhysicalPort("Port1", 1);
    fr1.setPorts(Collections.singletonList(p1));

    OFFeaturesReply fr2 = createOFFeaturesReply();
    fr1.setDatapathId(dpid);
    OFPhysicalPort p2 = createOFPhysicalPort("Port1", 1);
    p2.setAdvertisedFeatures(0x2); // just some bogus values
    fr2.setPorts(Collections.singletonList(p2));

    OFDescriptionStatistics desc = createOFDescriptionStatistics();

    // activate switch
    IOFSwitch sw = doActivateNewSwitch(dpid, desc, fr1);

    // check the store
    SwitchSyncRepresentation ssr = storeClient.getValue(dpid);
    assertNotNull(ssr);
    assertEquals(dpid, ssr.getDpid());
    assertEquals(1, ssr.getPorts().size());
    assertEquals(p1, ssr.getPorts().get(0).toOFPhysicalPort());

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    controller.addOFSwitchListener(listener);
    // setup switch with the new, second features reply (and thus ports)
    setupSwitchForAddSwitch(sw, dpid, desc, fr2);
    listener.switchPortChanged(dpid, ImmutablePort.fromOFPhysicalPort(p2),
                               PortChangeType.OTHER_UPDATE);
    expectLastCall().once();
    replay(listener);
    replay(sw);
    controller.notifyPortChanged(sw, ImmutablePort.fromOFPhysicalPort(p2),
                                 PortChangeType.OTHER_UPDATE);
    controller.processUpdateQueueForTesting();
    verify(listener);
    verify(sw);

    // check the store
    ssr = storeClient.getValue(dpid);
    assertNotNull(ssr);
    assertEquals(dpid, ssr.getDpid());
    assertEquals(1, ssr.getPorts().size());
    assertEquals(p2, ssr.getPorts().get(0).toOFPhysicalPort());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:55,代码来源:ControllerTest.java



注:本文中的net.floodlightcontroller.core.SwitchSyncRepresentation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RMIConnection类代码示例发布时间:2022-05-21
下一篇:
Java ActivationID类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap