Java Code Examples for org.onosproject.net.flowobjective.NextObjective#id()
The following examples show how to use
org.onosproject.net.flowobjective.NextObjective#id() .
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: NextObjectiveTranslator.java From onos with Apache License 2.0 | 5 votes |
private int selectGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException { final PiTableId hashedTableId = FabricConstants.FABRIC_INGRESS_NEXT_HASHED; final List<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true); final List<TrafficTreatment> piTreatments = Lists.newArrayList(); for (DefaultNextTreatment t : defaultNextTreatments) { // Map treatment to PI... piTreatments.add(mapTreatmentToPiIfNeeded(t.treatment(), hashedTableId)); // ...and handle egress if necessary. handleEgress(obj, t.treatment(), resultBuilder, false); } final List<GroupBucket> bucketList = piTreatments.stream() .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); final int groupId = obj.id(); final PiGroupKey groupKey = new PiGroupKey( hashedTableId, FabricConstants.FABRIC_INGRESS_NEXT_HASHED_SELECTOR, groupId); resultBuilder.addGroup(new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(bucketList), groupKey, groupId, obj.appId())); return groupId; }
Example 2
Source File: XconnectManager.java From onos with Apache License 2.0 | 5 votes |
/** * Populates next objectives for given XConnect. * * @param key XConnect store key * @param endpoints XConnect endpoints * @return next id */ private int populateNext(XconnectKey key, Set<XconnectEndpoint> endpoints) { int nextId = Versioned.valueOrElse(xconnectNextObjStore.get(key), -1); if (nextId != -1) { log.debug("NextObj for {} found, id={}", key, nextId); return nextId; } else { NextObjective.Builder nextObjBuilder = nextObjBuilder(key, endpoints); if (nextObjBuilder == null) { log.warn("Fail to populate {}: {}", key, ERROR_NEXT_OBJ_BUILDER); return -1; } ObjectiveContext nextContext = new DefaultObjectiveContext( // To serialize this with kryo (Serializable & Consumer<Objective>) (objective) -> log.debug("XConnect NextObj for {} added", key), (Serializable & BiConsumer<Objective, ObjectiveError>) (objective, error) -> { log.warn("Failed to add XConnect NextObj for {}: {}", key, error); srService.invalidateNextObj(objective.id()); }); NextObjective nextObj = nextObjBuilder.add(nextContext); flowObjectiveService.next(key.deviceId(), nextObj); xconnectNextObjStore.put(key, nextObj.id()); log.debug("NextObj for {} not found. Creating new NextObj with id={}", key, nextObj.id()); return nextObj.id(); } }
Example 3
Source File: NextObjectiveTranslator.java From onos with Apache License 2.0 | 4 votes |
private int allGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException { final Collection<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true); // No need to map treatments to PI as translation of ALL groups to PRE // multicast entries is based solely on the output port. for (DefaultNextTreatment t : defaultNextTreatments) { handleEgress(obj, t.treatment(), resultBuilder, true); } // FIXME: this implementation supports only the case in which each // switch interface is associated with only one VLAN, otherwise we would // need to support replicating multiple times the same packet for the // same port while setting different VLAN IDs. Hence, collect in a set. final Set<PortNumber> outPorts = defaultNextTreatments.stream() .map(DefaultNextTreatment::treatment) .map(FabricUtils::outputPort) .filter(Objects::nonNull) .collect(Collectors.toSet()); if (outPorts.size() != defaultNextTreatments.size()) { throw new FabricPipelinerException(format( "Found BROADCAST NextObjective with %d treatments but " + "found only %d distinct OUTPUT port numbers, cannot " + "translate to ALL groups", defaultNextTreatments.size(), outPorts.size()), ObjectiveError.UNSUPPORTED); } final List<GroupBucket> bucketList = outPorts.stream() .map(p -> DefaultTrafficTreatment.builder().setOutput(p).build()) .map(DefaultGroupBucket::createAllGroupBucket) .collect(Collectors.toList()); final int groupId = obj.id(); // Use DefaultGroupKey instead of PiGroupKey as we don't have any // action profile to apply to the groups of ALL type. final GroupKey groupKey = new DefaultGroupKey( FabricPipeliner.KRYO.serialize(groupId)); resultBuilder.addGroup( new DefaultGroupDescription( deviceId, GroupDescription.Type.ALL, new GroupBuckets(bucketList), groupKey, groupId, obj.appId())); return groupId; }