use of org.onosproject.net.behaviour.MirroringStatistics in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getMirroringStatistics.
@Override
public Set<MirroringStatistics> getMirroringStatistics(DeviceId deviceId) {
Uuid bridgeUuid = getBridgeUuid(deviceId);
if (bridgeUuid == null) {
log.warn("Couldn't find bridge {} in {}", deviceId, nodeId.getIpAddress());
return null;
}
List<MirroringStatistics> mirrorings = getMirrorings(bridgeUuid);
if (mirrorings == null) {
log.warn("Couldn't find mirrors in {}", nodeId.getIpAddress());
return null;
}
return ImmutableSet.copyOf(mirrorings);
}
use of org.onosproject.net.behaviour.MirroringStatistics in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getMirrorings.
/**
* Helper method which retrieves mirrorings statistics using bridge uuid.
*
* @param bridgeUuid the uuid of the bridge
* @return the list of the mirrorings statistics.
*/
private List<MirroringStatistics> getMirrorings(Uuid bridgeUuid) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
if (dbSchema == null) {
log.warn("Unable to retrieve dbSchema {}", DATABASENAME);
return null;
}
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.warn("Unable to retrieve rowStore {} of {}", BRIDGE, DATABASENAME);
return null;
}
Row bridgeRow = rowStore.getRow(bridgeUuid.value());
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
Set<Uuid> mirroringsUuids = (Set<Uuid>) ((OvsdbSet) bridge.getMirrorsColumn().data()).set();
OvsdbRowStore mirrorRowStore = getRowStore(DATABASENAME, MIRROR);
if (mirrorRowStore == null) {
log.warn("Unable to retrieve rowStore {} of {}", MIRROR, DATABASENAME);
return null;
}
List<MirroringStatistics> mirroringStatistics = new ArrayList<>();
ConcurrentMap<String, Row> mirrorTableRows = mirrorRowStore.getRowStore();
mirrorTableRows.forEach((key, row) -> {
if (!mirroringsUuids.contains(Uuid.uuid(key))) {
return;
}
Mirror mirror = (Mirror) TableGenerator.getTable(dbSchema, row, OvsdbTable.MIRROR);
mirroringStatistics.add(MirroringStatistics.mirroringStatistics(mirror.getName(), (Map<String, Integer>) ((OvsdbMap) mirror.getStatisticsColumn().data()).map()));
});
return ImmutableList.copyOf(mirroringStatistics);
}
Aggregations