Java Code Examples for org.onosproject.net.flowobjective.NextObjective#op()
The following examples show how to use
org.onosproject.net.flowobjective.NextObjective#op() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FabricPipeliner.java From onos with Apache License 2.0 | 6 votes |
@Override public void next(NextObjective obj) { if (obj.op() == Objective.Operation.VERIFY) { // TODO: support VERIFY operation log.debug("VERIFY operation not yet supported for NextObjective, will return success"); success(obj); return; } if (obj.op() == Objective.Operation.MODIFY) { // TODO: support MODIFY operation log.warn("MODIFY operation not yet supported for NextObjective, will return failure :("); fail(obj, ObjectiveError.UNSUPPORTED); return; } final ObjectiveTranslation result = nextTranslator.translate(obj); handleResult(obj, result); }
Example 2
Source File: FabricPipeliner.java From onos with Apache License 2.0 | 6 votes |
private void handleNextGroup(NextObjective obj) { switch (obj.op()) { case REMOVE: removeNextGroup(obj); break; case ADD: case ADD_TO_EXISTING: case REMOVE_FROM_EXISTING: case MODIFY: putNextGroup(obj); break; case VERIFY: break; default: log.error("Unknown NextObjective operation '{}'", obj.op()); } }
Example 3
Source File: PortLoadBalancerManager.java From onos with Apache License 2.0 | 6 votes |
private void onSuccessHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) { // Operation done PortLoadBalancerData oldPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId); PortLoadBalancerData newPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId); // Other operations will not lead to a generation of an event switch (nextObjective.op()) { case ADD: newPortLoadBalancerData.setNextId(nextObjective.id()); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.INSTALLED, newPortLoadBalancerData, oldPortLoadBalancerData)); break; case REMOVE: oldPortLoadBalancerData.setNextId(nextObjective.id()); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.UNINSTALLED, newPortLoadBalancerData, oldPortLoadBalancerData)); break; default: break; } }
Example 4
Source File: NextTable.java From onos with Apache License 2.0 | 6 votes |
public List<NextObjective> updateNext(NextObjective nextObjective) { List<NextObjective> updates = new ArrayList<>(); switch (nextObjective.op()) { case ADD: this.nextMap.put(nextObjective.id(), nextObjective); updates.add(nextObjective); break; case REMOVE: this.nextMap.remove(nextObjective.id()); updates.add(nextObjective); break; default: break; } return updates; }
Example 5
Source File: InOrderFlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
@Override public void next(NextObjective nextObjective) { recordObjective(nextObjective); // Notify delegate when the next obj is completed ObjectiveEvent.Type type; if (nextObjective.op() == Objective.Operation.ADD || nextObjective.op() == Objective.Operation.ADD_TO_EXISTING) { type = ObjectiveEvent.Type.ADD; } else if (nextObjective.op() == Objective.Operation.REMOVE || nextObjective.op() == Objective.Operation.REMOVE_FROM_EXISTING) { type = ObjectiveEvent.Type.REMOVE; } else { return; } mgr.delegate.notify(new ObjectiveEvent(type, nextObjective.id())); }
Example 6
Source File: VirtualNetworkFlowObjectiveManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void next(DeviceId deviceId, NextObjective nextObjective) { nextToDevice.put(nextObjective.id(), deviceId); if (nextObjective.op() == Objective.Operation.ADD || flowObjectiveStore.getNextGroup(nextObjective.id()) != null || !queueNextObjective(deviceId, nextObjective)) { // either group exists or we are trying to create it - let it through executorService.execute(new ObjectiveInstaller(deviceId, nextObjective)); } }
Example 7
Source File: FlowObjectiveManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void next(DeviceId deviceId, NextObjective nextObjective) { checkPermission(FLOWRULE_WRITE); if (nextObjective.op() == Operation.VERIFY) { // Verify does not need to wait verifierExecutor.execute(new ObjectiveProcessor(deviceId, nextObjective, verifierExecutor)); } else if (nextObjective.op() == Operation.ADD || flowObjectiveStore.getNextGroup(nextObjective.id()) != null || !queueNextObjective(deviceId, nextObjective)) { // either group exists or we are trying to create it - let it through installerExecutor.execute(new ObjectiveProcessor(deviceId, nextObjective, installerExecutor)); } }
Example 8
Source File: Ofdpa2Pipeline.java From onos with Apache License 2.0 | 4 votes |
@Override public void next(NextObjective nextObjective) { NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id()); switch (nextObjective.op()) { case ADD: if (nextGroup != null) { log.warn("Cannot add next {} that already exists in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id {} in dev {} - add group", nextObjective.id(), deviceId); groupHandler.addGroup(nextObjective); break; case ADD_TO_EXISTING: if (nextGroup != null) { log.debug("Processing NextObjective id {} in dev {} - add bucket", nextObjective.id(), deviceId); groupHandler.addBucketToGroup(nextObjective, nextGroup); } else { // it is possible that group-chain has not been fully created yet log.debug("Waiting to add bucket to group for next-id:{} in dev:{}", nextObjective.id(), deviceId); // by design multiple pending bucket is allowed for the group groupHandler.pendingBuckets.compute(nextObjective.id(), (nextId, pendBkts) -> { if (pendBkts == null) { pendBkts = Sets.newHashSet(); } pendBkts.add(nextObjective); return pendBkts; }); } break; case REMOVE: if (nextGroup == null) { log.warn("Cannot remove next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id {} in dev {} - remove group", nextObjective.id(), deviceId); groupHandler.removeGroup(nextObjective, nextGroup); break; case REMOVE_FROM_EXISTING: if (nextGroup == null) { log.warn("Cannot remove from next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id {} in dev {} - remove bucket", nextObjective.id(), deviceId); groupHandler.removeBucketFromGroup(nextObjective, nextGroup); break; case MODIFY: if (nextGroup == null) { log.warn("Cannot modify next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id {} in dev {} group {} - modify bucket", nextObjective.id(), deviceId, nextGroup); groupHandler.modifyBucketFromGroup(nextObjective, nextGroup); break; case VERIFY: if (nextGroup == null) { log.warn("Cannot verify next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id {} in dev {} - verify", nextObjective.id(), deviceId); groupHandler.verifyGroup(nextObjective, nextGroup); break; default: log.warn("Unsupported operation {}", nextObjective.op()); } }
Example 9
Source File: NokiaOltPipeline.java From onos with Apache License 2.0 | 4 votes |
@Override public void next(NextObjective nextObjective) { if (nextObjective.type() != NextObjective.Type.BROADCAST) { log.error("OLT only supports broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); } if (nextObjective.next().size() != 1) { log.error("OLT only supports singleton broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); } TrafficTreatment treatment = nextObjective.next().stream().findFirst().get(); GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment); GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); pendingGroups.put(key, nextObjective); switch (nextObjective.op()) { case ADD: GroupDescription groupDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(Collections.singletonList(bucket)), key, null, nextObjective.appId()); groupService.addGroup(groupDesc); break; case REMOVE: groupService.removeGroup(deviceId, key, nextObjective.appId()); break; case ADD_TO_EXISTING: groupService.addBucketsToGroup(deviceId, key, new GroupBuckets(Collections.singletonList(bucket)), key, nextObjective.appId()); break; case REMOVE_FROM_EXISTING: groupService.removeBucketsFromGroup(deviceId, key, new GroupBuckets(Collections.singletonList(bucket)), key, nextObjective.appId()); break; default: log.warn("Unknown next objective operation: {}", nextObjective.op()); } }
Example 10
Source File: SpringOpenTTP.java From onos with Apache License 2.0 | 4 votes |
@Override public void next(NextObjective nextObjective) { NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id()); switch (nextObjective.op()) { case ADD: if (nextGroup != null) { log.warn("Cannot add next {} that already exists in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id{} in dev{} - add group", nextObjective.id(), deviceId); addGroup(nextObjective); break; case ADD_TO_EXISTING: if (nextGroup != null) { log.debug("Processing NextObjective id{} in dev{} - add bucket", nextObjective.id(), deviceId); addBucketToGroup(nextObjective); } else { log.warn("Cannot add to group that does not exist"); } break; case REMOVE: if (nextGroup == null) { log.warn("Cannot remove next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id{} in dev{} - remove group", nextObjective.id(), deviceId); removeGroup(nextObjective); break; case REMOVE_FROM_EXISTING: if (nextGroup == null) { log.warn("Cannot remove from next {} that does not exist in device {}", nextObjective.id(), deviceId); return; } log.debug("Processing NextObjective id{} in dev{} - remove bucket", nextObjective.id(), deviceId); removeBucketFromGroup(nextObjective); break; default: log.warn("Unsupported operation {}", nextObjective.op()); } }
Example 11
Source File: OltPipeline.java From onos with Apache License 2.0 | 4 votes |
@Override public void next(NextObjective nextObjective) { if (nextObjective.type() != NextObjective.Type.BROADCAST) { log.error("OLT only supports broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); return; } if (nextObjective.next().size() != 1 && !nextObjective.op().equals(Objective.Operation.REMOVE)) { log.error("OLT only supports singleton broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); return; } Optional<TrafficTreatment> treatmentOpt = nextObjective.next().stream().findFirst(); if (treatmentOpt.isEmpty() && !nextObjective.op().equals(Objective.Operation.REMOVE)) { log.error("Next objective {} does not have a treatment", nextObjective); fail(nextObjective, ObjectiveError.BADPARAMS); return; } GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); pendingGroups.put(key, nextObjective); log.trace("NextObjective Operation {}", nextObjective.op()); switch (nextObjective.op()) { case ADD: GroupDescription groupDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets( Collections.singletonList( buildBucket(treatmentOpt.get()))), key, null, nextObjective.appId()); groupService.addGroup(groupDesc); break; case REMOVE: groupService.removeGroup(deviceId, key, nextObjective.appId()); break; case ADD_TO_EXISTING: groupService.addBucketsToGroup(deviceId, key, new GroupBuckets( Collections.singletonList( buildBucket(treatmentOpt.get()))), key, nextObjective.appId()); break; case REMOVE_FROM_EXISTING: groupService.removeBucketsFromGroup(deviceId, key, new GroupBuckets( Collections.singletonList( buildBucket(treatmentOpt.get()))), key, nextObjective.appId()); break; default: log.warn("Unknown next objective operation: {}", nextObjective.op()); } }
Example 12
Source File: NextObjectiveTranslator.java From onos with Apache License 2.0 | 4 votes |
private boolean isGroupModifyOp(NextObjective obj) { // If operation is ADD_TO_EXIST or REMOVE_FROM_EXIST, it means we modify // group buckets only, no changes for flow rules. return obj.op() == Objective.Operation.ADD_TO_EXISTING || obj.op() == Objective.Operation.REMOVE_FROM_EXISTING; }
Example 13
Source File: PortLoadBalancerManager.java From onos with Apache License 2.0 | 4 votes |
private void onErrorHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) { // There was a failure PortLoadBalancerData portLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId); // send FAILED event; switch (nextObjective.op()) { case ADD: // If ADD is failing apps do not know the next id; let's update the store portLoadBalancerNextStore.remove(portLoadBalancerId); portLoadBalancerResStore.remove(portLoadBalancerId); portLoadBalancerStore.remove(portLoadBalancerId); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData)); break; case ADD_TO_EXISTING: // If ADD_TO_EXISTING is failing let's remove the failed ports Collection<PortNumber> addedPorts = nextObjective.next().stream() .flatMap(t -> t.allInstructions().stream()) .filter(i -> i.type() == Instruction.Type.OUTPUT) .map(i -> ((Instructions.OutputInstruction) i).port()) .collect(Collectors.toList()); portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> { if (value != null && value.ports() != null && !value.ports().isEmpty()) { value.ports().removeAll(addedPorts); } return value; }); portLoadBalancerData.setNextId(nextObjective.id()); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData)); break; case REMOVE_FROM_EXISTING: // If REMOVE_TO_EXISTING is failing let's re-add the failed ports Collection<PortNumber> removedPorts = nextObjective.next().stream() .flatMap(t -> t.allInstructions().stream()) .filter(i -> i.type() == Instruction.Type.OUTPUT) .map(i -> ((Instructions.OutputInstruction) i).port()) .collect(Collectors.toList()); portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> { if (value != null && value.ports() != null) { value.ports().addAll(removedPorts); } return value; }); portLoadBalancerData.setNextId(nextObjective.id()); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData)); break; case VERIFY: case REMOVE: // If ADD/REMOVE_TO_EXISTING, REMOVE and VERIFY are failing let's send // also the info about the next id portLoadBalancerData.setNextId(nextObjective.id()); post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData)); break; default: break; } }