Search in sources :

Example 1 with OvsdbQueue

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

the class OvsdbQueueConfig method getQueue.

@Override
public QueueDescription getQueue(QueueDescription queueDesc) {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    if (ovsdbClient == null) {
        return null;
    }
    OvsdbQueue queue = ovsdbClient.getQueue(queueDesc.queueId());
    if (queue == null) {
        return null;
    }
    return DefaultQueueDescription.builder().queueId(QueueId.queueId(queue.externalIds().get(QUEUE_EXTERNAL_ID_KEY))).type(types(queue)).dscp(queue.dscp().isPresent() ? queue.dscp().get().intValue() : null).maxRate(queue.otherConfigs().get(MAX_RATE) != null ? Bandwidth.bps(Long.parseLong(queue.otherConfigs().get(MAX_RATE))) : Bandwidth.bps(0L)).minRate(queue.otherConfigs().get(MIN_RATE) != null ? Bandwidth.bps(Long.parseLong(queue.otherConfigs().get(MIN_RATE))) : Bandwidth.bps(0L)).burst(queue.otherConfigs().get(BURST) != null ? Long.valueOf(queue.otherConfigs().get(BURST)) : 0L).priority(queue.otherConfigs().get(PRIORITY) != null ? Long.valueOf(queue.otherConfigs().get(PRIORITY)) : 0L).build();
}
Also used : OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue)

Example 2 with OvsdbQueue

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

the class OvsdbQueueConfig method getQueues.

@Override
public Collection<QueueDescription> getQueues() {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    if (ovsdbClient == null) {
        return Collections.emptyList();
    }
    Set<OvsdbQueue> queues = ovsdbClient.getQueues();
    return queues.stream().map(q -> DefaultQueueDescription.builder().queueId(QueueId.queueId(q.externalIds().get(QUEUE_EXTERNAL_ID_KEY))).type(types(q)).dscp(q.dscp().isPresent() ? q.dscp().get().intValue() : null).maxRate(q.otherConfigs().get(MAX_RATE) != null ? Bandwidth.bps(Long.parseLong(q.otherConfigs().get(MAX_RATE))) : Bandwidth.bps(0L)).minRate(q.otherConfigs().get(MIN_RATE) != null ? Bandwidth.bps(Long.parseLong(q.otherConfigs().get(MIN_RATE))) : Bandwidth.bps(0L)).burst(q.otherConfigs().get(BURST) != null ? Long.valueOf(q.otherConfigs().get(BURST)) : 0L).priority(q.otherConfigs().get(PRIORITY) != null ? Long.valueOf(q.otherConfigs().get(PRIORITY)) : 0L).build()).collect(Collectors.toSet());
}
Also used : QUEUE_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUE_EXTERNAL_ID_KEY) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) QueueId(org.onosproject.net.behaviour.QueueId) MIN_RATE(org.onosproject.ovsdb.controller.OvsdbConstant.MIN_RATE) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) DefaultQueueDescription(org.onosproject.net.behaviour.DefaultQueueDescription) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) BURST(org.onosproject.ovsdb.controller.OvsdbConstant.BURST) PRIORITY(org.onosproject.ovsdb.controller.OvsdbConstant.PRIORITY) EnumSet(java.util.EnumSet) IpAddress(org.onlab.packet.IpAddress) Logger(org.slf4j.Logger) Bandwidth(org.onlab.util.Bandwidth) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) DriverHandler(org.onosproject.net.driver.DriverHandler) QueueDescription(org.onosproject.net.behaviour.QueueDescription) Type(org.onosproject.net.behaviour.QueueDescription.Type) MAX_RATE(org.onosproject.ovsdb.controller.OvsdbConstant.MAX_RATE) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) QueueConfigBehaviour(org.onosproject.net.behaviour.QueueConfigBehaviour) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue)

Example 3 with OvsdbQueue

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

the class DefaultOvsdbClient method getOvsdbQueue.

private OvsdbQueue getOvsdbQueue(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Queue queue = (Queue) TableGenerator.getTable(dbSchema, row, OvsdbTable.QUEUE);
    if (queue == null) {
        return null;
    }
    OvsdbSet dscpOvsdbSet = ((OvsdbSet) queue.getDscpColumn().data());
    Set dscpSet = dscpOvsdbSet.set();
    Long dscp = null;
    if (dscpSet != null && !dscpSet.isEmpty()) {
        dscp = Long.valueOf(dscpSet.toArray()[0].toString());
    }
    Map<String, String> otherConfigs;
    Map<String, String> externalIds;
    otherConfigs = ((OvsdbMap) queue.getOtherConfigColumn().data()).map();
    externalIds = ((OvsdbMap) queue.getExternalIdsColumn().data()).map();
    return OvsdbQueue.builder().dscp(dscp).otherConfigs(otherConfigs).externalIds(externalIds).build();
}
Also used : OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Queue(org.onosproject.ovsdb.rfc.table.Queue) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 4 with OvsdbQueue

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

the class OvsdbQueueConfig method addQueue.

@Override
public boolean addQueue(QueueDescription queue) {
    OvsdbClientService ovsdbClient = getOvsdbClient(handler());
    OvsdbQueue ovsdbQueue = OvsdbQueue.builder(queue).build();
    return ovsdbClient.createQueue(ovsdbQueue);
}
Also used : OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue)

Example 5 with OvsdbQueue

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

the class DefaultOvsdbClient method createQueue.

@Override
public boolean createQueue(OvsdbQueue ovsdbQueue) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Queue queue = (Queue) TableGenerator.createTable(dbSchema, OvsdbTable.QUEUE);
    ArrayList<Operation> operations = Lists.newArrayList();
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QUEUE);
    if (rowStore == null) {
        log.debug("The queue uuid is null");
        return false;
    }
    if (ovsdbQueue.dscp().isPresent()) {
        queue.setDscp(ImmutableSet.of(ovsdbQueue.dscp().get()));
    }
    queue.setOtherConfig(ovsdbQueue.otherConfigs());
    queue.setExternalIds(ovsdbQueue.externalIds());
    Insert queueInsert = new Insert(dbSchema.getTableSchema(QUEUE), QUEUE, queue.getRow());
    operations.add(queueInsert);
    try {
        transactConfig(DATABASENAME, operations).get();
    } catch (InterruptedException | ExecutionException e) {
        log.error("createQueue transactConfig get exception !");
    }
    return true;
}
Also used : Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Insert(org.onosproject.ovsdb.rfc.operations.Insert) ExecutionException(java.util.concurrent.ExecutionException) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Queue(org.onosproject.ovsdb.rfc.table.Queue) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

OvsdbQueue (org.onosproject.ovsdb.controller.OvsdbQueue)6 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)2 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)2 Queue (org.onosproject.ovsdb.rfc.table.Queue)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 Objects (java.util.Objects)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 DefaultQueueDescription (org.onosproject.net.behaviour.DefaultQueueDescription)1 QueueConfigBehaviour (org.onosproject.net.behaviour.QueueConfigBehaviour)1 QueueDescription (org.onosproject.net.behaviour.QueueDescription)1