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


Java Link类代码示例

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


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

示例1: addOrUpdateLink

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
public void addOrUpdateLink(DatapathId srcId, OFPort srcPort, DatapathId dstId,
		OFPort dstPort, LinkType type) {
	Link link = new Link(srcId, srcPort, dstId, dstPort);

	if (type.equals(LinkType.MULTIHOP_LINK)) {
		addPortToSwitch(srcId, srcPort);
		addPortToSwitch(dstId, dstPort);
		addLinkToStructure(switchPortLinks, link);

		addLinkToStructure(portBroadcastDomainLinks, link);
		dtLinksUpdated = removeLinkFromStructure(directLinks, link);
		linksUpdated = true;
	} else if (type.equals(LinkType.DIRECT_LINK)) {
		addPortToSwitch(srcId, srcPort);
		addPortToSwitch(dstId, dstPort);
		addLinkToStructure(switchPortLinks, link);

		addLinkToStructure(directLinks, link);
		removeLinkFromStructure(portBroadcastDomainLinks, link);
		dtLinksUpdated = true;
		linksUpdated = true;
	} else if (type.equals(LinkType.TUNNEL)) {
		addOrUpdateTunnelLink(srcId, srcPort, dstId, dstPort);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:TopologyManager.java

示例2: init

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
		throws FloodlightModuleException {
	linkDiscoveryService = context.getServiceImpl(ILinkDiscoveryService.class);
	threadPoolService = context.getServiceImpl(IThreadPoolService.class);
	floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
	switchService = context.getServiceImpl(IOFSwitchService.class);
	restApiService = context.getServiceImpl(IRestApiService.class);
	debugCounterService = context.getServiceImpl(IDebugCounterService.class);
	debugEventService = context.getServiceImpl(IDebugEventService.class);

	switchPorts = new HashMap<DatapathId, Set<OFPort>>();
	switchPortLinks = new HashMap<NodePortTuple, Set<Link>>();
	directLinks = new HashMap<NodePortTuple, Set<Link>>();
	portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>();
	tunnelPorts = new HashSet<NodePortTuple>();
	topologyAware = new ArrayList<ITopologyListener>();
	ldUpdates = new LinkedBlockingQueue<LDUpdate>();
	haListener = new HAListenerDelegate();
	registerTopologyDebugCounters();
	registerTopologyDebugEvents();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:TopologyManager.java

示例3: deleteLinksOnPort

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
/**
 * Delete links incident on a given switch port.
 *
 * @param npt
 * @param reason
 */
protected void deleteLinksOnPort(NodePortTuple npt, String reason) {
	List<Link> eraseList = new ArrayList<Link>();
	if (this.portLinks.containsKey(npt)) {
		if (log.isTraceEnabled()) {
			log.trace("handlePortStatus: Switch {} port #{} "
					+ "removing links {}",
					new Object[] {
							npt.getNodeId().toString(),
							npt.getPortId(),
							this.portLinks.get(npt) });
		}
		eraseList.addAll(this.portLinks.get(npt));
		deleteLinks(eraseList, reason);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:LinkDiscoveryManager.java

示例4: getInfo

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Override
public Map<String, Object> getInfo(String type) {
	if (!"summary".equals(type)) return null;

	Map<String, Object> info = new HashMap<String, Object>();

	int numDirectLinks = 0;
	for (Set<Link> links : switchLinks.values()) {
		for (Link link : links) {
			LinkInfo linkInfo = this.getLinkInfo(link);
			if (linkInfo != null &&
					linkInfo.getLinkType() == LinkType.DIRECT_LINK) {
				numDirectLinks++;
			}
		}
	}
	info.put("# inter-switch links", numDirectLinks / 2);
	info.put("# quarantine ports", quarantineQueue.size());
	return info;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:21,代码来源:LinkDiscoveryManager.java

示例5: readLinkValidTime

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
public Long readLinkValidTime(Link lt) {
	// FIXME: We're not currently using this right now, but if we start
	// to use this again, we probably shouldn't use it in its current
	// form, because it's doing synchronous storage calls. Depending
	// on the context this may still be OK, but if it's being called
	// on the packet in processing thread it should be reworked to
	// use asynchronous storage calls.
	Long validTime = null;
	IResultSet resultSet = null;
	try {
		String[] columns = { LINK_VALID_TIME };
		String id = getLinkId(lt);
		resultSet = storageSourceService.executeQuery(LINK_TABLE_NAME,
				columns,
				new OperatorPredicate(
						LINK_ID,
						OperatorPredicate.Operator.EQ,
						id),
						null);
		if (resultSet.next())
			validTime = resultSet.getLong(LINK_VALID_TIME);
	} finally {
		if (resultSet != null) resultSet.close();
	}
	return validTime;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:LinkDiscoveryManager.java

示例6: removeLinkFromStructure

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
/**
 * Delete the given link from the data strucure.  Returns true if the
 * link was deleted.
 * @param s
 * @param l
 * @return
 */
private boolean removeLinkFromStructure(Map<NodePortTuple,
		Set<Link>> s, Link l) {

	boolean result1 = false, result2 = false;
	NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
	NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());

	if (s.get(n1) != null) {
		result1 = s.get(n1).remove(l);
		if (s.get(n1).isEmpty()) s.remove(n1);
	}
	if (s.get(n2) != null) {
		result2 = s.get(n2).remove(l);
		if (s.get(n2).isEmpty()) s.remove(n2);
	}
	return result1 || result2;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:TopologyManager.java

示例7: removeSwitch

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
public void removeSwitch(DatapathId sid) {
	// Delete all the links in the switch, switch and all
	// associated data should be deleted.
	if (switchPorts.containsKey(sid) == false) return;

	// Check if any tunnel ports need to be removed.
	for(NodePortTuple npt: tunnelPorts) {
		if (npt.getNodeId() == sid) {
			removeTunnelPort(npt.getNodeId(), npt.getPortId());
		}
	}

	Set<Link> linksToRemove = new HashSet<Link>();
	for(OFPort p: switchPorts.get(sid)) {
		NodePortTuple n1 = new NodePortTuple(sid, p);
		linksToRemove.addAll(switchPortLinks.get(n1));
	}

	if (linksToRemove.isEmpty()) return;

	for(Link link: linksToRemove) {
		removeLink(link);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:TopologyManager.java

示例8: calculateShortestPathTreeInClusters

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
protected void calculateShortestPathTreeInClusters() {
    pathcache.invalidateAll();
    destinationRootedTrees.clear();

    Map<Link, Integer> linkCost = new HashMap<Link, Integer>();
    int tunnel_weight = switchPorts.size() + 1;

    for (NodePortTuple npt : tunnelPorts) {
        if (switchPortLinks.get(npt) == null) continue;
        for (Link link : switchPortLinks.get(npt)) {
            if (link == null) continue;
            linkCost.put(link, tunnel_weight);
        }
    }

    for (Cluster c : clusters) {
        for (DatapathId node : c.links.keySet()) {
            BroadcastTree tree = clusterDijkstra(c, node, linkCost, true);
            destinationRootedTrees.put(node, tree);
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:TopologyInstance.java

示例9: calculateBroadcastNodePortsInClusters

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
protected void calculateBroadcastNodePortsInClusters() {
    clusterBroadcastTrees.clear();
    
    calculateBroadcastTreeInClusters();

    for (Cluster c : clusters) {
        // c.id is the smallest node that's in the cluster
        BroadcastTree tree = clusterBroadcastTrees.get(c.id);
        //log.info("Broadcast Tree {}", tree);

        Set<NodePortTuple> nptSet = new HashSet<NodePortTuple>();
        Map<DatapathId, Link> links = tree.getLinks();
        if (links == null) continue;
        for (DatapathId nodeId : links.keySet()) {
            Link l = links.get(nodeId);
            if (l == null) continue;
            NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
            NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort());
            nptSet.add(npt1);
            nptSet.add(npt2);
        }
        clusterBroadcastNodePorts.put(c.id, nptSet);
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:TopologyInstance.java

示例10: getAllLinks

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Override
public Map<DatapathId, Set<Link>> getAllLinks(){

	Map<DatapathId, Set<Link>> dpidLinks = new HashMap<DatapathId, Set<Link>>();
	TopologyInstance ti = getCurrentInstance(true);
	Set<DatapathId> switches = ti.getSwitches();

	for(DatapathId s: switches) {
		if (this.switchPorts.get(s) == null) continue;
		for (OFPort p: switchPorts.get(s)) {
			NodePortTuple np = new NodePortTuple(s, p);
			if (this.switchPortLinks.get(np) == null) continue;
			for(Link l: this.switchPortLinks.get(np)) {
				if(dpidLinks.containsKey(s)) {
					dpidLinks.get(s).add(l);
				}
				else {
					dpidLinks.put(s,new HashSet<Link>(Arrays.asList(l)));
				}

			}
		}
	}

	return dpidLinks;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:27,代码来源:TopologyManager.java

示例11: addLinkToStructure

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
/**
 * Add the given link to the data structure.
 * @param s
 * @param l
 */
private void addLinkToStructure(Map<NodePortTuple, Set<Link>> s, Link l) {
	NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
	NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());

	if (s.get(n1) == null) {
		s.put(n1, new HashSet<Link>());
	} 
	if (s.get(n2) == null) {
		s.put(n2, new HashSet<Link>());
	}
	/* 
	 * Since we don't include latency in .equals(), we need
	 * to explicitly remove the existing link (if present).
	 * Otherwise, new latency values for existing links will
	 * never be accepted.
	 */
	s.get(n1).remove(l);
	s.get(n2).remove(l);
	s.get(n1).add(l);
	s.get(n2).add(l);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:27,代码来源:TopologyManager.java

示例12: testRemovedSwitch

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Test
public void testRemovedSwitch() {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();

    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1));
    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1));
    LinkInfo info = new LinkInfo(new Date(),
    		new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);

    IOFSwitch sw1 = getMockSwitchService().getSwitch(DatapathId.of(1L));
    IOFSwitch sw2 = getMockSwitchService().getSwitch(DatapathId.of(2L));
    // Mock up our expected behavior
    linkDiscovery.switchRemoved(sw1.getId());
    verify(sw1, sw2);

    // check invariants hold
    assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertNull(linkDiscovery.switchLinks.get(lt.getDst()));
    assertNull(linkDiscovery.portLinks.get(srcNpt));
    assertNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.links.isEmpty());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:LinkDiscoveryManagerTest.java

示例13: addOrUpdateLink

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
public void addOrUpdateLink(DatapathId srcId, OFPort srcPort, DatapathId dstId,
		OFPort dstPort, U64 latency, LinkType type) {
	Link link = new Link(srcId, srcPort, dstId, dstPort, latency);

	if (type.equals(LinkType.MULTIHOP_LINK)) {
		addPortToSwitch(srcId, srcPort);
		addPortToSwitch(dstId, dstPort);
		addLinkToStructure(switchPortLinks, link);

		addLinkToStructure(portBroadcastDomainLinks, link);
		dtLinksUpdated = removeLinkFromStructure(directLinks, link);
		linksUpdated = true;
	} else if (type.equals(LinkType.DIRECT_LINK)) {
		addPortToSwitch(srcId, srcPort);
		addPortToSwitch(dstId, dstPort);
		addLinkToStructure(switchPortLinks, link);

		addLinkToStructure(directLinks, link);
		removeLinkFromStructure(portBroadcastDomainLinks, link);
		dtLinksUpdated = true;
		linksUpdated = true;
	} else if (type.equals(LinkType.TUNNEL)) {
		addOrUpdateTunnelLink(srcId, srcPort, dstId, dstPort, latency);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:TopologyManager.java

示例14: testAddOrUpdateLinkToSelf

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Test
public void testAddOrUpdateLinkToSelf() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();

    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(3));
    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3));

    LinkInfo info = new LinkInfo(new Date(),
    		new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);

    // check invariants hold
    assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(srcNpt));
    assertTrue(linkDiscovery.portLinks.get(srcNpt).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
    assertTrue(linkDiscovery.links.containsKey(lt));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:LinkDiscoveryManagerTest.java

示例15: testAddOrUpdateLink

import net.floodlightcontroller.routing.Link; //导入依赖的package包/类
@Test
public void testAddOrUpdateLink() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    U64 latency = U64.of(100);
    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), latency);
    LinkInfo info = new LinkInfo(new Date(),
                                 new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);

    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1));

    // check invariants hold
    assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
    assertNotNull(linkDiscovery.getPortLinks().get(srcNpt));
    assertTrue(linkDiscovery.getPortLinks().get(srcNpt).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
    assertTrue(linkDiscovery.links.containsKey(lt));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).iterator().next().getLatency().equals(latency));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:LinkDiscoveryManagerTest.java


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