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.ExecutorService;
13 import java.util.concurrent.Executors;
14 import java.util.concurrent.atomic.AtomicInteger;
15 import com.google.common.base.Optional;
16 import com.google.common.base.Preconditions;
17 import com.google.common.collect.ImmutableList;
18 import com.google.common.collect.Iterables;
19 import com.google.common.collect.Lists;
20 import com.google.common.util.concurrent.CheckedFuture;
21 import com.google.common.util.concurrent.FutureCallback;
22 import com.google.common.util.concurrent.Futures;
24 import java.util.concurrent.Callable;
26 import org.opendaylight.controller.md.sal.binding.api.*;
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.FlowId;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
62 import org.opendaylight.yangtools.concepts.ListenerRegistration;
63 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
64 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
65 import org.slf4j.Logger;
66 import org.slf4j.LoggerFactory;
68 import javax.annotation.Nonnull;
72 * forwardingrules-manager
73 * org.opendaylight.openflowplugin.applications.frm
75 * FlowNode Reconciliation Listener
76 * Reconciliation for a new FlowNode
78 * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
80 * Created: Jun 13, 2014
82 public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
84 private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconciliationImpl.class);
86 private final DataBroker dataBroker;
88 private final ForwardingRulesManager provider;
89 public static final String SEPARATOR = ":";
91 private ListenerRegistration<FlowNodeReconciliationImpl> listenerRegistration;
93 private final int THREAD_POOL_SIZE = 4;
94 ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
96 private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE
97 = InstanceIdentifier.builder(Nodes.class)
99 .augmentation(FlowCapableNode.class)
102 public FlowNodeReconciliationImpl (final ForwardingRulesManager manager, final DataBroker db) {
103 this.provider = Preconditions.checkNotNull(manager, "ForwardingRulesManager can not be null!");
104 dataBroker = Preconditions.checkNotNull(db, "DataBroker can not be null!");
106 final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
107 .child(Node.class).augmentation(FlowCapableNode.class);
109 final DataTreeIdentifier<FlowCapableNode> treeId =
110 new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
113 SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
114 ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
116 listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<FlowNodeReconciliationImpl>>() {
118 public ListenerRegistration<FlowNodeReconciliationImpl> call() throws Exception {
119 return dataBroker.registerDataTreeChangeListener(treeId, FlowNodeReconciliationImpl.this);
122 } catch (Exception e) {
123 LOG.warn("data listener registration failed: {}", e.getMessage());
124 LOG.debug("data listener registration failed.. ", e);
125 throw new IllegalStateException("FlowNodeReconciliation startup fail! System needs restart.", e);
130 public void close() {
131 if (listenerRegistration != null) {
133 listenerRegistration.close();
134 } catch (Exception e) {
135 LOG.warn("Error by stop FRM FlowNodeReconilListener: {}", e.getMessage());
136 LOG.debug("Error by stop FRM FlowNodeReconilListener..", e);
138 listenerRegistration = null;
143 public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> changes) {
144 Preconditions.checkNotNull(changes, "Changes may not be null!");
146 for (DataTreeModification<FlowCapableNode> change : changes) {
147 final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
148 final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
149 final InstanceIdentifier<FlowCapableNode> nodeIdent =
150 key.firstIdentifierOf(FlowCapableNode.class);
152 switch (mod.getModificationType()) {
154 if (mod.getDataAfter() == null) {
155 remove(key, mod.getDataBefore(), nodeIdent);
158 case SUBTREE_MODIFIED:
159 //NO-OP since we donot need to reconciliate on Node-updated
162 if (mod.getDataBefore() == null) {
163 add(key, mod.getDataAfter(), nodeIdent);
167 throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
174 public void remove(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode del,
175 InstanceIdentifier<FlowCapableNode> nodeIdent) {
176 if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
177 if (LOG.isDebugEnabled()) {
178 LOG.debug("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
181 if ( ! nodeIdent.isWildcarded()) {
182 flowNodeDisconnected(nodeIdent);
188 public void add(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode add,
189 InstanceIdentifier<FlowCapableNode> nodeIdent) {
190 if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
191 if (LOG.isDebugEnabled()) {
192 LOG.debug("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
195 if ( ! nodeIdent.isWildcarded()) {
196 flowNodeConnected(nodeIdent);
202 public void flowNodeDisconnected(InstanceIdentifier<FlowCapableNode> disconnectedNode) {
203 provider.unregistrateNode(disconnectedNode);
207 public void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode) {
208 flowNodeConnected(connectedNode, false);
211 private void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode, boolean force) {
212 if (force || !provider.isNodeActive(connectedNode)) {
213 provider.registrateNewNode(connectedNode);
215 if(!provider.isNodeOwner(connectedNode)) { return; }
217 if (provider.getConfiguration().isStaleMarkingEnabled()) {
218 LOG.info("Stale-Marking is ENABLED and proceeding with deletion of stale-marked entities on switch {}",
219 connectedNode.toString());
220 reconciliationPreProcess(connectedNode);
222 ReconciliationTask reconciliationTask = new ReconciliationTask(connectedNode);
223 executor.execute(reconciliationTask);
227 private class ReconciliationTask implements Runnable {
229 InstanceIdentifier<FlowCapableNode> nodeIdentity;
231 public ReconciliationTask(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
232 nodeIdentity = nodeIdent;
238 String sNode = nodeIdentity.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
239 long nDpId = getDpnIdFromNodeName(sNode);
241 ReadOnlyTransaction trans = provider.getReadTranaction();
242 Optional<FlowCapableNode> flowNode = Optional.absent();
244 AtomicInteger counter = new AtomicInteger();
245 //initialize the counter
248 flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdentity).get();
249 } catch (Exception e) {
250 LOG.error("Fail with read Config/DS for Node {} !", nodeIdentity, e);
253 if (flowNode.isPresent()) {
254 /* Tables - have to be pushed before groups */
255 // CHECK if while pusing the update, updateTableInput can be null to emulate a table add
256 List<TableFeatures> tableList = flowNode.get().getTableFeatures() != null
257 ? flowNode.get().getTableFeatures() : Collections.<TableFeatures>emptyList();
258 for (TableFeatures tableFeaturesItem : tableList) {
259 TableFeaturesKey tableKey = tableFeaturesItem.getKey();
260 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII
261 = nodeIdentity.child(TableFeatures.class, new TableFeaturesKey(tableKey.getTableId()));
262 provider.getTableFeaturesCommiter().update(tableFeaturesII, tableFeaturesItem, null, nodeIdentity);
265 /* Groups - have to be first */
266 List<Group> groups = flowNode.get().getGroup() != null
267 ? flowNode.get().getGroup() : Collections.<Group>emptyList();
268 List<Group> toBeInstalledGroups = new ArrayList<>();
269 toBeInstalledGroups.addAll(groups);
270 List<Long> alreadyInstalledGroupids = new ArrayList<>();
271 //new list for suspected groups pointing to ports .. when the ports come up late
272 List<Group> suspectedGroups = new ArrayList<>();
274 while ((!(toBeInstalledGroups.isEmpty()) || !(suspectedGroups.isEmpty())) &&
275 (counter.get() <= provider.getConfiguration().getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
277 if (toBeInstalledGroups.isEmpty() && !suspectedGroups.isEmpty()) {
278 LOG.error("These Groups are pointing to node-connectors that are not up yet {}", suspectedGroups.toString());
279 toBeInstalledGroups.addAll(suspectedGroups);
283 ListIterator<Group> iterator = toBeInstalledGroups.listIterator();
284 while (iterator.hasNext()) {
285 Group group = iterator.next();
286 boolean okToInstall = true;
287 for (Bucket bucket : group.getBuckets().getBucket()) {
288 for (Action action : bucket.getAction()) {
290 if (action.getAction().getImplementedInterface().getName()
291 .equals("org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase")) {
292 String nodeConnectorUri = ((OutputActionCase) (action.getAction()))
293 .getOutputAction().getOutputNodeConnector().getValue();
295 LOG.warn("Installing the group for node connector {}", nodeConnectorUri);
297 //check if the nodeconnector is there in the multimap
298 boolean isPresent = provider.getFlowNodeConnectorInventoryTranslatorImpl()
299 .isNodeConnectorUpdated(nDpId, nodeConnectorUri);
300 //if yes set okToInstall = true
304 }//else put it in a different list and still set okToInstall = true
306 suspectedGroups.add(group);
307 LOG.error("Not yet received the node-connector updated for {} " +
308 "for the group with id {}", nodeConnectorUri, group.getGroupId().toString());
315 else if (action.getAction().getImplementedInterface().getName()
316 .equals("org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase")) {
317 Long groupId = ((GroupActionCase) (action.getAction())).getGroupAction().getGroupId();
318 if (!alreadyInstalledGroupids.contains(groupId)) {
325 //increment retry counter value
326 counter.incrementAndGet();
335 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
336 nodeIdentity.child(Group.class, group.getKey());
337 provider.getGroupCommiter().add(groupIdent, group, nodeIdentity);
338 alreadyInstalledGroupids.add(group.getGroupId().getValue());
340 // resetting the counter to zero
346 /* installation of suspected groups*/
347 if (!toBeInstalledGroups.isEmpty()) {
348 for (Group group : toBeInstalledGroups) {
349 LOG.error("Installing the group {} finally although the port is not up after checking for {} times "
350 , group.getGroupId().toString(), provider.getConfiguration().getReconciliationRetryCount());
351 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
352 nodeIdentity.child(Group.class, group.getKey());
353 provider.getGroupCommiter().add(groupIdent, group, nodeIdentity);
357 List<Meter> meters = flowNode.get().getMeter() != null
358 ? flowNode.get().getMeter() : Collections.<Meter>emptyList();
359 for (Meter meter : meters) {
360 final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
361 nodeIdentity.child(Meter.class, meter.getKey());
362 provider.getMeterCommiter().add(meterIdent, meter, nodeIdentity);
365 List<Table> tables = flowNode.get().getTable() != null
366 ? flowNode.get().getTable() : Collections.<Table>emptyList();
367 for (Table table : tables) {
368 final KeyedInstanceIdentifier<Table, TableKey> tableIdent =
369 nodeIdentity.child(Table.class, table.getKey());
370 List<Flow> flows = table.getFlow() != null ? table.getFlow() : Collections.<Flow>emptyList();
371 for (Flow flow : flows) {
372 final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
373 tableIdent.child(Flow.class, flow.getKey());
374 provider.getFlowCommiter().add(flowIdent, flow, nodeIdentity);
378 /* clean transaction */
382 private long getDpnIdFromNodeName(String nodeName) {
383 String dpId = nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1);
384 return Long.parseLong(dpId);
387 private void reconciliationPreProcess(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
389 List<InstanceIdentifier<StaleFlow>> staleFlowsToBeBulkDeleted = Lists.newArrayList();
390 List<InstanceIdentifier<StaleGroup>> staleGroupsToBeBulkDeleted = Lists.newArrayList();
391 List<InstanceIdentifier<StaleMeter>> staleMetersToBeBulkDeleted = Lists.newArrayList();
394 ReadOnlyTransaction trans = provider.getReadTranaction();
395 Optional<FlowCapableNode> flowNode = Optional.absent();
398 flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdent).get();
400 catch (Exception e) {
401 LOG.error("Reconciliation Pre-Processing Fail with read Config/DS for Node {} !", nodeIdent, e);
404 if (flowNode.isPresent()) {
406 LOG.debug("Proceeding with deletion of stale-marked Flows on switch {} using Openflow interface",
407 nodeIdent.toString());
408 /* Stale-Flows - Stale-marked Flows have to be removed first for safety */
409 List<Table> tables = flowNode.get().getTable() != null
410 ? flowNode.get().getTable() : Collections.<Table> emptyList();
411 for (Table table : tables) {
412 final KeyedInstanceIdentifier<Table, TableKey> tableIdent =
413 nodeIdent.child(Table.class, table.getKey());
414 List<StaleFlow> staleFlows = table.getStaleFlow() != null ? table.getStaleFlow() : Collections.<StaleFlow> emptyList();
415 for (StaleFlow staleFlow : staleFlows) {
417 FlowBuilder flowBuilder = new FlowBuilder(staleFlow);
418 Flow toBeDeletedFlow = flowBuilder.setId(staleFlow.getId()).build();
420 final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
421 tableIdent.child(Flow.class, toBeDeletedFlow.getKey());
424 this.provider.getFlowCommiter().remove(flowIdent, toBeDeletedFlow, nodeIdent);
426 staleFlowsToBeBulkDeleted.add(getStaleFlowInstanceIdentifier(staleFlow, nodeIdent));
431 LOG.debug("Proceeding with deletion of stale-marked Groups for switch {} using Openflow interface",
432 nodeIdent.toString());
434 // TODO: Should we collate the futures of RPC-calls to be sure that groups are Flows are fully deleted
435 // before attempting to delete groups - just in case there are references
437 /* Stale-marked Groups - Can be deleted after flows */
438 List<StaleGroup> staleGroups = flowNode.get().getStaleGroup() != null
439 ? flowNode.get().getStaleGroup() : Collections.<StaleGroup> emptyList();
440 for (StaleGroup staleGroup : staleGroups) {
442 GroupBuilder groupBuilder = new GroupBuilder(staleGroup);
443 Group toBeDeletedGroup = groupBuilder.setGroupId(staleGroup.getGroupId()).build();
445 final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
446 nodeIdent.child(Group.class, toBeDeletedGroup.getKey());
448 this.provider.getGroupCommiter().remove(groupIdent, toBeDeletedGroup, nodeIdent);
450 staleGroupsToBeBulkDeleted.add(getStaleGroupInstanceIdentifier(staleGroup, nodeIdent));
453 LOG.debug("Proceeding with deletion of stale-marked Meters for switch {} using Openflow interface",
454 nodeIdent.toString());
455 /* Stale-marked Meters - can be deleted anytime - so least priority */
456 List<StaleMeter> staleMeters = flowNode.get().getStaleMeter() != null
457 ? flowNode.get().getStaleMeter() : Collections.<StaleMeter> emptyList();
459 for (StaleMeter staleMeter : staleMeters) {
461 MeterBuilder meterBuilder = new MeterBuilder(staleMeter);
462 Meter toBeDeletedMeter = meterBuilder.setMeterId(staleMeter.getMeterId()).build();
464 final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
465 nodeIdent.child(Meter.class, toBeDeletedMeter.getKey());
468 this.provider.getMeterCommiter().remove(meterIdent, toBeDeletedMeter, nodeIdent);
470 staleMetersToBeBulkDeleted.add(getStaleMeterInstanceIdentifier(staleMeter, nodeIdent));
474 /* clean transaction */
477 LOG.debug("Deleting all stale-marked flows/groups/meters of for switch {} in Configuration DS",
478 nodeIdent.toString());
479 // Now, do the bulk deletions
480 deleteDSStaleFlows(staleFlowsToBeBulkDeleted);
481 deleteDSStaleGroups(staleGroupsToBeBulkDeleted);
482 deleteDSStaleMeters(staleMetersToBeBulkDeleted);
487 private void deleteDSStaleFlows(List<InstanceIdentifier<StaleFlow>> flowsForBulkDelete){
488 ImmutableList.Builder<InstanceIdentifier<StaleFlow>> builder = ImmutableList.builder();
489 ImmutableList<InstanceIdentifier<StaleFlow>> bulkDelFlows = builder.addAll(flowsForBulkDelete.iterator()).build();
491 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
493 for (InstanceIdentifier<StaleFlow> staleFlowIId : flowsForBulkDelete){
494 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleFlowIId);
497 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
498 handleStaleEntityDeletionResultFuture(submitFuture);
501 private void deleteDSStaleGroups(List<InstanceIdentifier<StaleGroup>> groupsForBulkDelete){
502 ImmutableList.Builder<InstanceIdentifier<StaleGroup>> builder = ImmutableList.builder();
503 ImmutableList<InstanceIdentifier<StaleGroup>> bulkDelGroups = builder.addAll(groupsForBulkDelete.iterator()).build();
505 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
507 for (InstanceIdentifier<StaleGroup> staleGroupIId : groupsForBulkDelete){
508 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleGroupIId);
511 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
512 handleStaleEntityDeletionResultFuture(submitFuture);
516 private void deleteDSStaleMeters(List<InstanceIdentifier<StaleMeter>> metersForBulkDelete){
517 ImmutableList.Builder<InstanceIdentifier<StaleMeter>> builder = ImmutableList.builder();
518 ImmutableList<InstanceIdentifier<StaleMeter>> bulkDelGroups = builder.addAll(metersForBulkDelete.iterator()).build();
520 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
522 for (InstanceIdentifier<StaleMeter> staleMeterIId : metersForBulkDelete){
523 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleMeterIId);
526 CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTransaction.submit();
527 handleStaleEntityDeletionResultFuture(submitFuture);
533 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow> getStaleFlowInstanceIdentifier(StaleFlow staleFlow, InstanceIdentifier<FlowCapableNode> nodeIdent) {
535 .child(Table.class, new TableKey(staleFlow.getTableId()))
536 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow.class,
537 new StaleFlowKey(new FlowId(staleFlow.getId())));
540 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup> getStaleGroupInstanceIdentifier(StaleGroup staleGroup, InstanceIdentifier<FlowCapableNode> nodeIdent) {
542 .child(StaleGroup.class, new StaleGroupKey(new GroupId(staleGroup.getGroupId())));
546 private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter> getStaleMeterInstanceIdentifier(StaleMeter staleMeter, InstanceIdentifier<FlowCapableNode> nodeIdent) {
548 .child(StaleMeter.class, new StaleMeterKey(new MeterId(staleMeter.getMeterId())));
552 private void handleStaleEntityDeletionResultFuture(CheckedFuture<Void, TransactionCommitFailedException> submitFuture) {
553 Futures.addCallback(submitFuture, new FutureCallback<Void>() {
555 public void onSuccess(Void result) { LOG.debug("Stale entity removal success");
559 public void onFailure(Throwable t) {
560 LOG.error("Stale entity removal failed {}", t);
567 private boolean compareInstanceIdentifierTail(InstanceIdentifier<?> identifier1,
568 InstanceIdentifier<?> identifier2) {
569 return Iterables.getLast(identifier1.getPathArguments()).equals(Iterables.getLast(identifier2.getPathArguments()));