2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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
8 package org.opendaylight.vpnservice.fcapsapp.performancecounter;
10 import org.opendaylight.controller.md.sal.binding.api.*;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14 import java.util.Collection;
16 public abstract class NodeConnectorEventListener <T extends DataObject> implements ClusteredDataTreeChangeListener<T>,AutoCloseable,FlowCapableNodeConnectorCommitter<T> {
17 NodeConnectorEventListener(Class<FlowCapableNodeConnector> flowCapableNodeConnectorClass) {
21 public void onDataTreeChanged(Collection<DataTreeModification<T>> changes) {
22 for (DataTreeModification<T> change : changes) {
23 final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
24 final DataObjectModification<T> mod = change.getRootNode();
25 final InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent =
26 key.firstIdentifierOf(FlowCapableNodeConnector.class);
28 switch (mod.getModificationType()) {
30 remove(key, mod.getDataBefore(), nodeConnIdent);
32 case SUBTREE_MODIFIED:
33 update(key, mod.getDataBefore(), mod.getDataAfter(), nodeConnIdent);
36 if (mod.getDataBefore() == null) {
37 add(key, mod.getDataAfter(), nodeConnIdent);
39 update(key, mod.getDataBefore(), mod.getDataAfter(), nodeConnIdent);
45 throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
51 public void close() throws Exception {