use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.
the class FlowTableStatNotificationSupplierImpl method createNotification.
@Override
public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics, final InstanceIdentifier<FlowTableStatistics> path) {
Preconditions.checkArgument(flowTableStatistics != null);
Preconditions.checkArgument(path != null);
final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
ftsmBuilder.setKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class, TableKey.class).getId())));
final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
builder.setId(getNodeId(path));
builder.setMoreReplies(Boolean.FALSE);
// NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
builder.setNodeConnector(Collections.<NodeConnector>emptyList());
builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.
the class FlowTableStatNotificationSupplierImplTest method testCreateChangeEvent.
@Test
public void testCreateChangeEvent() {
final TestData testData = new TestData(createTestFlowTableStatPath(), null, createTestFlowTableStat(), DataObjectModification.ModificationType.WRITE);
Collection<DataTreeModification<FlowTableStatistics>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
verify(notifProviderService, times(1)).publish(Matchers.any(FlowTableStatisticsUpdate.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_table.
@Test
public void testGatherStatistics_table() throws Exception {
final MultipartType type = MultipartType.OFPMPTABLE;
final TableStatsBuilder tableStatsBld = new TableStatsBuilder().setActiveCount(33L).setLookupCount(BigInteger.valueOf(34L)).setMatchedCount(BigInteger.valueOf(35L)).setTableId((short) 0);
final MultipartReplyTableBuilder mpReplyTableBld = new MultipartReplyTableBuilder();
mpReplyTableBld.setTableStats(Lists.newArrayList(tableStatsBld.build()));
final MultipartReplyTableCaseBuilder mpReplyTableCaseBld = new MultipartReplyTableCaseBuilder();
mpReplyTableCaseBld.setMultipartReplyTable(mpReplyTableBld.build());
final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyTableCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
fireAndCheck(type, statsData);
final InstanceIdentifier<FlowTableStatistics> tablePath = dummyNodePath.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0)).augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(tablePath), Matchers.any(FlowTableStatistics.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics 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