2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.applications.frm.impl;
12 import java.util.concurrent.atomic.AtomicInteger;
13 import com.google.common.base.Optional;
14 import com.google.common.base.Preconditions;
15 import com.google.common.collect.ImmutableList;
16 import com.google.common.collect.Iterables;
17 import com.google.common.collect.Lists;
18 import com.google.common.util.concurrent.CheckedFuture;
19 import com.google.common.util.concurrent.FutureCallback;
20 import com.google.common.util.concurrent.Futures;
22 import java.util.concurrent.Callable;
24 import org.opendaylight.controller.md.sal.binding.api.*;
25 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
26 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
27 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
28 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
29 import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation;
30 import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
31 import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
65 import org.opendaylight.yangtools.concepts.ListenerRegistration;
66 import org.opendaylight.yangtools.yang.binding.DataObject;
67 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
68 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
72 import javax.annotation.Nonnull;
76 * forwardingrules-manager
77 * org.opendaylight.openflowplugin.applications.frm
79 * FlowNode Reconciliation Listener
80 * Reconciliation for a new FlowNode
82 * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
84 * Created: Jun 13, 2014
86 public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
88 private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconciliationImpl.class);
90 private final DataBroker dataBroker;
92 private final ForwardingRulesManager provider;
93 public static final String SEPARATOR = ":";
95 private ListenerRegistration<FlowNodeReconciliationImpl> listenerRegistration;
97 private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE
98 = InstanceIdentifier.builder(Nodes.class)
100 .augmentation(FlowCapableNode.class)
103 public FlowNodeReconciliationImpl (final ForwardingRulesManager manager, final DataBroker db) {
104 this.provider = Preconditions.checkNotNull(manager, "ForwardingRulesManager can not be null!");
105 dataBroker = Preconditions.checkNotNull(db, "DataBroker can not be null!");
107 final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
108 .child(Node.class).augmentation(FlowCapableNode.class);
110 final DataTreeIdentifier<FlowCapableNode> treeId =
111 new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
114 SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
115 ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
117 listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<FlowNodeReconciliationImpl>>() {
119 public ListenerRegistration<FlowNodeReconciliationImpl> call() throws Exception {
120 return dataBroker.registerDataTreeChangeListener(treeId, FlowNodeReconciliationImpl.this);
123 } catch (Exception e) {
124 LOG.warn("data listener registration failed: {}", e.getMessage());
125 LOG.debug("data listener registration failed.. ", e);
126 throw new IllegalStateException("FlowNodeReconciliation startup fail! System needs restart.", e);
131 public void close() {
132 if (listenerRegistration != null) {
134 listenerRegistration.close();
135 } catch (Exception e) {
136 LOG.warn("Error by stop FRM FlowNodeReconilListener: {}", e.getMessage());
137 LOG.debug("Error by stop FRM FlowNodeReconilListener..", e);
139 listenerRegistration = null;
144 public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> changes) {
145 Preconditions.checkNotNull(changes, "Changes may not be null!");
147 for (DataTreeModification<FlowCapableNode> change : changes) {
148 final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
149 final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
150 final InstanceIdentifier<FlowCapableNode> nodeIdent =
151 key.firstIdentifierOf(FlowCapableNode.class);
153 switch (mod.getModificationType()) {
155 if (mod.getDataAfter() == null) {
156 remove(key, mod.getDataBefore(), nodeIdent);
159 case SUBTREE_MODIFIED:
160 //NO-OP since we donot need to reconciliate on Node-updated
163 if (mod.getDataBefore() == null) {
164 add(key, mod.getDataAfter(), nodeIdent);
168 throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
175 public void remove(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode del,
176 InstanceIdentifier<FlowCapableNode> nodeIdent) {
177 if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
178 LOG.warn("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
180 if ( ! nodeIdent.isWildcarded()) {
181 flowNodeDisconnected(nodeIdent);
187 public void add(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode add,
188 InstanceIdentifier<FlowCapableNode> nodeIdent) {
189 if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
190 LOG.warn("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
192 if ( ! nodeIdent.isWildcarded()) {
193 flowNodeConnected(nodeIdent);
199 public void flowNodeDisconnected(InstanceIdentifier<FlowCapableNode> disconnectedNode) {
200 provider.unregistrateNode(disconnectedNode);
204 public void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode) {
205 flowNodeConnected(connectedNode, false);
208 private void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode, boolean force) {
209 if (force || !provider.isNodeActive(connectedNode)) {
210 provider.registrateNewNode(connectedNode);
212 if(!provider.isNodeOwner(connectedNode)) { return; }
214 if (provider.getConfiguration().isStaleMarkingEnabled()) {
215 LOG.info("Stale-Marking is ENABLED and proceeding with deletion of stale-marked entities on switch {}",
216 connectedNode.toString());
217 reconciliationPreProcess(connectedNode);
219 reconciliation(connectedNode);
223 private void reconciliation(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
225 String sNode = nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
226 long nDpId = getDpnIdFromNodeName(sNode);
228 ReadOnlyTransaction trans = provider.getReadTranaction();
229 Optional<FlowCapableNode> flowNode = Optional.absent();
231 AtomicInteger counter = new AtomicInteger();
232 //initialize the counter
235 flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdent).get();
237 catch (Exception e) {
238 LOG.error("Fail with read Config/DS for Node {} !", nodeIdent, e);
241 if (flowNode.isPresent()) {
242 /* Tables - have to be pushed before groups */
243 // CHECK if while pusing the update, updateTableInput can be null to emulate a table add
244 List<TableFeatures> tableList = flowNode.get().getTableFeatures() != null
245 ? flowNode.get().getTableFeatures() : Collections.<TableFeatures> emptyList() ;
246 for (TableFeatures tableFeaturesItem : tableList) {
247 TableFeaturesKey tableKey = tableFeaturesItem.getKey();
248 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII
249 = nodeIdent.child(TableFeatures.class, new TableFeaturesKey(tableKey.getTableId()));
250 provider.getTableFeaturesCommiter().update(tableFeaturesII, tableFeaturesItem, null, nodeIdent);
253 /* Groups - have to be first */
254 List<Group> groups = flowNode.get().getGroup() != null
255 ? flowNode.get().getGroup() : Collections.<Group>emptyList();
256 List<Group> toBeInstalledGroups = new ArrayList<>();
257 toBeInstalledGroups.addAll(groups);
258 List<Long> alreadyInstalledGroupids = new ArrayList<>();
259 //new list for suspected groups pointing to ports .. when the ports come up late
260 List<Group> suspectedGroups = new ArrayList<>();
262 while ((!(toBeInstalledGroups.isEmpty()) || !(suspectedGroups.isEmpty())) &&
263 (counter.get()<=provider.getConfiguration().getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
265 if(toBeInstalledGroups.isEmpty() && ! suspectedGroups.isEmpty()){
266 LOG.error("These Groups are pointing to node-connectors that are not up yet {}",suspectedGroups.toString());
267 toBeInstalledGroups.addAll(suspectedGroups);
271 ListIterator<Group> iterator = toBeInstalledGroups.listIterator();
272 while (iterator.hasNext()) {
273 Group group = iterator.next();
274 boolean okToInstall = true;
275 for (Bucket bucket : group.getBuckets().getBucket()) {
276 for (Action action : bucket.getAction()) {
278 if (action.getAction().getImplementedInterface().getName()
279 .equals("org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase")){
280 String nodeConnectorUri = ((OutputActionCase)(action.getAction()))
281 .getOutputAction().getOutputNodeConnector().getValue();
283 LOG.warn("Installing the group for node connector {}",nodeConnectorUri);
285 //check if the nodeconnector is there in the multimap
286 boolean isPresent = provider.getFlowNodeConnectorInventoryTranslatorImpl()
287 .isNodeConnectorUpdated(nDpId, nodeConnectorUri);
288 //if yes set okToInstall = true
292 }//else put it in a different list and still set okToInstall = true
294 suspectedGroups.add(group);
295 LOG.error("Not yet received the node-connector updated for {} " +
296 "for the group with id {}",nodeConnectorUri,group.getGroupId().toString());
303 else if (action.getAction().getImplementedInterface().getName()
304 .equals("org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase")) {
305 Long groupId = ((GroupActionCase) (action.getAction())).getGroupAction().getGroupId();
306 if (!alreadyInstalledGroupids.contains(groupId)) {
313 //increment retry counter value
314 counter.incrementAndGet();
324 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
325 nodeIdent.child(Group.class, group.getKey());
326 this.provider.getGroupCommiter().add(groupIdent, group, nodeIdent);
327 alreadyInstalledGroupids.add(group.getGroupId().getValue());
329 // resetting the counter to zero
335 /* installation of suspected groups*/
336 if(!toBeInstalledGroups.isEmpty()){
337 for(Group group :toBeInstalledGroups){
338 LOG.error("Installing the group {} finally although the port is not up after checking for {} times "
339 ,group.getGroupId().toString(),provider.getConfiguration().getReconciliationRetryCount());
340 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
341 nodeIdent.child(Group.class, group.getKey());
342 this.provider.getGroupCommiter().add(groupIdent, group, nodeIdent);
346 List<Meter> meters = flowNode.get().getMeter() != null
347 ? flowNode.get().getMeter() : Collections.<Meter> emptyList();
348 for (Meter meter : meters) {
349 final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
350 nodeIdent.child(Meter.class, meter.getKey());
351 this.provider.getMeterCommiter().add(meterIdent, meter, nodeIdent);
354 List<Table> tables = flowNode.get().getTable() != null
355 ? flowNode.get().getTable() : Collections.<Table> emptyList();
356 for (Table table : tables) {
357 final KeyedInstanceIdentifier<Table, TableKey> tableIdent =
358 nodeIdent.child(Table.class, table.getKey());
359 List<Flow> flows = table.getFlow() != null ? table.getFlow() : Collections.<Flow> emptyList();
360 for (Flow flow : flows) {
361 final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
362 tableIdent.child(Flow.class, flow.getKey());
363 this.provider.getFlowCommiter().add(flowIdent, flow, nodeIdent);
367 /* clean transaction */
370 private long getDpnIdFromNodeName(String nodeName) {
371 String dpId = nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1);
372 return Long.parseLong(dpId);
375 private void reconciliationPreProcess(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
378 List<InstanceIdentifier<StaleFlow>> staleFlowsToBeBulkDeleted = Lists.newArrayList();
379 List<InstanceIdentifier<StaleGroup>> staleGroupsToBeBulkDeleted = Lists.newArrayList();
380 List<InstanceIdentifier<StaleMeter>> staleMetersToBeBulkDeleted = Lists.newArrayList();
383 ReadOnlyTransaction trans = provider.getReadTranaction();
384 Optional<FlowCapableNode> flowNode = Optional.absent();
387 flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdent).get();
389 catch (Exception e) {
390 LOG.error("Reconciliation Pre-Processing Fail with read Config/DS for Node {} !", nodeIdent, e);
393 if (flowNode.isPresent()) {
395 LOG.debug("Proceeding with deletion of stale-marked Flows on switch {} using Openflow interface",
396 nodeIdent.toString());
397 /* Stale-Flows - Stale-marked Flows have to be removed first for safety */
398 List<Table> tables = flowNode.get().getTable() != null
399 ? flowNode.get().getTable() : Collections.<Table> emptyList();
400 for (Table table : tables) {
401 final KeyedInstanceIdentifier<Table, TableKey> tableIdent =
402 nodeIdent.child(Table.class, table.getKey());
403 List<StaleFlow> staleFlows = table.getStaleFlow() != null ? table.getStaleFlow() : Collections.<StaleFlow> emptyList();
404 for (StaleFlow staleFlow : staleFlows) {
406 FlowBuilder flowBuilder = new FlowBuilder(staleFlow);
407 Flow toBeDeletedFlow = flowBuilder.setId(staleFlow.getId()).build();
409 final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
410 tableIdent.child(Flow.class, toBeDeletedFlow.getKey());
413 this.provider.getFlowCommiter().remove(flowIdent, toBeDeletedFlow, nodeIdent);
415 staleFlowsToBeBulkDeleted.add(getStaleFlowInstanceIdentifier(staleFlow, nodeIdent));
420 LOG.debug("Proceeding with deletion of stale-marked Groups for switch {} using Openflow interface",
421 nodeIdent.toString());
423 // TODO: Should we collate the futures of RPC-calls to be sure that groups are Flows are fully deleted
424 // before attempting to delete groups - just in case there are references
426 /* Stale-marked Groups - Can be deleted after flows */
427 List<StaleGroup> staleGroups = flowNode.get().getStaleGroup() != null
428 ? flowNode.get().getStaleGroup() : Collections.<StaleGroup> emptyList();
429 for (StaleGroup staleGroup : staleGroups) {
431 GroupBuilder groupBuilder = new GroupBuilder(staleGroup);
432 Group toBeDeletedGroup = groupBuilder.setGroupId(staleGroup.getGroupId()).build();
434 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
435 nodeIdent.child(Group.class, toBeDeletedGroup.getKey());
437 this.provider.getGroupCommiter().remove(groupIdent, toBeDeletedGroup, nodeIdent);
439 staleGroupsToBeBulkDeleted.add(getStaleGroupInstanceIdentifier(staleGroup, nodeIdent));
442 LOG.debug("Proceeding with deletion of stale-marked Meters for switch {} using Openflow interface",
443 nodeIdent.toString());
444 /* Stale-marked Meters - can be deleted anytime - so least priority */
445 List<StaleMeter> staleMeters = flowNode.get().getStaleMeter() != null
446 ? flowNode.get().getStaleMeter() : Collections.<StaleMeter> emptyList();
448 for (StaleMeter staleMeter : staleMeters) {
450 MeterBuilder meterBuilder = new MeterBuilder(staleMeter);
451 Meter toBeDeletedMeter = meterBuilder.setMeterId(staleMeter.getMeterId()).build();
453 final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
454 nodeIdent.child(Meter.class, toBeDeletedMeter.getKey());
457 this.provider.getMeterCommiter().remove(meterIdent, toBeDeletedMeter, nodeIdent);
459 staleMetersToBeBulkDeleted.add(getStaleMeterInstanceIdentifier(staleMeter, nodeIdent));
463 /* clean transaction */
466 LOG.debug("Deleting all stale-marked flows/groups/meters of for switch {} in Configuration DS",
467 nodeIdent.toString());
468 // Now, do the bulk deletions
469 deleteDSStaleFlows(staleFlowsToBeBulkDeleted);
470 deleteDSStaleGroups(staleGroupsToBeBulkDeleted);
471 deleteDSStaleMeters(staleMetersToBeBulkDeleted);
476 private void deleteDSStaleFlows(List<InstanceIdentifier<StaleFlow>> flowsForBulkDelete){
477 ImmutableList.Builder<InstanceIdentifier<StaleFlow>> builder = ImmutableList.builder();
478 ImmutableList<InstanceIdentifier<StaleFlow>> bulkDelFlows = builder.addAll(flowsForBulkDelete.iterator()).build();
480 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
482 for (InstanceIdentifier<StaleFlow> staleFlowIId : flowsForBulkDelete){
483 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleFlowIId);
486 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
487 handleStaleEntityDeletionResultFuture(submitFuture);
490 private void deleteDSStaleGroups(List<InstanceIdentifier<StaleGroup>> groupsForBulkDelete){
491 ImmutableList.Builder<InstanceIdentifier<StaleGroup>> builder = ImmutableList.builder();
492 ImmutableList<InstanceIdentifier<StaleGroup>> bulkDelGroups = builder.addAll(groupsForBulkDelete.iterator()).build();
494 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
496 for (InstanceIdentifier<StaleGroup> staleGroupIId : groupsForBulkDelete){
497 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleGroupIId);
500 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
501 handleStaleEntityDeletionResultFuture(submitFuture);
505 private void deleteDSStaleMeters(List<InstanceIdentifier<StaleMeter>> metersForBulkDelete){
506 ImmutableList.Builder<InstanceIdentifier<StaleMeter>> builder = ImmutableList.builder();
507 ImmutableList<InstanceIdentifier<StaleMeter>> bulkDelGroups = builder.addAll(metersForBulkDelete.iterator()).build();
509 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
511 for (InstanceIdentifier<StaleMeter> staleMeterIId : metersForBulkDelete){
512 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleMeterIId);
515 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
516 handleStaleEntityDeletionResultFuture(submitFuture);
522 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow> getStaleFlowInstanceIdentifier(StaleFlow staleFlow, InstanceIdentifier<FlowCapableNode> nodeIdent) {
524 .child(Table.class, new TableKey(staleFlow.getTableId()))
525 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow.class,
526 new StaleFlowKey(new FlowId(staleFlow.getId())));
529 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup> getStaleGroupInstanceIdentifier(StaleGroup staleGroup, InstanceIdentifier<FlowCapableNode> nodeIdent) {
531 .child(StaleGroup.class, new StaleGroupKey(new GroupId(staleGroup.getGroupId())));
535 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter> getStaleMeterInstanceIdentifier(StaleMeter staleMeter, InstanceIdentifier<FlowCapableNode> nodeIdent) {
537 .child(StaleMeter.class, new StaleMeterKey(new MeterId(staleMeter.getMeterId())));
541 private void handleStaleEntityDeletionResultFuture(CheckedFuture<Void, TransactionCommitFailedException> submitFuture) {
542 Futures.addCallback(submitFuture, new FutureCallback<Void>() {
544 public void onSuccess(Void result) { LOG.debug("Stale entity removal success");
548 public void onFailure(Throwable t) {
549 LOG.error("Stale entity removal failed {}", t);
556 private boolean compareInstanceIdentifierTail(InstanceIdentifier<?> identifier1,
557 InstanceIdentifier<?> identifier2) {
558 return Iterables.getLast(identifier1.getPathArguments()).equals(Iterables.getLast(identifier2.getPathArguments()));