@Override public void removeExtraneousGroupEntry(Group group) { ConcurrentMap<GroupId, Group> extraneousIdTable = getExtraneousGroupIdTable(group.deviceId()); extraneousIdTable.remove(group.id()); }
@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)); }); } }
continue; gchain.append(" 0x").append(Integer.toHexString(g.id().id())) .append(" -->"); lastGroup = g;
@Override public void addOrUpdateExtraneousGroupEntry(Group group) { ConcurrentMap<GroupId, Group> extraneousIdTable = getExtraneousGroupIdTable(group.deviceId()); extraneousIdTable.put(group.id(), group); // Check the reference counter if (group.referenceCount() == 0) { notifyDelegate(new GroupEvent(Type.GROUP_REMOVE_REQUESTED, group)); } }
private TrafficTreatment buildFailoverTreatment(DeviceId srcDevice, GroupKey groupKey) { Group group = waitForGroup(srcDevice, groupKey); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); TrafficTreatment trafficTreatment = tBuilder.group(group.id()).build(); return trafficTreatment; }
@Override public void event(GroupEvent event) { if (event.type() == GroupEvent.Type.GROUP_ADDED) { log.trace("InnerGroupListener: Group ADDED " + "event received in device {}", deviceId); GroupKey key = event.subject().appCookie(); NextObjective obj = pendingGroups.getIfPresent(key); if (obj != null) { log.debug("Group verified: dev:{} gid:{} <<->> nextId:{}", deviceId, event.subject().id(), obj.id()); flowObjectiveStore .putNextGroup(obj.id(), new SpringOpenGroup(key, null)); pass(obj); pendingGroups.invalidate(key); } } else if (event.type() == GroupEvent.Type.GROUP_ADD_FAILED) { log.warn("InnerGroupListener: Group ADD " + "failed event received in device {}", deviceId); } } }
.withGroupId(group.id().id()) .addReplicas(getReplicas(outInstructions, device)) .build();
/** * Removes the group entry from store. * * @param group group entry */ @Override public void removeGroupEntry(Group group) { StoredGroupEntry existing = (groupEntriesById.get( group.deviceId()) != null) ? groupEntriesById.get(group.deviceId()).get(group.id()) : null; if (existing != null) { ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(existing.deviceId()); ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(existing.deviceId()); idTable.remove(existing.id()); keyTable.remove(existing.appCookie()); notifyDelegate(new GroupEvent(Type.GROUP_REMOVED, existing)); } }
@Override public ObjectNode encode(Group group, CodecContext context) { checkNotNull(group, "Group cannot be null"); ObjectNode result = context.mapper().createObjectNode() .put(ID, group.id().id().toString()) .put(STATE, group.state().toString()) .put(LIFE, group.life()) .put(PACKETS, group.packets()) .put(BYTES, group.bytes()) .put(REFERENCE_COUNT, group.referenceCount()) .put(TYPE, group.type().toString()) .put(DEVICE_ID, group.deviceId().toString()); if (group.appId() != null) { result.put(APP_ID, group.appId().name()); } if (group.appCookie() != null) { result.put(APP_COOKIE, group.appCookie().toString()); } if (group.givenGroupId() != null) { result.put(GIVEN_GROUP_ID, group.givenGroupId().toString()); } ArrayNode buckets = context.mapper().createArrayNode(); group.buckets().buckets().forEach(bucket -> { ObjectNode bucketJson = context.codec(GroupBucket.class).encode(bucket, context); buckets.add(bucketJson); }); result.set(BUCKETS, buckets); return result; }
StoredGroupEntry existing = (groupEntriesById.get( group.deviceId()) != null) ? groupEntriesById.get(group.deviceId()).get(group.id()) : null; log.trace("groupMissing: group "
case GROUP_ADD_REQUESTED: log.debug("GROUP_ADD_REQUESTED for Group {} on device {}", group.id(), group.deviceId()); GroupOperation groupAddOp = GroupOperation. createAddGroupOperation(group.id(), group.type(), group.buckets()); group.id(), group.deviceId()); GroupOperation groupModifyOp = GroupOperation. createModifyGroupOperation(group.id(), group.type(), group.buckets()); group.id(), group.deviceId()); GroupOperation groupDeleteOp = GroupOperation. createDeleteGroupOperation(group.id(), group.type()); groupOps = new GroupOperations(
private void printGroups(DeviceId deviceId, List<Group> groups) { print("deviceId=%s, groupCount=%s", deviceId, groups.size()); if (countOnly) { return; } for (Group group : groups) { print(FORMAT, Integer.toHexString(group.id().id()), group.state(), group.type(), group.bytes(), group.packets(), group.appId().name(), group.referenceCount()); int i = 0; for (GroupBucket bucket:group.buckets().buckets()) { print(BUCKET_FORMAT, Integer.toHexString(group.id().id()), ++i, bucket.bytes(), bucket.packets(), bucket.treatment().allInstructions()); } } } }
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); }
group.id(), nextObjective.id(), deviceId); groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId);
groupEntriesById.get(group.deviceId()).get(group.id()) : null; GroupEvent event = null;
oldGroup.givenGroupId(), oldGroup.appId()); StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(), updatedGroupDesc); newGroup.setState(GroupState.PENDING_UPDATE); getGroupIdTable(oldGroup.deviceId()); keyTable.remove(oldGroup.appCookie()); idTable.remove(oldGroup.id()); keyTable.put(newGroup.appCookie(), newGroup); idTable.put(newGroup.id(), newGroup);
buildTreatment(Instructions.createGroup(group.id()));
return Collections.emptySet(); tb.group(group.id());