Search in sources :

Example 1 with OFTableStatsReply

use of org.projectfloodlight.openflow.protocol.OFTableStatsReply 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());
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) OfTableStatsMapper(org.openkilda.floodlight.converter.OfTableStatsMapper) OFStatsReply(org.projectfloodlight.openflow.protocol.OFStatsReply) OFPortStatsRequest(org.projectfloodlight.openflow.protocol.OFPortStatsRequest) OFFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFFlowStatsRequest) LoggerFactory(org.slf4j.LoggerFactory) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OfFlowStatsMapper(org.openkilda.floodlight.converter.OfFlowStatsMapper) Map(java.util.Map) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) Collection(java.util.Collection) Set(java.util.Set) InfoData(org.openkilda.messaging.info.InfoData) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) OFTableStatsRequest(org.projectfloodlight.openflow.protocol.OFTableStatsRequest) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) OFPort(org.projectfloodlight.openflow.types.OFPort) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) List(java.util.List) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) OfPortStatsMapper(org.openkilda.floodlight.converter.OfPortStatsMapper) OFGroup(org.projectfloodlight.openflow.types.OFGroup) OFVersion(org.projectfloodlight.openflow.protocol.OFVersion) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) SwitchTableStatsData(org.openkilda.messaging.info.stats.SwitchTableStatsData) ImmutableList(com.google.common.collect.ImmutableList) OFTableStatsReply(org.projectfloodlight.openflow.protocol.OFTableStatsReply) TableStatsEntry(org.openkilda.messaging.info.stats.TableStatsEntry) Logger(org.slf4j.Logger) CorrelationContextClosable(org.openkilda.floodlight.utils.CorrelationContext.CorrelationContextClosable) IFloodlightModule(net.floodlightcontroller.core.module.IFloodlightModule) FutureCallback(com.google.common.util.concurrent.FutureCallback) OFMeterStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterStatsRequest) Futures(com.google.common.util.concurrent.Futures) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired) SwitchId(org.openkilda.model.SwitchId) OfMeterStatsMapper(org.openkilda.floodlight.converter.OfMeterStatsMapper) IFloodlightService(net.floodlightcontroller.core.module.IFloodlightService) Destination(org.openkilda.messaging.Destination) NumberUtils(org.apache.commons.lang3.math.NumberUtils) DatapathId(org.projectfloodlight.openflow.types.DatapathId) Collections(java.util.Collections) IThreadPoolService(net.floodlightcontroller.threadpool.IThreadPoolService) OFTableStatsReply(org.projectfloodlight.openflow.protocol.OFTableStatsReply) InfoData(org.openkilda.messaging.info.InfoData) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) SwitchId(org.openkilda.model.SwitchId) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) OFTableStatsRequest(org.projectfloodlight.openflow.protocol.OFTableStatsRequest) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)1 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)1 IFloodlightModule (net.floodlightcontroller.core.module.IFloodlightModule)1 IFloodlightService (net.floodlightcontroller.core.module.IFloodlightService)1 IThreadPoolService (net.floodlightcontroller.threadpool.IThreadPoolService)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1