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


Java Link类代码示例

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


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


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