/** * Generates a link description from a link description entity. The endpoints * must be specified to indicate directionality. * * @param src the source ConnectPoint * @param dst the destination ConnectPoint * @param link the link config entity * @return a linkDescription based on the config */ public static LinkDescription descriptionOf( ConnectPoint src, ConnectPoint dst, Link link) { checkNotNull(src, "Must supply a source endpoint"); checkNotNull(dst, "Must supply a destination endpoint"); checkNotNull(link, "Must supply a link"); return new DefaultLinkDescription( src, dst, link.type(), link.isExpected(), (SparseAnnotations) link.annotations()); }
(linkEvent.type() == LINK_REMOVED || (linkEvent.type() == LINK_UPDATED && linkEvent.subject().isExpected()));
private LinkDescription description(Link link, String key, String value) { checkNotNull(key, "Key cannot be null"); DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); if (value != null) { builder.set(key, value); } else { builder.remove(key); } return new DefaultLinkDescription(link.src(), link.dst(), link.type(), link.isExpected(), builder.build()); }
/** * Returns a formatted string representing the given link. * * @param link infrastructure link * @return formatted link string */ public static String linkString(Link link) { return String.format(FMT, link.src().deviceId(), link.src().port(), link.dst().deviceId(), link.dst().port(), link.type(), link.state(), annotations(link.annotations()), link.isExpected()); }
private Link reverseLink(Link link) { return DefaultLink.builder().providerId(link.providerId()) .src(link.dst()) .dst(link.src()) .type(link.type()) .state(link.state()) .isExpected(link.isExpected()) .build(); }
/** * Returns a link in reverse direction. * * @param link to revese * @return reversed link */ Link reverse(Link link) { return DefaultLink.builder() .providerId(link.providerId()) .src(link.dst()) .dst(link.src()) .type(link.type()) .state(link.state()) .isExpected(link.isExpected()) .annotations(link.annotations()) .build(); }