Java Code Examples for org.onosproject.net.Link#State
The following examples show how to use
org.onosproject.net.Link#State .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualNetworkManager.java From onos with Apache License 2.0 | 6 votes |
@Override public VirtualLink createVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(src, LINK_POINT_NULL); checkNotNull(dst, LINK_POINT_NULL); ConnectPoint physicalSrc = mapVirtualToPhysicalPort(networkId, src); checkNotNull(physicalSrc, LINK_POINT_NULL); ConnectPoint physicalDst = mapVirtualToPhysicalPort(networkId, dst); checkNotNull(physicalDst, LINK_POINT_NULL); VirtualNetworkProvider provider = getProvider(DefaultVirtualLink.PID); Link.State state = Link.State.INACTIVE; if (provider != null) { boolean traversable = provider.isTraversable(physicalSrc, physicalDst); state = traversable ? Link.State.ACTIVE : Link.State.INACTIVE; } return store.addLink(networkId, src, dst, state, null); }
Example 2
Source File: DistributedVirtualNetworkStore.java From onos with Apache License 2.0 | 6 votes |
@Override public void updateLink(VirtualLink virtualLink, TunnelId tunnelId, Link.State state) { checkState(networkExists(virtualLink.networkId()), "The network has not been added."); Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(virtualLink.networkId()); if (virtualLinkSet == null) { virtualLinkSet = new HashSet<>(); networkIdVirtualLinkSetMap.put(virtualLink.networkId(), virtualLinkSet); log.warn("The updated virtual link {} has not been added", virtualLink); return; } if (!virtualLinkSet.remove(virtualLink)) { log.warn("The updated virtual link {} does not exist", virtualLink); return; } VirtualLink newVirtualLink = DefaultVirtualLink.builder() .networkId(virtualLink.networkId()) .src(virtualLink.src()) .dst(virtualLink.dst()) .tunnelId(tunnelId) .state(state) .build(); virtualLinkSet.add(newVirtualLink); networkIdVirtualLinkSetMap.put(newVirtualLink.networkId(), virtualLinkSet); }
Example 3
Source File: LinkProtoTranslator.java From onos with Apache License 2.0 | 6 votes |
/** * Translates gRPC LinkCore message to {@link Link}. * * @param link gRPC message * @return {@link Link} null if link is a default instance */ public static Link translate(LinkProtoOuterClass.LinkProto link) { if (link.equals(LinkProtoOuterClass.LinkProto.getDefaultInstance())) { return null; } ProviderId providerId = ProviderIdProtoTranslator.translate(link.getProviderId()); Link.State state = LinkEnumsProtoTranslator.translate(link.getState()).get(); ConnectPoint src = ConnectPointProtoTranslator.translate(link.getSrc()).get(); ConnectPoint dst = ConnectPointProtoTranslator.translate(link.getDst()).get(); Link.Type type = LinkEnumsProtoTranslator.translate(link.getType()).get(); Annotations annots = asAnnotations(link.getAnnotations()); Boolean isExpected = link.getIsExpected(); return DefaultLink.builder().state(state) .annotations(annots) .providerId(providerId) .src(src) .dst(dst) .type(type) .isExpected(isExpected) .build(); }
Example 4
Source File: DistributedVirtualNetworkStore.java From onos with Apache License 2.0 | 5 votes |
@Override public VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, Link.State state, TunnelId realizedBy) { checkState(networkExists(networkId), "The network has not been added."); checkState(virtualPortExists(networkId, src.deviceId(), src.port()), "The source virtual port has not been added."); checkState(virtualPortExists(networkId, dst.deviceId(), dst.port()), "The destination virtual port has not been added."); Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(networkId); if (virtualLinkSet == null) { virtualLinkSet = new HashSet<>(); } // validate that the link does not already exist in this network checkState(getLink(networkId, src, dst) == null, "The virtual link already exists"); checkState(getLink(networkId, src, null) == null, "The source connection point has been used by another link"); checkState(getLink(networkId, null, dst) == null, "The destination connection point has been used by another link"); VirtualLink virtualLink = DefaultVirtualLink.builder() .networkId(networkId) .src(src) .dst(dst) .state(state) .tunnelId(realizedBy) .build(); virtualLinkSet.add(virtualLink); networkIdVirtualLinkSetMap.put(networkId, virtualLinkSet); return virtualLink; }
Example 5
Source File: LinkEnumsProtoTranslator.java From onos with Apache License 2.0 | 5 votes |
/** * Translates gRPC enum LinkState to Optional of ONOS enum. * * @param state linkstate state in gRPC enum * @return Optional of equivalent ONOS enum or empty if not recognized */ public static Optional<Link.State> translate(LinkEnumsProto.LinkStateProto state) { switch (state) { case ACTIVE: return Optional.of(Link.State.ACTIVE); case INACTIVE: return Optional.of(Link.State.INACTIVE); default: log.warn("Unrecognized State gRPC message: {}", state); return Optional.empty(); } }
Example 6
Source File: LinkEnumsProtoTranslator.java From onos with Apache License 2.0 | 5 votes |
/** * Translates ONOS enum State to gRPC enum. * * @param state ONOS' state state * @return equivalent gRPC message enum */ public static LinkEnumsProto.LinkStateProto translate(Link.State state) { switch (state) { case ACTIVE: return LinkEnumsProto.LinkStateProto.ACTIVE; case INACTIVE: return LinkEnumsProto.LinkStateProto.INACTIVE; default: log.warn("Unrecognized State", state); throw new IllegalArgumentException("Unrecognized State"); } }
Example 7
Source File: VirtualNetworkStore.java From onos with Apache License 2.0 | 2 votes |
/** * Adds a new virtual link. * * @param networkId network identifier * @param src source end-point of the link * @param dst destination end-point of the link * @param state link state * @param realizedBy underlying tunnel identifier using which this link is realized * @return the virtual link */ VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, Link.State state, TunnelId realizedBy);
Example 8
Source File: VirtualNetworkStore.java From onos with Apache License 2.0 | 2 votes |
/** * Updates the tunnelId in the virtual link. * * @param virtualLink virtual link * @param tunnelId tunnel identifier * @param state link state */ void updateLink(VirtualLink virtualLink, TunnelId tunnelId, Link.State state);