Search in sources :

Example 1 with OFGroupDescStatsRequest

use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest in project open-kilda by telstra.

the class SwitchManager method dumpGroups.

private List<OFGroupDescStatsEntry> dumpGroups(IOFSwitch sw) {
    OFFactory ofFactory = sw.getOFFactory();
    OFGroupDescStatsRequest groupRequest = ofFactory.buildGroupDescStatsRequest().build();
    List<OFGroupDescStatsReply> replies;
    try {
        ListenableFuture<List<OFGroupDescStatsReply>> future = sw.writeStatsRequest(groupRequest);
        replies = future.get(10, TimeUnit.SECONDS);
    } catch (ExecutionException | TimeoutException e) {
        logger.error("Could not dump groups on switch {}.", sw.getId(), e);
        return Collections.emptyList();
    } catch (InterruptedException e) {
        logger.error("Could not dump groups on switch {}.", sw.getId(), e);
        Thread.currentThread().interrupt();
        return Collections.emptyList();
    }
    return replies.stream().map(OFGroupDescStatsReply::getEntries).flatMap(List::stream).collect(toList());
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) ExecutionException(java.util.concurrent.ExecutionException) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Collectors.toList (java.util.stream.Collectors.toList)1 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)1 OFGroupDescStatsReply (org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply)1 OFGroupDescStatsRequest (org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest)1