Search in sources :

Example 6 with Pipeliner

use of org.onosproject.net.behaviour.Pipeliner in project onos by opennetworkinglab.

the class FlowObjectiveCompositionManager method setupPipelineHandler.

private void setupPipelineHandler(DeviceId deviceId) {
    // Attempt to lookup the handler in the cache
    DriverHandler handler = driverHandlers.get(deviceId);
    if (handler == null) {
        try {
            // Otherwise create it and if it has pipeline behaviour, cache it
            handler = driverService.createHandler(deviceId);
            if (!handler.driver().hasBehaviour(Pipeliner.class)) {
                log.warn("Pipeline behaviour not supported for device {}", deviceId);
                return;
            }
        } catch (ItemNotFoundException e) {
            log.warn("No applicable driver for device {}", deviceId);
            return;
        }
        driverHandlers.put(deviceId, handler);
    }
    // Always (re)initialize the pipeline behaviour
    log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId);
    Pipeliner pipeliner = handler.behaviour(Pipeliner.class);
    pipeliner.init(deviceId, context);
    pipeliners.putIfAbsent(deviceId, pipeliner);
}
Also used : Pipeliner(org.onosproject.net.behaviour.Pipeliner) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 7 with Pipeliner

use of org.onosproject.net.behaviour.Pipeliner in project onos by opennetworkinglab.

the class FlowObjectiveManager method getNextMappings.

@Override
public List<String> getNextMappings() {
    List<String> mappings = new ArrayList<>();
    Map<Integer, NextGroup> allnexts = flowObjectiveStore.getAllGroups();
    for (Map.Entry<Integer, NextGroup> e : allnexts.entrySet()) {
        // get the device this next Objective was sent to
        DeviceId deviceId = nextToDevice.get(e.getKey());
        mappings.add("NextId " + e.getKey() + ": " + ((deviceId != null) ? deviceId : "nextId not in this onos instance"));
        if (deviceId != null) {
            // this instance of the controller sent the nextObj to a driver
            Pipeliner pipeliner = getDevicePipeliner(deviceId);
            List<String> nextMappings = pipeliner.getNextMappings(e.getValue());
            if (nextMappings != null) {
                mappings.addAll(nextMappings);
            }
        }
    }
    return mappings;
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) Pipeliner(org.onosproject.net.behaviour.Pipeliner) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with Pipeliner

use of org.onosproject.net.behaviour.Pipeliner in project onos by opennetworkinglab.

the class FlowObjectiveManager method purgeAll.

@Override
public void purgeAll(DeviceId deviceId, ApplicationId appId) {
    synchronized (pendingForwards) {
        List<Integer> emptyPendingForwards = Lists.newArrayList();
        pendingForwards.forEach((nextId, pendingObjectives) -> {
            pendingObjectives.removeIf(pendingFlowObjective -> pendingFlowObjective.deviceId().equals(deviceId));
            if (pendingObjectives.isEmpty()) {
                emptyPendingForwards.add(nextId);
            }
        });
        emptyPendingForwards.forEach(pendingForwards::remove);
    }
    synchronized (pendingNexts) {
        List<Integer> emptyPendingNexts = Lists.newArrayList();
        pendingNexts.forEach((nextId, pendingObjectives) -> {
            pendingObjectives.removeIf(pendingFlowObjective -> pendingFlowObjective.deviceId().equals(deviceId));
            if (pendingObjectives.isEmpty()) {
                emptyPendingNexts.add(nextId);
            }
        });
        emptyPendingNexts.forEach(pendingNexts::remove);
    }
    Pipeliner pipeliner = getDevicePipeliner(deviceId);
    if (pipeliner != null) {
        pipeliner.purgeAll(appId);
    } else {
        log.warn("Skip purgeAll, pipeliner not ready!");
    }
}
Also used : Pipeliner(org.onosproject.net.behaviour.Pipeliner)

Aggregations

Pipeliner (org.onosproject.net.behaviour.Pipeliner)8 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 DeviceId (org.onosproject.net.DeviceId)3 NextGroup (org.onosproject.net.behaviour.NextGroup)3 HashMap (java.util.HashMap)2 ItemNotFoundException (org.onlab.util.ItemNotFoundException)2 DriverHandler (org.onosproject.net.driver.DriverHandler)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 URL (java.net.URL)1 List (java.util.List)1 Pair (org.apache.commons.lang3.tuple.Pair)1 IntProgrammable (org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable)1