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);
}
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;
}
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!");
}
}
Aggregations