@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; }
if (matchingBucket.isPresent()) { ((StoredGroupBucketEntry) matchingBucket. get()).setPackets(bucket.packets()); ((StoredGroupBucketEntry) matchingBucket. get()).setBytes(bucket.bytes());
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()); } } } }