Search in sources :

Example 1 with OvsdbQos

use of org.onosproject.ovsdb.controller.OvsdbQos in project onos by opennetworkinglab.

the class OvsdbQosConfig method addQoS.

@Override
public boolean addQoS(QosDescription qos) {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    OvsdbQos ovsdbQos = OvsdbQos.builder(qos).build();
    return ovsdbClient.createQos(ovsdbQos);
}
Also used : OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService)

Example 2 with OvsdbQos

use of org.onosproject.ovsdb.controller.OvsdbQos in project onos by opennetworkinglab.

the class DefaultOvsdbClient method createQos.

@Override
public boolean createQos(OvsdbQos ovsdbQos) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Qos qos = (Qos) TableGenerator.createTable(dbSchema, OvsdbTable.QOS);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
    if (rowStore == null) {
        log.debug("The qos uuid is null");
        return false;
    }
    ArrayList<Operation> operations = Lists.newArrayList();
    Set<String> types = Sets.newHashSet();
    Map<Long, Uuid> queues = Maps.newHashMap();
    types.add(ovsdbQos.qosType());
    qos.setOtherConfig(ovsdbQos.otherConfigs());
    qos.setExternalIds(ovsdbQos.externalIds());
    qos.setType(types);
    if (ovsdbQos.qosQueues().isPresent()) {
        for (Map.Entry<Long, String> entry : ovsdbQos.qosQueues().get().entrySet()) {
            OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
            if (queueRowStore != null) {
                ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
                Row queueRow = queueTableRows.values().stream().filter(r -> {
                    OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
                    return entry.getValue().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
                }).findFirst().orElse(null);
                if (queueRow != null) {
                    queues.put(entry.getKey(), queueRow.uuid());
                }
            }
        }
        qos.setQueues(queues);
    }
    Insert qosInsert = new Insert(dbSchema.getTableSchema(QOS), QOS, qos.getRow());
    operations.add(qosInsert);
    try {
        transactConfig(DATABASENAME, operations).get();
    } catch (InterruptedException | ExecutionException e) {
        return false;
    }
    return true;
}
Also used : Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Insert(org.onosproject.ovsdb.rfc.operations.Insert) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Qos(org.onosproject.ovsdb.rfc.table.Qos) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Row(org.onosproject.ovsdb.rfc.notation.Row) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 3 with OvsdbQos

use of org.onosproject.ovsdb.controller.OvsdbQos in project onos by opennetworkinglab.

the class OvsdbQosConfig method getQoses.

@Override
public Collection<QosDescription> getQoses() {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    if (ovsdbClient == null) {
        return null;
    }
    Set<OvsdbQos> qoses = ovsdbClient.getQoses();
    return qoses.stream().map(qos -> DefaultQosDescription.builder().qosId(QosId.qosId(qos.externalIds().get(QOS_EXTERNAL_ID_KEY))).type(QOS_EGRESS_POLICER.equals(qos.qosType()) ? QosDescription.Type.EGRESS_POLICER : QosDescription.Type.valueOf(qos.qosType().replace(QOS_TYPE_PREFIX, "").toUpperCase())).maxRate(qos.otherConfigs().get(MAX_RATE) != null ? Bandwidth.bps(Long.parseLong(qos.otherConfigs().get(MAX_RATE))) : Bandwidth.bps(0L)).cbs(qos.otherConfigs().get(CBS) != null ? Long.valueOf(qos.otherConfigs().get(CBS)) : null).cir(qos.otherConfigs().get(CIR) != null ? Long.valueOf(qos.otherConfigs().get(CIR)) : null).build()).collect(Collectors.toSet());
}
Also used : OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) QOS_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QOS_EXTERNAL_ID_KEY) QOS_TYPE_PREFIX(org.onosproject.ovsdb.controller.OvsdbConstant.QOS_TYPE_PREFIX) QOS_EGRESS_POLICER(org.onosproject.ovsdb.controller.OvsdbConstant.QOS_EGRESS_POLICER) QosDescription(org.onosproject.net.behaviour.QosDescription) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) CBS(org.onosproject.ovsdb.controller.OvsdbConstant.CBS) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Map(java.util.Map) QosConfigBehaviour(org.onosproject.net.behaviour.QosConfigBehaviour) IpAddress(org.onlab.packet.IpAddress) QosId(org.onosproject.net.behaviour.QosId) Logger(org.slf4j.Logger) Bandwidth(org.onlab.util.Bandwidth) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultQosDescription(org.onosproject.net.behaviour.DefaultQosDescription) QueueDescription(org.onosproject.net.behaviour.QueueDescription) MAX_RATE(org.onosproject.ovsdb.controller.OvsdbConstant.MAX_RATE) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) CIR(org.onosproject.ovsdb.controller.OvsdbConstant.CIR) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceId(org.onosproject.net.DeviceId) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService)

Example 4 with OvsdbQos

use of org.onosproject.ovsdb.controller.OvsdbQos in project onos by opennetworkinglab.

the class OvsdbQosConfig method getQos.

@Override
public QosDescription getQos(QosDescription qosDesc) {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    if (ovsdbClient == null) {
        return null;
    }
    OvsdbQos qos = ovsdbClient.getQos(qosDesc.qosId());
    if (qos == null) {
        return null;
    }
    return DefaultQosDescription.builder().qosId(QosId.qosId(qos.externalIds().get(QOS_EXTERNAL_ID_KEY))).type(QOS_EGRESS_POLICER.equals(qos.qosType()) ? QosDescription.Type.EGRESS_POLICER : QosDescription.Type.valueOf(qos.qosType().replace(QOS_TYPE_PREFIX, "").toUpperCase())).maxRate(qos.otherConfigs().get(MAX_RATE) != null ? Bandwidth.bps(Long.parseLong(qos.otherConfigs().get(MAX_RATE))) : Bandwidth.bps(0L)).cbs(qos.otherConfigs().get(CBS) != null ? Long.valueOf(qos.otherConfigs().get(CBS)) : null).cir(qos.otherConfigs().get(CIR) != null ? Long.valueOf(qos.otherConfigs().get(CIR)) : null).build();
}
Also used : OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService)

Example 5 with OvsdbQos

use of org.onosproject.ovsdb.controller.OvsdbQos in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getQoses.

@Override
public Set<OvsdbQos> getQoses() {
    Set<OvsdbQos> ovsdbQoses = new HashSet<>();
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
    if (rowStore == null) {
        log.debug("The qos uuid is null");
        return ovsdbQoses;
    }
    ConcurrentMap<String, Row> rows = rowStore.getRowStore();
    ovsdbQoses = rows.keySet().stream().map(uuid -> getRow(DATABASENAME, QOS, uuid)).map(this::getOvsdbQos).filter(Objects::nonNull).collect(Collectors.toSet());
    return ovsdbQoses;
}
Also used : OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) Objects(java.util.Objects) Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) HashSet(java.util.HashSet)

Aggregations

OvsdbQos (org.onosproject.ovsdb.controller.OvsdbQos)6 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)3 Map (java.util.Map)2 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)2 Row (org.onosproject.ovsdb.rfc.notation.Row)2 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)2 Qos (org.onosproject.ovsdb.rfc.table.Qos)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Collectors (java.util.stream.Collectors)1 IpAddress (org.onlab.packet.IpAddress)1 Bandwidth (org.onlab.util.Bandwidth)1 DeviceId (org.onosproject.net.DeviceId)1 DefaultQosDescription (org.onosproject.net.behaviour.DefaultQosDescription)1