use of org.projectfloodlight.openflow.protocol.OFTableStatsRequest in project open-kilda by telstra.
the class StatisticsService method gatherTableStats.
@NewCorrelationContextRequired
private void gatherTableStats(IOFSwitch iofSwitch) {
final SwitchId switchId = new SwitchId(iofSwitch.getId().getLong());
OFFactory factory = iofSwitch.getOFFactory();
OFTableStatsRequest flowStatsRequest = factory.buildTableStatsRequest().build();
logger.info("Getting table stats for switch={} OF-xid:{}", iofSwitch.getId(), flowStatsRequest.getXid());
if (factory.getVersion().compareTo(OFVersion.OF_13) >= 0) {
Function<List<OFTableStatsReply>, InfoData> converter = (response) -> {
List<TableStatsEntry> tableEntries = response.stream().filter(reply -> CollectionUtils.isNotEmpty(reply.getEntries())).map(OFTableStatsReply::getEntries).flatMap(List::stream).filter(entry -> entry.getActiveCount() != NumberUtils.LONG_ZERO).map(OfTableStatsMapper.INSTANCE::toTableStatsEntry).collect(Collectors.toList());
return SwitchTableStatsData.builder().switchId(switchId).tableStatsEntries(tableEntries).build();
};
RequestCallback<OFTableStatsReply> callback = new RequestCallback<>(converter, switchId, "table");
Futures.addCallback(iofSwitch.writeStatsRequest(flowStatsRequest), callback, directExecutor());
}
}
Aggregations