use of org.onosproject.net.flowobjective.NextObjQueueKey in project onos by opennetworkinglab.
the class InOrderFlowObjectiveManager method execute.
/**
* Submit the flow objective. Starting from this point on, the execution order is not guaranteed.
* Therefore we must be certain that this method is called in-order.
*
* @param deviceId Device ID
* @param obj Flow objective
*/
private void execute(DeviceId deviceId, Objective obj) {
LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG;
Tools.log(log, logLevel, "Submit objective installer, deviceId {}, obj {}", deviceId, obj);
int priority = obj.priority();
if (obj instanceof FilteringObjective) {
FilteringObjQueueKey k = new FilteringObjQueueKey(deviceId, priority, ((FilteringObjective) obj).key());
filtObjQueueHead.put(k, obj);
super.filter(deviceId, (FilteringObjective) obj);
} else if (obj instanceof ForwardingObjective) {
ForwardingObjQueueKey k = new ForwardingObjQueueKey(deviceId, priority, ((ForwardingObjective) obj).selector());
fwdObjQueueHead.put(k, obj);
super.forward(deviceId, (ForwardingObjective) obj);
} else if (obj instanceof NextObjective) {
NextObjQueueKey k = new NextObjQueueKey(deviceId, obj.id());
nextObjQueueHead.put(k, obj);
super.next(deviceId, (NextObjective) obj);
} else {
log.error("Unknown flow objective instance: {}", obj.getClass().getName());
}
}
use of org.onosproject.net.flowobjective.NextObjQueueKey in project onos by opennetworkinglab.
the class InOrderFlowObjectiveManager method enqueue.
/**
* Enqueue flow objective. Execute the flow objective if there is no pending objective ahead.
*
* @param deviceId Device ID
* @param obj Flow objective
*/
private synchronized void enqueue(DeviceId deviceId, Objective obj) {
int queueSize;
int priority = obj.priority();
LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG;
Tools.log(log, logLevel, "Enqueue {}", obj);
if (obj instanceof FilteringObjective) {
FilteringObjQueueKey k = new FilteringObjQueueKey(deviceId, priority, ((FilteringObjective) obj).key());
filtObjQueue.put(k, obj);
queueSize = filtObjQueue.get(k).size();
} else if (obj instanceof ForwardingObjective) {
ForwardingObjQueueKey k = new ForwardingObjQueueKey(deviceId, priority, ((ForwardingObjective) obj).selector());
fwdObjQueue.put(k, obj);
queueSize = fwdObjQueue.get(k).size();
} else if (obj instanceof NextObjective) {
NextObjQueueKey k = new NextObjQueueKey(deviceId, obj.id());
nextObjQueue.put(k, obj);
queueSize = nextObjQueue.get(k).size();
} else {
log.error("Unknown flow objective instance: {}", obj.getClass().getName());
return;
}
log.trace("{} queue size {}", obj.getClass().getSimpleName(), queueSize);
// Execute immediately if there is no pending obj ahead
if (queueSize == 1) {
execute(deviceId, obj);
}
}
use of org.onosproject.net.flowobjective.NextObjQueueKey in project onos by opennetworkinglab.
the class InOrderFlowObjectiveManager method dequeue.
/**
* Dequeue flow objective. Execute the next flow objective in the queue, if any.
*
* @param deviceId Device ID
* @param obj Flow objective
* @param error ObjectiveError that triggers this dequeue. Null if this is not triggered by an error.
*/
private synchronized void dequeue(DeviceId deviceId, Objective obj, ObjectiveError error) {
List<Objective> remaining;
int priority = obj.priority();
LogLevel logLevel = (obj.op() == Objective.Operation.VERIFY) ? LogLevel.TRACE : LogLevel.DEBUG;
Tools.log(log, logLevel, "Dequeue {}", obj);
if (obj instanceof FilteringObjective) {
FilteringObjQueueKey k = new FilteringObjQueueKey(deviceId, priority, ((FilteringObjective) obj).key());
if (!Objects.equals(ObjectiveError.INSTALLATIONTIMEOUT, error)) {
filtObjQueueHead.invalidate(k);
}
filtObjQueue.remove(k, obj);
remaining = filtObjQueue.get(k);
} else if (obj instanceof ForwardingObjective) {
ForwardingObjQueueKey k = new ForwardingObjQueueKey(deviceId, priority, ((ForwardingObjective) obj).selector());
if (!Objects.equals(ObjectiveError.INSTALLATIONTIMEOUT, error)) {
fwdObjQueueHead.invalidate(k);
}
fwdObjQueue.remove(k, obj);
remaining = fwdObjQueue.get(k);
} else if (obj instanceof NextObjective) {
if (error != null) {
// Remove pendingForwards and pendingNexts if next objective failed
Set<PendingFlowObjective> removedForwards = pendingForwards.remove(obj.id());
List<PendingFlowObjective> removedNexts = pendingNexts.remove(obj.id());
if (removedForwards != null) {
removedForwards.stream().map(PendingFlowObjective::flowObjective).forEach(pendingObj -> pendingObj.context().ifPresent(c -> c.onError(pendingObj, error)));
}
if (removedNexts != null) {
removedNexts.stream().map(PendingFlowObjective::flowObjective).forEach(pendingObj -> pendingObj.context().ifPresent(c -> c.onError(pendingObj, error)));
}
}
NextObjQueueKey k = new NextObjQueueKey(deviceId, obj.id());
if (!Objects.equals(ObjectiveError.INSTALLATIONTIMEOUT, error)) {
nextObjQueueHead.invalidate(k);
}
nextObjQueue.remove(k, obj);
remaining = nextObjQueue.get(k);
} else {
log.error("Unknown flow objective instance: {}", obj.getClass().getName());
return;
}
log.trace("{} queue size {}", obj.getClass().getSimpleName(), remaining.size());
// Submit the next one in the queue, if any
if (remaining.size() > 0) {
execute(deviceId, remaining.get(0));
}
}
use of org.onosproject.net.flowobjective.NextObjQueueKey in project onos by opennetworkinglab.
the class FlowObjectiveQueueListCommand method doExecute.
@Override
protected void doExecute() {
try {
FlowObjectiveService service = get(FlowObjectiveService.class);
ListMultimap<FilteringObjQueueKey, Objective> filtObjQueue = service.getFilteringObjQueue();
ListMultimap<ForwardingObjQueueKey, Objective> fwdObjQueue = service.getForwardingObjQueue();
ListMultimap<NextObjQueueKey, Objective> nextObjQueue = service.getNextObjQueue();
Map<FilteringObjQueueKey, Objective> filtObjQueueHead = service.getFilteringObjQueueHead();
Map<ForwardingObjQueueKey, Objective> fwdObjQueueHead = service.getForwardingObjQueueHead();
Map<NextObjQueueKey, Objective> nextObjQueueHead = service.getNextObjQueueHead();
if (cache) {
printMap("Filtering objective cache", filtObjQueueHead, sizeOnly);
printMap("Forwarding objective cache", fwdObjQueueHead, sizeOnly);
printMap("Next objective cache", nextObjQueueHead, sizeOnly);
} else {
printMap("Filtering objective queue", filtObjQueue.asMap(), sizeOnly);
printMap("Forwarding objective queue", fwdObjQueue.asMap(), sizeOnly);
printMap("Next objective queue", nextObjQueue.asMap(), sizeOnly);
}
} catch (ServiceNotFoundException e) {
print("FlowObjectiveService unavailable");
}
}
Aggregations