use of org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply in project open-kilda by telstra.
the class SwitchManager method dumpMeters.
/**
* {@inheritDoc}
*/
@Override
public OFMeterConfigStatsReply dumpMeters(final DatapathId dpid) throws SwitchOperationException {
OFMeterConfigStatsReply values = null;
IOFSwitch sw = lookupSwitch(dpid);
if (sw == null) {
throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
}
OFFactory ofFactory = sw.getOFFactory();
OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest().setMeterId(0xffffffff).build();
try {
ListenableFuture<OFMeterConfigStatsReply> future = sw.writeRequest(meterRequest);
values = future.get(5, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
logger.error("Could not get meter config stats: {}", e.getMessage());
}
return values;
}
use of org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply in project open-kilda by telstra.
the class MetersResource method getMeters.
// FIXME(surabujin): is it used anywhere?
@Get("json")
@SuppressWarnings("unchecked")
public Map<Long, Object> getMeters() {
Map<Long, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get meters for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes().get(ISwitchManager.class.getCanonicalName());
try {
OFMeterConfigStatsReply replay = switchManager.dumpMeters(DatapathId.of(switchId));
logger.debug("Meters from switch {} received: {}", switchId, replay);
if (replay != null) {
for (OFMeterConfig entry : replay.getEntries()) {
response.put(entry.getMeterId(), entry);
}
}
} catch (IllegalArgumentException | SwitchOperationException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
}
return response;
}
Aggregations