use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyFlowCase flowCase = mock(MultipartReplyFlowCase.class);
final MultipartReplyFlow flow = mock(MultipartReplyFlow.class);
final FlowStats flowStat = new FlowStatsBuilder().setDurationSec(1L).setDurationNsec(1L).setTableId(TABLE_NO).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setFlags(mock(FlowModFlags.class)).setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder().setMatchEntry(Collections.emptyList()).build()).build();
final List<FlowStats> flowStats = Collections.singletonList(flowStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(flow.getFlowStats()).thenReturn(flowStats);
when(flowCase.getMultipartReplyFlow()).thenReturn(flow);
when(reply.getMultipartReplyBody()).thenReturn(flowCase);
final GetFlowStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
assertEquals(stats.getTableId(), TABLE_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final FlowAndStatisticsMapList flowStat = new FlowAndStatisticsMapListBuilder().setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setTableId(TABLE_NO).setByteCount(new Counter64(BigInteger.ONE)).setPacketCount(new Counter64(BigInteger.ONE)).setFlags(new FlowModFlags(true, false, false, false, false)).setMatch(new MatchBuilder().build()).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyFlowStatsBuilder().setFlowAndStatisticsMapList(Collections.singletonList(flowStat)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetFlowStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
assertEquals(stats.getTableId(), TABLE_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap in project genius by opendaylight.
the class NodeConnectorStatsImpl method processFlowStatistics.
/**
* This method processes FlowStatistics RPC result.
* It performs:
* - fetches all flows of node
* - stores flows count per table in local map
* - creates/updates Flow table counters using Infrautils metrics API
* - set counter with values fetched from FlowStatistics
*/
private void processFlowStatistics(GetFlowStatisticsOutput flowStatsOutput, BigInteger dpid) {
Map<Short, AtomicInteger> flowTableMap = new HashMap<>();
// Get all flows for node from RPC result
List<FlowAndStatisticsMapList> flowTableAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
for (FlowAndStatisticsMapList flowAndStatisticsMap : flowTableAndStatisticsMapList) {
short tableId = flowAndStatisticsMap.getTableId();
// populate map to maintain flow count per table
flowTableMap.computeIfAbsent(tableId, key -> new AtomicInteger(0)).incrementAndGet();
}
LOG.trace("FlowTableStatistics (tableId:counter): {} for node: {}", flowTableMap.entrySet(), dpid.toString());
for (Map.Entry<Short, AtomicInteger> flowTable : flowTableMap.entrySet()) {
Short tableId = flowTable.getKey();
AtomicInteger flowCount = flowTable.getValue();
Counter counter = getCounter(CounterConstants.IFM_FLOW_TBL_COUNTER_FLOWS_PER_TBL, dpid, null, null, tableId.toString());
// update counter value
updateCounter(counter, flowCount.longValue());
}
}
Aggregations