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