本文整理汇总了Java中org.onosproject.net.Link类的典型用法代码示例。如果您正苦于以下问题:Java Link类的具体用法?Java Link怎么用?Java Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Link类属于org.onosproject.net包,在下文中一共展示了Link类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPaths
import org.onosproject.net.Link; //导入依赖的package包/类
@Override
public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
final Set<Path> paths = getPaths(src, dst);
for (Path path : paths) {
final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
if (srcDevice != null && dstDevice != null) {
final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
final Link link = link(src.toString(), 1, dst.toString(), 1);
final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
if (weightValue < 0) {
return new HashSet<>();
}
}
}
return paths;
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:IntentTestsMocks.java
示例2: portData
import org.onosproject.net.Link; //导入依赖的package包/类
private ObjectNode portData(Port p, DeviceId id) {
ObjectNode port = objectNode();
LinkService ls = get(LinkService.class);
String name = p.annotations().value(AnnotationKeys.PORT_NAME);
port.put(ID, capitalizeFully(p.number().toString()));
port.put(TYPE, capitalizeFully(p.type().toString()));
port.put(SPEED, p.portSpeed());
port.put(ENABLED, p.isEnabled());
port.put(NAME, name != null ? name : "");
Set<Link> links = ls.getEgressLinks(new ConnectPoint(id, p.number()));
if (!links.isEmpty()) {
StringBuilder egressLinks = new StringBuilder();
for (Link l : links) {
ConnectPoint dest = l.dst();
egressLinks.append(dest.elementId()).append("/")
.append(dest.port()).append(" ");
}
port.put(LINK_DEST, egressLinks.toString());
}
return port;
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DeviceViewMessageHandler.java
示例3: getLinkFlowCounts
import org.onosproject.net.Link; //导入依赖的package包/类
private Map<Link, Integer> getLinkFlowCounts(DeviceId deviceId) {
// get the flows for the device
List<FlowEntry> entries = new ArrayList<>();
for (FlowEntry flowEntry : servicesBundle.flowService()
.getFlowEntries(deviceId)) {
entries.add(flowEntry);
}
// get egress links from device, and include edge links
Set<Link> links = new HashSet<>(servicesBundle.linkService()
.getDeviceEgressLinks(deviceId));
Set<Host> hosts = servicesBundle.hostService().getConnectedHosts(deviceId);
if (hosts != null) {
for (Host host : hosts) {
links.add(createEdgeLink(host, false));
}
}
// compile flow counts per link
Map<Link, Integer> counts = new HashMap<>();
for (Link link : links) {
counts.put(link, getEgressFlows(link, entries));
}
return counts;
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:TrafficMonitor.java
示例4: toString
import org.onosproject.net.Link; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder sBuilder = new StringBuilder();
for (Device device: srManager.deviceService.getDevices()) {
if (device.id() != rootDevice) {
sBuilder.append("Paths from" + rootDevice + " to " + device.id() + "\r\n");
ArrayList<Path> paths = getECMPPaths(device.id());
if (paths != null) {
for (Path path : paths) {
for (Link link : path.links()) {
sBuilder.append(" : " + link.src() + " -> " + link.dst());
}
}
}
}
}
return sBuilder.toString();
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:EcmpShortestPathGraph.java
示例5: testGetIngressLinks
import org.onosproject.net.Link; //导入依赖的package包/类
@Test
public final void testGetIngressLinks() {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
putLink(linkId1, DIRECT);
putLink(linkId2, DIRECT);
putLink(linkId3, DIRECT);
// DID1,P1 => DID2,P2
// DID2,P2 => DID1,P1
// DID1,P2 => DID2,P3
Set<Link> links1 = linkStore.getIngressLinks(d2P2);
assertEquals(1, links1.size());
assertLink(linkId1, DIRECT, links1.iterator().next());
Set<Link> links2 = linkStore.getIngressLinks(d1P1);
assertEquals(1, links2.size());
assertLink(linkId2, DIRECT, links2.iterator().next());
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ECLinkStoreTest.java
示例6: weight
import org.onosproject.net.Link; //导入依赖的package包/类
@Override
public double weight(TopologyEdge edge) {
// Ignore inactive links
if (edge.link().state() == Link.State.INACTIVE) {
return -1;
}
// TODO: Ignore cross connect links with used ports
// Transport links have highest weight
if (edge.link().type() == Link.Type.OPTICAL) {
return 1000;
}
// Packet links
return 1;
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OpticalPathProvisioner.java
示例7: decodeLinkTypeConstraint
import org.onosproject.net.Link; //导入依赖的package包/类
/**
* Decodes a link type constraint.
*
* @return link type constraint object.
*/
private Constraint decodeLinkTypeConstraint() {
boolean inclusive = nullIsIllegal(json.get(ConstraintCodec.INCLUSIVE),
ConstraintCodec.INCLUSIVE + ConstraintCodec.MISSING_MEMBER_MESSAGE).asBoolean();
JsonNode types = nullIsIllegal(json.get(ConstraintCodec.TYPES),
ConstraintCodec.TYPES + ConstraintCodec.MISSING_MEMBER_MESSAGE);
if (types.size() < 1) {
throw new IllegalArgumentException(
"types array in link constraint must have at least one value");
}
ArrayList<Link.Type> typesEntries = new ArrayList<>(types.size());
IntStream.range(0, types.size())
.forEach(index ->
typesEntries.add(Link.Type.valueOf(types.get(index).asText())));
return new LinkTypeConstraint(inclusive,
typesEntries.toArray(new Link.Type[types.size()]));
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DecodeConstraintCodecHelper.java
示例8: getLinkFlowCounts
import org.onosproject.net.Link; //导入依赖的package包/类
private Map<Link, Integer> getLinkFlowCounts(DeviceId deviceId) {
// get the flows for the device
List<FlowEntry> entries = new ArrayList<>();
for (FlowEntry flowEntry : flowService.getFlowEntries(deviceId)) {
entries.add(flowEntry);
}
// get egress links from device, and include edge links
Set<Link> links = new HashSet<>(linkService.getDeviceEgressLinks(deviceId));
Set<Host> hosts = hostService.getConnectedHosts(deviceId);
if (hosts != null) {
for (Host host : hosts) {
links.add(createEdgeLink(host, false));
}
}
// compile flow counts per link
Map<Link, Integer> counts = new HashMap<>();
for (Link link : links) {
counts.put(link, getEgressFlows(link, entries));
}
return counts;
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:TopologyViewMessageHandlerBase.java
示例9: testGetDeviceEgressLinks
import org.onosproject.net.Link; //导入依赖的package包/类
@Test
public final void testGetDeviceEgressLinks() {
LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
putLink(linkId1, DIRECT);
putLink(linkId2, DIRECT);
putLink(linkId3, DIRECT);
// DID1,P1 => DID2,P2
// DID2,P2 => DID1,P1
// DID1,P2 => DID2,P3
Set<Link> links1 = linkStore.getDeviceEgressLinks(DID1);
assertEquals(2, links1.size());
// check
Set<Link> links2 = linkStore.getDeviceEgressLinks(DID2);
assertEquals(1, links2.size());
assertLink(linkId2, DIRECT, links2.iterator().next());
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:SimpleLinkStoreTest.java
示例10: testConstructor
import org.onosproject.net.Link; //导入依赖的package包/类
/**
* Tests constructor without constraints.
*/
@Test
public void testConstructor() {
final HashSet<Link> links1 = new HashSet<>();
links1.add(link("src", 1, "dst", 2));
final LinkCollectionIntent collectionIntent =
LinkCollectionIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.links(links1)
.ingressPoints(ImmutableSet.of(ingress))
.egressPoints(ImmutableSet.of(egress))
.build();
final Set<Link> createdLinks = collectionIntent.links();
assertThat(createdLinks, hasSize(1));
assertThat(collectionIntent.isInstallable(), is(false));
assertThat(collectionIntent.treatment(), is(treatment));
assertThat(collectionIntent.selector(), is(selector));
assertThat(collectionIntent.ingressPoints(), is(ImmutableSet.of(ingress)));
assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress)));
assertThat(collectionIntent.resources(), hasSize(1));
final List<Constraint> createdConstraints = collectionIntent.constraints();
assertThat(createdConstraints, hasSize(0));
}
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:LinkCollectionIntentTest.java
示例11: createOrUpdateLink
import org.onosproject.net.Link; //导入依赖的package包/类
@Override
public LinkEvent createOrUpdateLink(ProviderId providerId,
LinkDescription linkDescription) {
LinkKey key = linkKey(linkDescription.src(), linkDescription.dst());
Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key);
synchronized (descs) {
final Link oldLink = links.get(key);
// update description
createOrUpdateLinkDescription(descs, providerId, linkDescription);
final Link newLink = composeLink(descs);
if (oldLink == null) {
return createLink(key, newLink);
}
return updateLink(key, oldLink, newLink);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:SimpleLinkStore.java
示例12: sendLinkData
import org.onosproject.net.Link; //导入依赖的package包/类
private void sendLinkData() {
DemoLinkMap linkMap = new DemoLinkMap();
for (Link link : linkSet) {
linkMap.add(link);
}
DemoLink dl = linkMap.add(linkSet[linkIndex]);
dl.makeImportant().setLabel(Integer.toString(linkIndex));
log.debug("sending link data (index {})", linkIndex);
linkIndex += 1;
if (linkIndex >= linkSet.length) {
linkIndex = 0;
}
Highlights highlights = new Highlights();
for (DemoLink dlink : linkMap.biLinks()) {
highlights.add(dlink.highlight(null));
}
sendHighlights(highlights);
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:AppUiTopovMessageHandler.java
示例13: refreshLinkCache
import org.onosproject.net.Link; //导入依赖的package包/类
private LinkEvent refreshLinkCache(LinkKey linkKey) {
AtomicReference<LinkEvent.Type> eventType = new AtomicReference<>();
Link link = links.compute(linkKey, (key, existingLink) -> {
Link newLink = composeLink(linkKey);
if (existingLink == null) {
eventType.set(LINK_ADDED);
return newLink;
} else if (existingLink.state() != newLink.state() ||
existingLink.isExpected() != newLink.isExpected() ||
(existingLink.type() == INDIRECT && newLink.type() == DIRECT) ||
!AnnotationsUtil.isEqual(existingLink.annotations(), newLink.annotations())) {
eventType.set(LINK_UPDATED);
return newLink;
} else {
return existingLink;
}
});
return eventType.get() != null ? new LinkEvent(eventType.get(), link) : null;
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ECLinkStore.java
示例14: ingressFlow
import org.onosproject.net.Link; //导入依赖的package包/类
private FlowRule ingressFlow(PortNumber inPort, Link link,
MplsPathIntent intent,
MplsLabel label) {
TrafficSelector.Builder ingressSelector = DefaultTrafficSelector
.builder(intent.selector());
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
ingressSelector.matchInPort(inPort);
if (intent.ingressLabel().isPresent()) {
ingressSelector.matchEthType(Ethernet.MPLS_UNICAST)
.matchMplsLabel(intent.ingressLabel().get());
// Swap the MPLS label
treat.setMpls(label);
} else {
// Push and set the MPLS label
treat.pushMpls().setMpls(label);
}
// Add the output action
treat.setOutput(link.src().port());
return createFlowRule(intent, link.src().deviceId(), ingressSelector.build(), treat.build());
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:MplsPathIntentCompiler.java
示例15: validate
import org.onosproject.net.Link; //导入依赖的package包/类
private boolean validate(Path path) {
LinkedList<DeviceId> waypoints = new LinkedList<>(this.waypoints);
DeviceId current = waypoints.poll();
// This is safe because Path class ensures the number of links are more than 0
Link firstLink = path.links().get(0);
if (firstLink.src().elementId().equals(current)) {
current = waypoints.poll();
}
for (Link link : path.links()) {
if (link.dst().elementId().equals(current)) {
current = waypoints.poll();
// Empty waypoints means passing through all waypoints in the specified order
if (current == null) {
return true;
}
}
}
return false;
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:WaypointConstraint.java
示例16: edgeToEdgePath
import org.onosproject.net.Link; //导入依赖的package包/类
private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path) {
List<Link> links = Lists.newArrayListWithCapacity(2);
double cost = 0;
// Add source and destination edge links only if they are real and
// add the infrastructure path only if it is not null.
if (srcLink != NOT_HOST) {
links.add(srcLink);
cost++;
}
if (path != null) {
links.addAll(path.links());
cost += path.cost();
}
if (dstLink != NOT_HOST) {
links.add(dstLink);
cost++;
}
return new DefaultPath(PID, links, cost);
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:PathManager.java
示例17: getCrossConnectPoints
import org.onosproject.net.Link; //导入依赖的package包/类
/**
* Returns list of (optical, packet) pairs of cross connection points of missing optical path sections.
*
* Scans the given multi-layer path and looks for sections that use cross connect links.
* The ingress and egress points in the optical layer are combined to the packet layer ports, and
* are returned in a list.
*
* @param path the multi-layer path
* @return List of cross connect link's (packet port, optical port) pairs
*/
private List<Pair<ConnectPoint, ConnectPoint>> getCrossConnectPoints(Path path) {
List<Pair<ConnectPoint, ConnectPoint>> xcPointPairs = new LinkedList<>();
boolean scanning = false;
for (Link link : path.links()) {
if (!isCrossConnectLink(link)) {
continue;
}
if (scanning) {
// link.src() is packet, link.dst() is optical
xcPointPairs.add(Pair.of(checkNotNull(link.src()), checkNotNull(link.dst())));
scanning = false;
} else {
// link.src() is optical, link.dst() is packet
xcPointPairs.add(Pair.of(checkNotNull(link.dst()), checkNotNull(link.src())));
scanning = true;
}
}
return xcPointPairs;
}
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:OpticalPathProvisioner.java
示例18: setUp
import org.onosproject.net.Link; //导入依赖的package包/类
@Before
public void setUp() {
long now = System.currentTimeMillis();
Set<Device> devices = of(device("1"), device("2"),
device("3"), device("4"),
device("5"));
Set<Link> links = of(link("1", 1, "2", 1), link("2", 1, "1", 1),
link("3", 2, "2", 2), link("2", 2, "3", 2),
link("1", 3, "4", 3), link("4", 3, "1", 3),
link("3", 4, "4", 4), link("4", 4, "3", 4));
GraphDescription graphDescription =
new DefaultGraphDescription(now, System.currentTimeMillis(), devices, links);
dt = new DefaultTopology(PID, graphDescription);
assertEquals("incorrect supplier", PID, dt.providerId());
assertEquals("incorrect time", now, dt.time());
assertEquals("incorrect device count", 5, dt.deviceCount());
assertEquals("incorrect link count", 8, dt.linkCount());
assertEquals("incorrect cluster count", 2, dt.clusterCount());
assertEquals("incorrect broadcast set size", 6, dt.broadcastSetSize(C0));
assertEquals("incorrect root node", V1, dt.getCluster(C0).root());
assertEquals("incorrect root node", V5, dt.getCluster(C1).root());
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DefaultTopologyTest.java
示例19: getAllLearnedSwitchesAndVia
import org.onosproject.net.Link; //导入依赖的package包/类
/**
* Return the complete info of the computed ECMP paths for each Device
* learned in multiple iterations from the root Device.
*
* @return the hash table of Devices learned in multiple Dijkstra
* iterations and corresponding ECMP paths in terms of Devices to
* be traversed to it from the root Device
*/
public HashMap<Integer, HashMap<DeviceId,
ArrayList<ArrayList<DeviceId>>>> getAllLearnedSwitchesAndVia() {
HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap = new HashMap<>();
for (Integer itrIndx : distanceDeviceMap.keySet()) {
HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap = new HashMap<>();
for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
ArrayList<ArrayList<DeviceId>> swViaArray = new ArrayList<>();
for (Path path : getECMPPaths(sw)) {
ArrayList<DeviceId> swVia = new ArrayList<>();
for (Link link : path.links()) {
if (link.src().deviceId().equals(rootDevice)) {
/* No need to add the root Device again in
* the Via list
*/
continue;
}
swVia.add(link.src().deviceId());
}
swViaArray.add(swVia);
}
swMap.put(sw, swViaArray);
}
deviceViaMap.put(itrIndx, swMap);
}
return deviceViaMap;
}
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:EcmpShortestPathGraph.java
示例20: testEventLinkDownNoMatches
import org.onosproject.net.Link; //导入依赖的package包/类
/**
* Tests an event for a link down where none of the reasons match
* currently installed intents.
*
* @throws InterruptedException if the latch wait fails.
*/
@Test
public void testEventLinkDownNoMatches() throws InterruptedException {
Link link = link("src", 1, "dst", 2);
LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link);
reasons.add(linkEvent);
TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons);
listener.event(event);
// we expect no message, latch should never fire
assertThat(delegate.latch.await(25, TimeUnit.MILLISECONDS), is(false));
assertThat(delegate.intentIdsFromEvent, hasSize(0));
assertThat(delegate.compileAllFailedFromEvent, is(false));
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:ObjectiveTrackerTest.java
注:本文中的org.onosproject.net.Link类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论