@Override public ObjectNode encode(GroupBucket bucket, CodecContext context) { checkNotNull(bucket, "Driver cannot be null"); ObjectNode result = context.mapper().createObjectNode() .put(TYPE, bucket.type().toString()) .put(WEIGHT, bucket.weight()) .put(PACKETS, bucket.packets()) .put(BYTES, bucket.bytes()) .put(BUCKET_ID, bucket.hashCode()); if (bucket.watchPort() != null) { result.put(WATCH_PORT, bucket.watchPort().toString()); } if (bucket.watchGroup() != null) { result.put(WATCH_GROUP, bucket.watchGroup().toString()); } if (bucket.treatment() != null) { result.set(TREATMENT, context.codec(TrafficTreatment.class).encode(bucket.treatment(), context)); } return result; }
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()); } } } }
List<OFBucket> ofBuckets = new ArrayList<OFBucket>(); for (GroupBucket bucket: buckets.buckets()) { List<OFAction> actions = buildActions(bucket.treatment()); bucketBuilder.setWeight(1); if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) { bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong())); } else { bucketBuilder.setWatchPort(OFPort.ANY); if (type == GroupDescription.Type.FAILOVER && bucket.watchGroup() != null) { bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id())); } else { bucketBuilder.setWatchGroup(OFGroup.ANY);
if (lastGroup != null) { lastGroupIns = lastGroup.buckets().buckets().get(0) .treatment().allInstructions();
List<OFAction> actions = buildActions(bucket.treatment()); if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) { bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong())); } else { bucketBuilder.setWatchPort(OFPort.ANY); if (type == GroupDescription.Type.FAILOVER && bucket.watchGroup() != null) { bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id())); } else { bucketBuilder.setWatchGroup(OFGroup.ANY);
.flatMap(b -> b.treatment().allInstructions().stream()) .collect(Collectors.toList());
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()); } } } }
/** * 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; }
.next().treatment().allInstructions(); for (Instruction i : lastIns) { if (i instanceof Instructions.OutputInstruction) {