e17c45dc767f5050c4113c4df96b2c6aaf170232
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / impl / StatListenCommitFlow.java
1 /**
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.statistics.manager.impl;
10
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.HashMap;
14 import java.util.Iterator;
15 import java.util.LinkedList;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.Map.Entry;
19 import java.util.concurrent.atomic.AtomicInteger;
20
21 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
22 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
23 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
24 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
25 import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
26 import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
27 import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
28 import org.opendaylight.controller.md.statistics.manager.impl.helper.FlowComparator;
29 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMapping;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMappingBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMapBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMapKey;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsDataBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.aggregate.flow.statistics.AggregateFlowStatisticsBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
60 import org.opendaylight.yangtools.yang.binding.DataObject;
61 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
62 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
63 import org.slf4j.Logger;
64 import org.slf4j.LoggerFactory;
65
66 import com.google.common.base.Optional;
67 import com.google.common.collect.BiMap;
68 import com.google.common.collect.HashBiMap;
69
70 /**
71  * statistics-manager
72  * org.opendaylight.controller.md.statistics.manager.impl
73  *
74  * StatListenCommitFlow
75  * Class is a NotifyListener for FlowStatistics and DataChangeListener for Config/DataStore for Flow node.
76  * All expected (registered) FlowStatistics will be builded and commit to Operational/DataStore.
77  * DataChangeEven should call create/delete Flow in Operational/DS create process needs to pair
78  * Device Flow HashCode and FlowId from Config/DS
79  *
80  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
81  *
82  */
83 public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, OpendaylightFlowStatisticsListener>
84                                             implements OpendaylightFlowStatisticsListener {
85
86     protected static final Logger LOG = LoggerFactory.getLogger(StatListenCommitFlow.class);
87
88     private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
89
90     private static final Integer REMOVE_AFTER_MISSING_COLLECTION = 1;
91
92     private final AtomicInteger unaccountedFlowsCounter = new AtomicInteger(0);
93
94     public StatListenCommitFlow (final StatisticsManager manager, final DataBroker db,
95             final NotificationProviderService nps){
96         super(manager, db, nps, Flow.class);
97     }
98
99     @Override
100     protected OpendaylightFlowStatisticsListener getStatNotificationListener() {
101         return this;
102     }
103
104     @Override
105     protected InstanceIdentifier<Flow> getWildCardedRegistrationPath() {
106         return InstanceIdentifier.create(Nodes.class).child(Node.class)
107                 .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
108     }
109
110     @Override
111     public void onAggregateFlowStatisticsUpdate(final AggregateFlowStatisticsUpdate notification) {
112         final TransactionId transId = notification.getTransactionId();
113         final NodeId nodeId = notification.getId();
114         if ( ! isExpectedStatistics(transId, nodeId)) {
115             LOG.debug("STAT-MANAGER - AggregateFlowStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
116             return;
117         }
118         manager.getRpcMsgManager().addNotification(notification, nodeId);
119         if (notification.isMoreReplies()) {
120             return;
121         }
122         /* check flow Capable Node and write statistics */
123         manager.enqueue(new StatDataStoreOperation() {
124             @Override
125             public void applyOperation(final ReadWriteTransaction tx) {
126
127                 final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
128                 if (( ! txContainer.isPresent()) || txContainer.get().getNotifications() == null) {
129                     return;
130                 }
131                 final Optional<? extends DataObject> inputObj = txContainer.get().getConfInput();
132                 if (( ! inputObj.isPresent()) || ( ! (inputObj.get() instanceof Table))) {
133                     return;
134                 }
135                 final Table table = (Table) inputObj.get();
136                 final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
137                 for (final TransactionAware notif : cacheNotifs) {
138                     if (notif instanceof AggregateFlowStatisticsUpdate) {
139                         final AggregateFlowStatisticsData stats = new AggregateFlowStatisticsDataBuilder()
140                             .setAggregateFlowStatistics(new AggregateFlowStatisticsBuilder(notification).build()).build();
141                         final InstanceIdentifier<FlowCapableNode> fNodeIdent = InstanceIdentifier.create(Nodes.class)
142                                 .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
143                         final InstanceIdentifier<Table> tableRef = fNodeIdent.child(Table.class, table.getKey());
144                         final InstanceIdentifier<AggregateFlowStatisticsData> tableStatRef = tableRef
145                                 .augmentation(AggregateFlowStatisticsData.class);
146                         Optional<FlowCapableNode> fNode = Optional.absent();
147                         try {
148                             fNode = tx.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
149                         } catch (final ReadFailedException e) {
150                             LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
151                             return;
152                         }
153                         if (fNode.isPresent()) {
154                             ensureTable(tx, table.getId(), tableRef);
155                             tx.put(LogicalDatastoreType.OPERATIONAL, tableStatRef, stats);
156                         }
157                     }
158                 }
159             }
160         });
161     }
162
163     public void ensureTable(final ReadWriteTransaction tx, final Short tableId, final InstanceIdentifier<Table> tableRef) {
164         final Table tableNew = new TableBuilder().setId(tableId).build();
165         tx.merge(LogicalDatastoreType.OPERATIONAL, tableRef, tableNew);
166     }
167
168     @Override
169     public void onFlowsStatisticsUpdate(final FlowsStatisticsUpdate notification) {
170         final TransactionId transId = notification.getTransactionId();
171         final NodeId nodeId = notification.getId();
172         if ( ! isExpectedStatistics(transId, nodeId)) {
173             LOG.debug("STAT-MANAGER - FlowsStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
174             return;
175         }
176         manager.getRpcMsgManager().addNotification(notification, nodeId);
177         if (notification.isMoreReplies()) {
178             LOG.trace("Next notification for join txId {}", transId);
179             return;
180         }
181         /* add flow's statistics */
182         manager.enqueue(new StatDataStoreOperation() {
183             @Override
184             public void applyOperation(final ReadWriteTransaction tx) {
185                 final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
186                 if (( ! txContainer.isPresent()) || txContainer.get().getNotifications() == null) {
187                     return;
188                 }
189                 final List<FlowAndStatisticsMapList> flowStats = new ArrayList<FlowAndStatisticsMapList>(10);
190                 final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
191                         .child(Node.class, new NodeKey(nodeId));
192                 final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
193                 for (final TransactionAware notif : cacheNotifs) {
194                     if (notif instanceof FlowsStatisticsUpdate) {
195                         final List<FlowAndStatisticsMapList> notifList =
196                                 ((FlowsStatisticsUpdate) notif).getFlowAndStatisticsMapList();
197                         if (notifList != null) {
198                             flowStats.addAll(notifList);
199                         }
200                     }
201                 }
202
203                 statsFlowCommitAll(flowStats, nodeIdent, tx);
204                 /* cleaning all not cached hash collisions */
205                 final Map<InstanceIdentifier<Flow>, Integer> listAliens = mapNodesForDelete.get(nodeIdent);
206                 if (listAliens != null) {
207                     for (final Entry<InstanceIdentifier<Flow>, Integer> nodeForDelete : listAliens.entrySet()) {
208                         final Integer lifeIndex = nodeForDelete.getValue();
209                         if (nodeForDelete.getValue() > 0) {
210                             nodeForDelete.setValue(Integer.valueOf(lifeIndex.intValue() - 1));
211                         } else {
212                             final InstanceIdentifier<Flow> flowNodeIdent = nodeForDelete.getKey();
213                             mapNodesForDelete.get(nodeIdent).remove(flowNodeIdent);
214                             tx.delete(LogicalDatastoreType.OPERATIONAL, flowNodeIdent);
215                         }
216                     }
217                 }
218                 /* Notification for continue collecting statistics */
219                 notifyToCollectNextStatistics(nodeIdent, transId);
220             }
221         });
222     }
223
224     private void statsFlowCommitAll(final List<FlowAndStatisticsMapList> list,
225             final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) {
226
227         final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
228
229         final Optional<FlowCapableNode> fNode;
230         try {
231             fNode = tx.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
232         }
233         catch (final ReadFailedException e) {
234             LOG.debug("Read FlowCapableNode {} in Operational/DS fail! Statistic scan not be updated.", nodeIdent, e);
235             return;
236         }
237         if ( ! fNode.isPresent()) {
238             LOG.trace("FlowCapableNode {} is not presented in Operational/DS. Statisticscan not be updated.", nodeIdent);
239             return;
240         }
241
242         final NodeUpdateState nodeState = new NodeUpdateState(fNodeIdent,fNode.get());
243
244         for (final FlowAndStatisticsMapList flowStat : list) {
245             final TableKey tableKey = new TableKey(flowStat.getTableId());
246             final TableFlowUpdateState tableState = nodeState.getTable(tableKey, tx);
247             tableState.reportFlow(flowStat,tx);
248         }
249
250         for (final TableFlowUpdateState table : nodeState.getTables()) {
251             table.removeUnreportedFlows(tx);
252         }
253     }
254
255     /**
256      * Method adds statistics to Flow
257      *
258      * @param flowBuilder
259      * @param deviceFlow
260      */
261     private void addStatistics(final FlowBuilder flowBuilder, final FlowAndStatisticsMapList deviceFlow) {
262         final FlowAndStatisticsMapListBuilder stats = new FlowAndStatisticsMapListBuilder(deviceFlow);
263         final FlowStatisticsBuilder flowStatisticsBuilder = new FlowStatisticsBuilder(stats.build());
264         final FlowStatisticsDataBuilder flowStatisticsData =new FlowStatisticsDataBuilder();
265         flowStatisticsData.setFlowStatistics(flowStatisticsBuilder.build());
266         flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
267     }
268
269     /**
270      * build pseudoUnique hashCode for flow in table
271      * for future easy identification
272      *
273      * FIXME: we expect same version for YANG models for all clusters and that has to be fix
274      * FIXME: CREATE BETTER KEY - for flow (MATCH is the problem)
275      */
276     static String buildFlowIdOperKey(final FlowAndStatisticsMapList deviceFlow) {
277         return new StringBuffer().append(deviceFlow.getMatch())
278                 .append(deviceFlow.getPriority()).append(deviceFlow.getCookie().getValue()).toString();
279     }
280
281     private class NodeUpdateState {
282         private final InstanceIdentifier<FlowCapableNode> nodeIdentifier;
283         private final Map<TableKey,TableFlowUpdateState> tables = new HashMap<>();
284
285         public NodeUpdateState(final InstanceIdentifier<FlowCapableNode> fNodeIdent, final FlowCapableNode flowCapableNode) {
286             nodeIdentifier = fNodeIdent;
287             final List<Table> tableList = flowCapableNode.getTable();
288             if(tableList != null) {
289             for (final Table table : tableList) {
290                 final TableKey tableKey = table.getKey();
291                     tables.put(tableKey, new TableFlowUpdateState(nodeIdentifier.child(Table.class,tableKey),table));
292                 }
293             }
294         }
295
296         public Iterable<TableFlowUpdateState> getTables() {
297             return tables.values();
298         }
299
300         TableFlowUpdateState getTable(final TableKey key,final ReadWriteTransaction tx) {
301             TableFlowUpdateState table = tables.get(key);
302             if(table == null) {
303                 table = new TableFlowUpdateState(nodeIdentifier.child(Table.class, key), null);
304                 tables.put(key, table);
305             }
306             return table;
307         }
308     }
309
310     private class TableFlowUpdateState {
311
312         private boolean tableEnsured = false;
313         final KeyedInstanceIdentifier<Table, TableKey> tableRef;
314         final TableKey tableKey;
315         final BiMap<FlowHashIdMapKey, FlowId> flowIdByHash;
316         List<Flow> configFlows;
317
318         public TableFlowUpdateState(final KeyedInstanceIdentifier<Table, TableKey> tablePath, final Table table) {
319             tableRef = tablePath;
320             tableKey = tablePath.getKey();
321             flowIdByHash = HashBiMap.create();
322             if(table != null) {
323                 final FlowHashIdMapping flowHashMapping = table.getAugmentation(FlowHashIdMapping.class);
324                 if (flowHashMapping != null) {
325                     final List<FlowHashIdMap>  flowHashMap = flowHashMapping.getFlowHashIdMap() != null
326                             ? flowHashMapping.getFlowHashIdMap() : Collections.<FlowHashIdMap> emptyList();
327                     for (final FlowHashIdMap flowHashId : flowHashMap) {
328                         try {
329                             flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId());
330                         } catch (final Exception e) {
331                             LOG.warn("flow hashing hit a duplicate for {} -> {}", flowHashId.getKey(), flowHashId.getFlowId());
332                         }
333                     }
334                 }
335             }
336         }
337
338         private void ensureTableFowHashIdMapping(final ReadWriteTransaction tx) {
339             if( ! tableEnsured) {
340                 ensureTable(tx, tableKey.getId(), tableRef);
341                 final FlowHashIdMapping emptyMapping = new FlowHashIdMappingBuilder()
342                     .setFlowHashIdMap(Collections.<FlowHashIdMap> emptyList()).build();
343                 tx.merge(LogicalDatastoreType.OPERATIONAL, tableRef.augmentation(FlowHashIdMapping.class), emptyMapping);
344                 tableEnsured = true;
345             }
346         }
347
348         private FlowKey searchInConfiguration(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) {
349             initConfigFlows(trans);
350             final Iterator<Flow> it = configFlows.iterator();
351             while(it.hasNext()) {
352                 final Flow cfgFlow = it.next();
353                 final FlowKey cfgKey = cfgFlow.getKey();
354                 if(flowIdByHash.inverse().containsKey(cfgKey)) {
355                     it.remove();
356                 } else if(FlowComparator.flowEquals(flowStat, cfgFlow)) {
357                     it.remove();
358                     return cfgKey;
359                 }
360             }
361             return null;
362         }
363
364         private void initConfigFlows(final ReadWriteTransaction trans) {
365             final Optional<Table> table = readLatestConfiguration(tableRef);
366             List<Flow> localList = null;
367             if(table.isPresent()) {
368                 localList = table.get().getFlow();
369             }
370             if(localList == null) {
371                 configFlows = Collections.emptyList();
372             } else {
373                 configFlows = new LinkedList<>(localList);
374             }
375         }
376
377         private FlowKey getFlowKeyAndRemoveHash(final FlowHashIdMapKey key) {
378             final FlowId ret = flowIdByHash.get(key);
379             if(ret != null) {
380                 flowIdByHash.remove(key);
381                 return new FlowKey(ret);
382             }
383             return null;
384         }
385
386         /* Returns FlowKey which doesn't exist in any DataStore for now */
387         private FlowKey makeAlienFlowKey() {
388             final StringBuilder sBuilder = new StringBuilder(ALIEN_SYSTEM_FLOW_ID)
389                 .append(tableKey.getId()).append("-").append(unaccountedFlowsCounter.incrementAndGet());
390             final FlowId flowId = new FlowId(sBuilder.toString());
391             return new FlowKey(flowId);
392         }
393
394         private Map<FlowHashIdMapKey, FlowId> getRemovalList() {
395             return flowIdByHash;
396         }
397
398         void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) {
399             ensureTableFowHashIdMapping(trans);
400             final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat));
401             FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey);
402             if (flowKey == null) {
403                 flowKey = searchInConfiguration(flowStat, trans);
404                 if ( flowKey == null) {
405                     flowKey = makeAlienFlowKey();
406                 }
407                 updateHashCache(trans,flowKey,hashingKey);
408             }
409             final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
410             flowBuilder.setKey(flowKey);
411             addStatistics(flowBuilder, flowStat);
412             final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey);
413             trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
414             /* check life for Alien flows */
415             if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) {
416                 removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION);
417             }
418         }
419
420         /* Build and deploy new FlowHashId map */
421         private void updateHashCache(final ReadWriteTransaction trans, final FlowKey flowKey, final FlowHashIdMapKey hashingKey) {
422             final FlowHashIdMapBuilder flHashIdMap = new FlowHashIdMapBuilder();
423             flHashIdMap.setFlowId(flowKey.getId());
424             flHashIdMap.setKey(hashingKey);
425             final KeyedInstanceIdentifier<FlowHashIdMap, FlowHashIdMapKey> flHashIdent = tableRef
426                     .augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, hashingKey);
427             /* Add new FlowHashIdMap */
428             trans.put(LogicalDatastoreType.OPERATIONAL, flHashIdent, flHashIdMap.build());
429         }
430
431         void removeUnreportedFlows(final ReadWriteTransaction tx) {
432             final InstanceIdentifier<Node> nodeIdent = tableRef.firstIdentifierOf(Node.class);
433             final List<InstanceIdentifier<Flow>> listMissingConfigFlows = notStatReportedConfigFlows();
434             final Map<InstanceIdentifier<Flow>, Integer> nodeDeleteMap = mapNodesForDelete.get(nodeIdent);
435             final Map<FlowHashIdMapKey, FlowId> listForRemove = getRemovalList();
436             for (final Entry<FlowHashIdMapKey, FlowId> entryForRemove : listForRemove.entrySet()) {
437                 final FlowKey flowKey = new FlowKey(entryForRemove.getValue());
438                 final InstanceIdentifier<Flow> flowRef = tableRef.child(Flow.class, flowKey);
439                 if (nodeDeleteMap != null && flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) {
440                     final Integer lifeIndex = nodeDeleteMap.get(flowRef);
441                     if (lifeIndex > 0) {
442                         break;
443                     } else {
444                         nodeDeleteMap.remove(flowRef);
445                     }
446                 } else {
447                     if (listMissingConfigFlows.remove(flowRef)) {
448                         break; // we probably lost some multipart msg
449                     }
450                 }
451                 final InstanceIdentifier<FlowHashIdMap> flHashIdent =
452                         tableRef.augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, entryForRemove.getKey());
453                 tx.delete(LogicalDatastoreType.OPERATIONAL, flowRef);
454                 tx.delete(LogicalDatastoreType.OPERATIONAL, flHashIdent);
455             }
456         }
457
458         List<InstanceIdentifier<Flow>> notStatReportedConfigFlows() {
459             if (configFlows != null) {
460                 final List<InstanceIdentifier<Flow>> returnList = new ArrayList<>(configFlows.size());
461                 for (final Flow confFlow : configFlows) {
462                     final InstanceIdentifier<Flow> confFlowIdent = tableRef.child(Flow.class, confFlow.getKey());
463                     returnList.add(confFlowIdent);
464                 }
465                 return returnList;
466             }
467             return Collections.emptyList();
468         }
469     }
470 }
471