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();
}
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;
}
Aggregations