Search in sources :

Example 1 with OFBucketCounter

use of org.projectfloodlight.openflow.protocol.OFBucketCounter in project onos by opennetworkinglab.

the class OpenFlowGroupProvider method buildGroupMetrics.

private Collection<Group> buildGroupMetrics(DeviceId deviceId, OFGroupStatsReply groupStatsReply, OFGroupDescStatsReply groupDescStatsReply) {
    Map<Integer, Group> groups = Maps.newHashMap();
    Dpid dpid = Dpid.dpid(deviceId.uri());
    for (OFGroupDescStatsEntry entry : groupDescStatsReply.getEntries()) {
        int id = entry.getGroup().getGroupNumber();
        GroupId groupId = new GroupId(id);
        GroupDescription.Type type = getGroupType(entry.getGroupType());
        GroupBuckets buckets = new GroupBucketEntryBuilder(dpid, entry.getBuckets(), entry.getGroupType(), driverService).build();
        DefaultGroup group = new DefaultGroup(groupId, deviceId, type, buckets);
        groups.put(id, group);
    }
    if (groupStatsReply == null) {
        return groups.values();
    }
    for (OFGroupStatsEntry entry : groupStatsReply.getEntries()) {
        int groupId = entry.getGroup().getGroupNumber();
        DefaultGroup group = (DefaultGroup) groups.get(groupId);
        if (group != null) {
            group.setBytes(entry.getByteCount().getValue());
            group.setLife(entry.getDurationSec());
            group.setPackets(entry.getPacketCount().getValue());
            group.setReferenceCount(entry.getRefCount());
            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().get(bucketIndex).getByteCount().getValue());
                bucketIndex++;
            }
        }
    }
    return groups.values();
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Dpid(org.onosproject.openflow.controller.Dpid) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) GroupDescription(org.onosproject.net.group.GroupDescription) OFGroupStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupStatsEntry) OFBucketCounter(org.projectfloodlight.openflow.protocol.OFBucketCounter) StoredGroupBucketEntry(org.onosproject.net.group.StoredGroupBucketEntry)

Example 2 with OFBucketCounter

use of org.projectfloodlight.openflow.protocol.OFBucketCounter in project onos by opennetworkinglab.

the class DefaultOFSwitch method ofGroupStatsEntry.

private OFGroupStatsEntry ofGroupStatsEntry(Group group) {
    List<OFBucketCounter> ofBucketCounters = Lists.newArrayList();
    group.buckets().buckets().forEach(groupBucket -> {
        ofBucketCounters.add(FACTORY.bucketCounter(U64.of(groupBucket.packets()), U64.of(groupBucket.bytes())));
    });
    OFGroupStatsEntry entry = FACTORY.buildGroupStatsEntry().setGroup(OFGroup.of(group.id().id())).setDurationSec(group.life()).setPacketCount(U64.of(group.packets())).setByteCount(U64.of(group.bytes())).setRefCount(group.referenceCount()).setBucketStats(ofBucketCounters).build();
    return entry;
}
Also used : OFGroupStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupStatsEntry) OFBucketCounter(org.projectfloodlight.openflow.protocol.OFBucketCounter)

Aggregations

OFBucketCounter (org.projectfloodlight.openflow.protocol.OFBucketCounter)2 OFGroupStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupStatsEntry)2 GroupId (org.onosproject.core.GroupId)1 DefaultGroup (org.onosproject.net.group.DefaultGroup)1 Group (org.onosproject.net.group.Group)1 GroupBuckets (org.onosproject.net.group.GroupBuckets)1 GroupDescription (org.onosproject.net.group.GroupDescription)1 StoredGroupBucketEntry (org.onosproject.net.group.StoredGroupBucketEntry)1 Dpid (org.onosproject.openflow.controller.Dpid)1 OFGroupDescStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry)1