Search in sources :

Example 1 with MirroringStatistics

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);
}
Also used : Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) MirroringStatistics(org.onosproject.net.behaviour.MirroringStatistics)

Example 2 with MirroringStatistics

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);
}
Also used : Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) ArrayList(java.util.ArrayList) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Row(org.onosproject.ovsdb.rfc.notation.Row) MirroringStatistics(org.onosproject.net.behaviour.MirroringStatistics) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

MirroringStatistics (org.onosproject.net.behaviour.MirroringStatistics)2 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 OvsdbBridge (org.onosproject.ovsdb.controller.OvsdbBridge)1 OvsdbMirror (org.onosproject.ovsdb.controller.OvsdbMirror)1 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)1 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)1 OvsdbSet (org.onosproject.ovsdb.rfc.notation.OvsdbSet)1 Row (org.onosproject.ovsdb.rfc.notation.Row)1 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)1 Bridge (org.onosproject.ovsdb.rfc.table.Bridge)1 Mirror (org.onosproject.ovsdb.rfc.table.Mirror)1