Java Code Examples for org.onosproject.net.link.LinkEvent#type()

The following examples show how to use org.onosproject.net.link.LinkEvent#type() . 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: EdgeManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processLinkEvent(LinkEvent event) {
    // negative Link event can result in increase of edge ports
    boolean addEdgePort = event.type() == LinkEvent.Type.LINK_REMOVED;

    // but if the Link is an Edge type, it will be the opposite
    if (event.subject().type() == Type.EDGE) {
        addEdgePort = !addEdgePort;
    }

    if (addEdgePort) {
        addEdgePort(event.subject().src());
        addEdgePort(event.subject().dst());
    } else {
        removeEdgePort(event.subject().src());
        removeEdgePort(event.subject().dst());
    }
}
 
Example 2
Source File: Ipv6RoutingComponent.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(LinkEvent event) {
    switch (event.type()) {
        case LINK_ADDED:
            break;
        case LINK_UPDATED:
        case LINK_REMOVED:
        default:
            return false;
    }
    DeviceId srcDev = event.subject().src().deviceId();
    DeviceId dstDev = event.subject().dst().deviceId();
    return mastershipService.isLocalMaster(srcDev) ||
            mastershipService.isLocalMaster(dstDev);
}
 
Example 3
Source File: Ipv6RoutingComponent.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(LinkEvent event) {
    switch (event.type()) {
        case LINK_ADDED:
            break;
        case LINK_UPDATED:
        case LINK_REMOVED:
        default:
            return false;
    }
    DeviceId srcDev = event.subject().src().deviceId();
    DeviceId dstDev = event.subject().dst().deviceId();
    return mastershipService.isLocalMaster(srcDev) ||
            mastershipService.isLocalMaster(dstDev);
}
 
Example 4
Source File: Ipv6RoutingComponent.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(LinkEvent event) {
    switch (event.type()) {
        case LINK_ADDED:
            break;
        case LINK_UPDATED:
        case LINK_REMOVED:
        default:
            return false;
    }
    DeviceId srcDev = event.subject().src().deviceId();
    DeviceId dstDev = event.subject().dst().deviceId();
    return mastershipService.isLocalMaster(srcDev) ||
            mastershipService.isLocalMaster(dstDev);
}
 
Example 5
Source File: TopologyHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private boolean isValid(LinkEvent linkEvent) {
    Link link = linkEvent.subject();
    // Verify if the link is valid with the link handler
    if (!srManager.linkHandler.isLinkValid(link)) {
        log.debug("Link {} ignored by the LinkHandler", link);
        return false;
    }
    // Processing for LINK_REMOVED
    if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
        // device availability check helps to ensure that multiple link-removed
        // events are actually treated as a single switch removed event.
        // purgeSeenLink is necessary so we do rerouting (instead of rehashing)
        // when switch comes back.
        if (link.src().elementId() instanceof DeviceId
                && !srManager.deviceService.isAvailable(link.src().deviceId())) {
            log.debug("Link {} ignored device {} is down", link, link.src().deviceId());
            return false;
        }
        if (link.dst().elementId() instanceof DeviceId
                && !srManager.deviceService.isAvailable(link.dst().deviceId())) {
            log.debug("Link {} ignored device {} is down", link, link.dst().deviceId());
            return false;
        }
        // LINK_REMOVED is ok
        return true;
    }
    // Processing for LINK_ADDED and LINK_UPDATED
    // Verify if source device is configured
    if (srManager.deviceConfiguration == null ||
            !srManager.deviceConfiguration.isConfigured(link.src().deviceId())) {
        // Source device is not configured, not valid for us
        log.warn("Source device of this link is not configured.. "
                         + "not processing further");
        return false;
    }
    // LINK_ADDED/LINK_UPDATED is ok
    return true;
}
 
Example 6
Source File: ObjectiveTracker.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    // If there is no delegate, why bother? Just bail.
    if (delegate == null) {
        return;
    }

    if (event.reasons() == null || event.reasons().isEmpty()) {
        delegate.triggerCompile(Collections.emptySet(), true);

    } else {
        Set<Key> intentsToRecompile = new HashSet<>();
        boolean dontRecompileAllFailedIntents = true;

        // Scan through the list of reasons and keep accruing all
        // intents that need to be recompiled.
        for (Event reason : event.reasons()) {
            if (reason instanceof LinkEvent) {
                LinkEvent linkEvent = (LinkEvent) reason;
                final LinkKey linkKey = linkKey(linkEvent.subject());
                synchronized (intentsByLink) {
                    Set<Key> intentKeys = intentsByLink.get(linkKey);
                    log.debug("recompile triggered by LinkEvent {} ({}) for {}",
                            linkKey, linkEvent.type(), intentKeys);
                    intentsToRecompile.addAll(intentKeys);
                }
                dontRecompileAllFailedIntents = dontRecompileAllFailedIntents &&
                        (linkEvent.type() == LINK_REMOVED ||
                        (linkEvent.type() == LINK_UPDATED &&
                        linkEvent.subject().isExpected()));
            }
        }
        delegate.triggerCompile(intentsToRecompile, !dontRecompileAllFailedIntents);
    }
}