new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(Collections.singletonList(bucket)), key, null, 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;
GroupBuckets oldBuckets = oldGroup.buckets(); List<GroupBucket> newBucketList = new ArrayList<GroupBucket>( oldBuckets.buckets()); boolean groupDescUpdated = false; for (GroupBucket addBucket:buckets.buckets()) { if (!newBucketList.contains(addBucket)) { newBucketList.add(addBucket); for (GroupBucket removeBucket:buckets.buckets()) { if (newBucketList.contains(removeBucket)) { newBucketList.remove(removeBucket);
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()); } } } }
List<Instruction> lastIns = group.buckets().buckets().iterator() .next().treatment().allInstructions(); for (Instruction i : lastIns) { .group(pointedGroup.id()) .build()); GroupBuckets removeBuckets = new GroupBuckets(Collections .singletonList(bucket)); log.debug("Removing buckets from group id {} for next id {} in device {}",
groupBucketList.add(groupBucketCodec.decode(bucketJson, context)); }); buckets = new GroupBuckets(groupBucketList);
lastGroupIns = lastGroup.buckets().buckets().get(0) .treatment().allInstructions();
deviceId, GroupDescription.Type.ALL, new GroupBuckets(l2floodBuckets), l2floodgroupkey, l2floodgroupId,
final List<Instruction> instructions = group.buckets().buckets().stream() .flatMap(b -> b.treatment().allInstructions().stream()) .collect(Collectors.toList()); .anyMatch(i -> !i.type().equals(Instruction.Type.OUTPUT)); if (instructions.size() != group.buckets().buckets().size() || hasNonOutputInstr) { throw new PiTranslationException(
new GroupBuckets(l3McastBuckets), l3MulticastGroupKey, l3MulticastGroupId,
@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; }
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 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); }
/** * Gets primary port number through failover group associated * with this intent. */ private PortNumber getPrimaryPort(PointToPointIntent intent) { Group group = groupService.getGroup(intent.filteredIngressPoint().connectPoint().deviceId(), makeGroupKey(intent.id())); PortNumber primaryPort = null; if (group != null) { List<GroupBucket> buckets = group.buckets().buckets(); Iterator<GroupBucket> iterator = buckets.iterator(); while (primaryPort == null && iterator.hasNext()) { GroupBucket bucket = iterator.next(); Instruction individualInstruction = bucket.treatment().allInstructions().get(0); if (individualInstruction instanceof Instructions.OutputInstruction) { Instructions.OutputInstruction outInstruction = (Instructions.OutputInstruction) individualInstruction; PortNumber tempPortNum = outInstruction.port(); Port port = deviceService.getPort(intent.filteredIngressPoint().connectPoint().deviceId(), tempPortNum); if (port != null && port.isEnabled()) { primaryPort = tempPortNum; } } } } return primaryPort; }
deviceId, GroupDescription.Type.SELECT, new GroupBuckets(l3ecmpGroupBuckets), l3ecmpGroupKey, l3ecmpGroupId,
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()); } } } }
GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(buckets), key, L2ForwardServiceImpl.GROUP_ID,
int bucketIndex = 0; for (OFBucketCounter bucketStats:entry.getBucketStats()) { ((StoredGroupBucketEntry) group.buckets().buckets() .get(bucketIndex)) .setPackets(bucketStats .getPacketCount().getValue()); ((StoredGroupBucketEntry) group.buckets().buckets() .get(bucketIndex)) .setBytes(entry.getBucketStats()
deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), key, null, deviceId, GroupDescription.Type.ALL, new GroupBuckets(buckets), key, null,
for (GroupBucket bucket : group.buckets().buckets()) {