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());
Group group = groupService.getGroup(deviceId, groupKey); if (group != null) { return group; groupService.addListener(listener); try { group = groupService.getGroup(deviceId, groupKey); if (group != null) { return group; } catch (TimeoutException e) { group = groupService.getGroup(deviceId, groupKey); if (group != null) { return group; groupService.removeListener(listener);
Stream<Group> groupStream = Lists.newArrayList(groupService.getGroups(d.id())).stream(); if (groupsState != null) { groupStream = groupStream.filter(g -> g.state().equals(groupsState));
groupService.addBucketsToGroup(gce.groupDescription.deviceId(), gce.groupDescription.appCookie(), gce.groupDescription.buckets(), gce.groupDescription.appId()); } else { groupService.addGroup(gce.groupDescription);
/** * Creates a simple L2 Interface Group. * * @param nextObj the next Objective */ private void createL2InterfaceGroup(NextObjective nextObj) { VlanId assignedVlan = Ofdpa2Pipeline.readVlanFromSelector(nextObj.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by simple next obj is missing. Abort."); Ofdpa2Pipeline.fail(nextObj, ObjectiveError.BADPARAMS); return; } List<GroupInfo> groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan); // There is only one L2 interface group in this case GroupDescription l2InterfaceGroupDesc = groupInfos.get(0).innerMostGroupDesc; // Put all dependency information into allGroupKeys List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList(); Deque<GroupKey> gkeyChain = new ArrayDeque<>(); gkeyChain.addFirst(l2InterfaceGroupDesc.appCookie()); allGroupKeys.add(gkeyChain); // Point the next objective to this group OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj); updatePendingNextObjective(l2InterfaceGroupDesc.appCookie(), ofdpaGrp); // Start installing the inner-most group groupService.addGroup(l2InterfaceGroupDesc); }
@Override public void run() { Set<GroupKey> keys = pendingGroups.keySet().stream() .filter(key -> groupService.getGroup(deviceId, key) != null) .collect(Collectors.toSet()); Set<GroupKey> otherkeys = pendingAddNextObjectives.asMap().keySet().stream() .filter(otherkey -> groupService.getGroup(deviceId, otherkey) != null) .collect(Collectors.toSet()); keys.addAll(otherkeys); keys.stream().forEach(key -> processPendingAddGroupsOrNextObjs(key, false)); } }
appKryo.serialize(nextObjective .id())); Group group = groupService.getGroup(deviceId, key); if (group == null) { log.warn("Group is not found in {} for {}", deviceId, key); log.debug("Removing buckets from group id {} of next objective id {} in device {}", group.id(), nextObjective.id(), deviceId); groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId);
private void addBucketToGroup(NextObjective nextObjective) { log.debug("addBucketToGroup in {}: for next objective id {}", deviceId, nextObjective.id()); Collection<TrafficTreatment> treatments = nextObjective.next(); TrafficTreatment treatment = treatments.iterator().next(); final GroupKey key = new DefaultGroupKey( appKryo.serialize(nextObjective .id())); Group group = groupService.getGroup(deviceId, key); if (group == null) { log.warn("Group is not found in {} for {}", deviceId, key); return; } GroupBucket bucket; if (group.type() == GroupDescription.Type.INDIRECT) { bucket = DefaultGroupBucket.createIndirectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.SELECT) { bucket = DefaultGroupBucket.createSelectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.ALL) { bucket = DefaultGroupBucket.createAllGroupBucket(treatment); } else { log.warn("Unsupported Group type {}", group.type()); return; } GroupBuckets bucketsToAdd = new GroupBuckets(Collections.singletonList(bucket)); log.debug("Adding buckets to group id {} of next objective id {} in device {}", group.id(), nextObjective.id(), deviceId); groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId); }
protected void init(DeviceId deviceId, PipelinerContext context) { this.deviceId = deviceId; this.flowObjectiveStore = context.store(); this.serviceDirectory = context.directory(); this.groupService = serviceDirectory.get(GroupService.class); this.storageService = serviceDirectory.get(StorageService.class); this.nextIndex = storageService.getAtomicCounter("group-id-index-counter"); pendingAddNextObjectives = CacheBuilder.newBuilder() .expireAfterWrite(20, TimeUnit.SECONDS) .removalListener(( RemovalNotification<GroupKey, List<OfdpaNextGroup>> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { notification.getValue().forEach(ofdpaNextGrp -> Ofdpa2Pipeline.fail(ofdpaNextGrp.nextObj, ObjectiveError.GROUPINSTALLATIONFAILED)); } }).build(); pendingRemoveNextObjectives = CacheBuilder.newBuilder() .expireAfterWrite(20, TimeUnit.SECONDS) .removalListener(( RemovalNotification<NextObjective, List<GroupKey>> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { Ofdpa2Pipeline.fail(notification.getKey(), ObjectiveError.GROUPREMOVALFAILED); } }).build(); pendingGroups = new ConcurrentHashMap<>(); groupChecker.scheduleAtFixedRate(new GroupChecker(), 0, 500, TimeUnit.MILLISECONDS); groupService.addListener(new InnerGroupListener()); }
/** * Removes all groups in multiple possible group-chains that represent the next * objective. * * @param nextObjective the next objective to remove * @param next the NextGroup that represents the existing group-chain for * this next objective */ protected void removeGroup(NextObjective nextObjective, NextGroup next) { List<Deque<GroupKey>> allgkeys = Ofdpa2Pipeline.appKryo.deserialize(next.data()); List<GroupKey> groupKeys = allgkeys.stream() .map(Deque::getFirst).collect(Collectors.toList()); pendingRemoveNextObjectives.put(nextObjective, groupKeys); allgkeys.forEach(groupChain -> groupChain.forEach(groupKey -> groupService.removeGroup(deviceId, groupKey, nextObjective.appId()))); flowObjectiveStore.removeNextGroup(nextObjective.id()); }
private void updateFailoverGroup(PointToPointIntent intent, List<Link> links) { GroupKey groupKey = makeGroupKey(intent.id()); TrafficTreatment.Builder tBuilderIn = DefaultTrafficTreatment.builder(); ConnectPoint src = links.get(0).src(); tBuilderIn.setOutput(src.port()); GroupBucket bucket = DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn.build(), src.port(), null); GroupBuckets addBuckets = new GroupBuckets(Collections.singletonList(bucket)); groupService.addBucketsToGroup(src.deviceId(), groupKey, addBuckets, groupKey, intent.appId()); }
private void updateFailoverGroup(PointToPointIntent pointIntent) { DeviceId deviceId = pointIntent.filteredIngressPoint().connectPoint().deviceId(); GroupKey groupKey = makeGroupKey(pointIntent.id()); Group group = waitForGroup(deviceId, groupKey); Iterator<GroupBucket> groupIterator = group.buckets().buckets().iterator(); while (groupIterator.hasNext()) { GroupBucket bucket = groupIterator.next(); Instruction individualInstruction = bucket.treatment().allInstructions().get(0); if (individualInstruction instanceof Instructions.OutputInstruction) { Instructions.OutputInstruction outInstruction = (Instructions.OutputInstruction) individualInstruction; Port port = deviceService.getPort(deviceId, outInstruction.port()); if (port == null || !port.isEnabled()) { GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket)); groupService.removeBucketsFromGroup(deviceId, groupKey, removeBuckets, groupKey, pointIntent.appId()); } } } }
private void wipeOutGroups() { print("Wiping groups"); GroupService groupService = get(GroupService.class); DeviceAdminService deviceAdminService = get(DeviceAdminService.class); for (Device device : deviceAdminService.getDevices()) { groupService.purgeGroupEntries(device.id()); } }
groupService.addGroup(groupInfo.innerMostGroupDesc); });
@Override public void run() { Set<GroupKey> keys = pendingGroups.asMap().keySet().stream() .filter(key -> groupService.getGroup(deviceId, key) != null) .collect(Collectors.toSet()); keys.stream().forEach(key -> { NextObjective obj = pendingGroups.getIfPresent(key); if (obj == null) { return; } pass(obj); pendingGroups.invalidate(key); log.info("Heard back from group service for group {}. " + "Applying pending forwarding objectives", obj.id()); flowObjectiveStore.putNextGroup(obj.id(), new CentecV350Group(key)); }); } }
for (Deque<GroupKey> gkeys : allgkeys) { GroupKey groupWithPort = gkeys.peekLast(); Group group = groupService.getGroup(deviceId, groupWithPort); if (group == null) { log.warn("Inconsistent group chain"); Group modGroup = groupService.getGroup(deviceId, modGroupKey); Group pointedGroup = groupService.getGroup(deviceId, pointedGroupKey); GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket( DefaultTrafficTreatment.builder() log.debug("Removing buckets from group id {} for next id {} in device {}", modGroup.id(), nextObjective.id(), deviceId); groupService.removeBucketsFromGroup(deviceId, modGroupKey, removeBuckets, modGroupKey, nextObjective.appId());
@Override public void init(DeviceId deviceId, PipelinerContext context) { log.debug("Initiate OLT pipeline"); this.serviceDirectory = context.directory(); this.deviceId = deviceId; flowRuleService = serviceDirectory.get(FlowRuleService.class); coreService = serviceDirectory.get(CoreService.class); groupService = serviceDirectory.get(GroupService.class); flowObjectiveStore = context.store(); storageService = serviceDirectory.get(StorageService.class); appId = coreService.registerApplication( "org.onosproject.driver.OLTPipeline"); pendingGroups = CacheBuilder.newBuilder() .expireAfterWrite(20, TimeUnit.SECONDS) .removalListener((RemovalNotification<GroupKey, NextObjective> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { fail(notification.getValue(), ObjectiveError.GROUPINSTALLATIONFAILED); } }).build(); groupService.addListener(new InnerGroupListener()); }
private void removeGroup(NextObjective nextObjective) { log.debug("removeGroup in {}: for next objective id {}", deviceId, nextObjective.id()); final GroupKey key = new DefaultGroupKey( appKryo.serialize(nextObjective.id())); groupService.removeGroup(deviceId, key, appId); }
groupService.addGroup(groupInfo.innerMostGroupDesc); });
@Override public void run() { Set<GroupKey> keys = pendingGroups .asMap() .keySet() .stream() .filter(key -> groupService.getGroup(deviceId, key) != null) .collect(Collectors.toSet()); keys.stream() .forEach(key -> { NextObjective obj = pendingGroups .getIfPresent(key); if (obj == null) { return; } log.debug("Group verified: dev:{} gid:{} <<->> nextId:{}", deviceId, groupService.getGroup(deviceId, key).id(), obj.id()); pass(obj); pendingGroups.invalidate(key); flowObjectiveStore.putNextGroup( obj.id(), new SpringOpenGroup(key, null)); }); } }