use of org.onosproject.net.flowobjective.FilteringObjective in project onos by opennetworkinglab.
the class FlowObjectiveIntentInstaller method buildObjectiveContexts.
/**
* Builds all objective contexts for a given flow objective Intent with given
* operation.
*
* @param intent the flow objective Intent
* @param direction the operation of this Intent
* @return all objective context of the Intent with given operation
*/
private Set<FlowObjectiveInstallationContext> buildObjectiveContexts(FlowObjectiveIntent intent, Direction direction) {
Objects.requireNonNull(intent);
Objects.requireNonNull(direction);
Set<FlowObjectiveInstallationContext> contexts = Sets.newHashSet();
int size = intent.objectives().size();
List<Objective> objectives = intent.objectives();
List<DeviceId> deviceIds = intent.devices();
if (direction == ADD) {
// The flow objective system will handle the installation order
for (int i = 0; i < size; i++) {
Objective objective = objectives.get(i);
DeviceId deviceId = deviceIds.get(i);
FlowObjectiveInstallationContext ctx = buildObjectiveContext(objective, deviceId, direction);
contexts.add(ctx);
}
return contexts;
} else {
// basic idea is to chain objective contexts
for (int i = 0; i < size; i++) {
Objective objective = intent.objectives().get(i);
DeviceId deviceId = intent.devices().get(i);
if (objective instanceof FilteringObjective) {
// don't need to care ordering of filtering objective
FlowObjectiveInstallationContext ctx = buildObjectiveContext(objective, deviceId, direction);
contexts.add(ctx);
} else if (objective instanceof NextObjective) {
// need to removed after forwarding objective
// nothing to do here
} else if (objective instanceof ForwardingObjective) {
// forwarding objective, also find next objective if
// exist
FlowObjectiveInstallationContext fwdCtx = buildObjectiveContext(objective, deviceId, direction);
ForwardingObjective fwd = (ForwardingObjective) objective;
NextObjective nxt = null;
Integer nextId = fwd.nextId();
if (nextId != null) {
for (int j = 0; j < size; j++) {
if (objectives.get(j).id() == nextId) {
nxt = (NextObjective) objectives.get(j);
break;
}
}
// if a next objective exists in the Intent
if (nxt != null) {
FlowObjectiveInstallationContext nxtCtx = buildObjectiveContext(nxt, deviceId, direction);
fwdCtx.nextContext(nxtCtx);
}
}
contexts.add(fwdCtx);
} else {
// possible here?
log.warn(UNSUPPORT_OBJ, objective);
}
}
}
return contexts;
}
Aggregations