Search in sources :

Example 16 with ItemNotFoundException

use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryVlanIds.

private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(device);
        if (handler == null || !handler.hasBehaviour(VlanQuery.class)) {
            return ImmutableSet.of();
        }
        VlanQuery query = handler.behaviour(VlanQuery.class);
        if (query == null) {
            return ImmutableSet.of();
        }
        return query.queryVlanIds(port);
    } catch (ItemNotFoundException e) {
        return ImmutableSet.of();
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) VlanQuery(org.onosproject.net.behaviour.VlanQuery) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 17 with ItemNotFoundException

use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryTributarySlots.

private Set<TributarySlot> queryTributarySlots(DeviceId device, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(device);
        if (handler == null || !handler.hasBehaviour(TributarySlotQuery.class)) {
            return Collections.emptySet();
        }
        TributarySlotQuery query = handler.behaviour(TributarySlotQuery.class);
        if (query != null) {
            return query.queryTributarySlots(port);
        } else {
            return Collections.emptySet();
        }
    } catch (ItemNotFoundException e) {
        return Collections.emptySet();
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) TributarySlotQuery(org.onosproject.net.behaviour.TributarySlotQuery) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 18 with ItemNotFoundException

use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.

the class FlowObjectiveManager method initPipelineHandler.

/**
 * Creates and initialize {@link Pipeliner}.
 * <p>
 * Note: Expected to be called under per-Device lock.
 *      e.g., {@code pipeliners}' Map#compute family methods
 *
 * @param deviceId Device to initialize pipeliner
 * @return {@link Pipeliner} instance or null
 */
private Pipeliner initPipelineHandler(DeviceId deviceId) {
    start = now();
    // Attempt to lookup the handler in the cache
    DriverHandler handler = driverHandlers.get(deviceId);
    cTime = now();
    if (handler == null) {
        try {
            // Otherwise create it and if it has pipeline behaviour, cache it
            handler = driverService.createHandler(deviceId);
            dTime = now();
            if (!handler.driver().hasBehaviour(Pipeliner.class)) {
                log.debug("Pipeline behaviour not supported for device {}", deviceId);
                return null;
            }
        } catch (ItemNotFoundException e) {
            log.warn("No applicable driver for device {}", deviceId);
            return null;
        }
        driverHandlers.put(deviceId, handler);
        eTime = now();
    }
    // Always (re)initialize the pipeline behaviour
    log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId);
    hTime = now();
    Pipeliner pipeliner = handler.behaviour(Pipeliner.class);
    hbTime = now();
    pipeliner.init(deviceId, context);
    stopWatch();
    return pipeliner;
}
Also used : Pipeliner(org.onosproject.net.behaviour.Pipeliner) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 19 with ItemNotFoundException

use of org.onlab.util.ItemNotFoundException 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 20 with ItemNotFoundException

use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.

the class DomainIntentManager method initDomainIntentDriver.

private DomainIntentConfigurable initDomainIntentDriver(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 DomainIntentConfig behaviour, cache it
            handler = driverService.createHandler(deviceId);
            if (!handler.driver().hasBehaviour(DomainIntentConfigurable.class)) {
                log.warn("DomainIntentConfig behaviour not supported for device {}", deviceId);
                return null;
            }
        } catch (ItemNotFoundException e) {
            log.warn("No applicable driver for device {}", deviceId);
            return null;
        }
        driverHandlers.put(deviceId, handler);
    }
    // Always (re)initialize the pipeline behaviour
    log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId);
    return handler.behaviour(DomainIntentConfigurable.class);
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) DomainIntentConfigurable(org.onosproject.net.behaviour.DomainIntentConfigurable) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Aggregations

ItemNotFoundException (org.onlab.util.ItemNotFoundException)25 DriverHandler (org.onosproject.net.driver.DriverHandler)9 Path (javax.ws.rs.Path)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)5 FlowRuleService (org.onosproject.net.flow.FlowRuleService)5 ApplicationId (org.onosproject.core.ApplicationId)4 Driver (org.onosproject.net.driver.Driver)4 List (java.util.List)3 Consumes (javax.ws.rs.Consumes)3 DeviceId (org.onosproject.net.DeviceId)3 FlowEntry (org.onosproject.net.flow.FlowEntry)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 PathParam (javax.ws.rs.PathParam)2 MediaType (javax.ws.rs.core.MediaType)2 Response (javax.ws.rs.core.Response)2