use of org.onosproject.net.behaviour.QueueDescription.Type 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.net.behaviour.QueueDescription.Type in project onos by opennetworkinglab.
the class ServerQueueConfig method getQueues.
@Override
public Collection<QueueDescription> getQueues() {
// Retrieve the device ID from the handler
DeviceId deviceId = super.getDeviceId();
checkNotNull(deviceId, MSG_DEVICE_ID_NULL);
// Get the device
RestSBDevice device = super.getDevice(deviceId);
checkNotNull(device, MSG_DEVICE_NULL);
// Hit the path that provides queue administration
InputStream response = null;
try {
response = getController().get(deviceId, URL_NIC_QUEUE_ADMIN, JSON);
} catch (ProcessingException pEx) {
log.error("Failed to get NIC queues from device: {}", deviceId);
return Collections.EMPTY_LIST;
}
// Load the JSON into object
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> jsonMap = null;
JsonNode jsonNode = null;
ObjectNode objNode = null;
try {
jsonMap = mapper.readValue(response, Map.class);
jsonNode = mapper.convertValue(jsonMap, JsonNode.class);
objNode = (ObjectNode) jsonNode;
} catch (IOException ioEx) {
log.error("Failed to get NIC queues from device: {}", deviceId);
return Collections.EMPTY_LIST;
}
if (objNode == null) {
log.error("Failed to get NIC queues from device: {}", deviceId);
return Collections.EMPTY_LIST;
}
Collection<QueueDescription> queueDescs = Sets.newHashSet();
// Fetch NICs' array
JsonNode nicsNode = objNode.path(PARAM_NICS);
for (JsonNode nn : nicsNode) {
ObjectNode nicObjNode = (ObjectNode) nn;
int nicId = nicObjNode.path(PARAM_ID).asInt();
JsonNode queuesNode = nicObjNode.path(PARAM_QUEUES);
// Each NIC has a set of queues
for (JsonNode qn : queuesNode) {
ObjectNode queueObjNode = (ObjectNode) qn;
// Get the attributes of a queue
int queueIdInt = queueObjNode.path(PARAM_ID).asInt();
String queueTypeStr = get(qn, PARAM_TYPE);
long queueRateInt = queueObjNode.path(PARAM_NIC_MAX_RATE).asLong();
QueueId queueId = QueueId.queueId("nic" + nicId + ":" + queueIdInt);
EnumSet<Type> queueTypes = getQueueTypesFromString(queueTypeStr);
Bandwidth queueRate = Bandwidth.mbps(queueRateInt);
queueDescs.add(DefaultQueueDescription.builder().queueId(queueId).type(queueTypes).maxRate(queueRate).build());
}
}
log.info("[Device {}] NIC queues: {}", deviceId, queueDescs);
return ImmutableList.copyOf(queueDescs);
}
Aggregations