+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Dell, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-
-import java.util.Collection;
-
-import com.google.common.base.Preconditions;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * AbstractChangeListner implemented basic {@link AsyncDataChangeEvent} processing for
- * netvirt-sfc data change listener.
- */
-public abstract class AbstractDataTreeListener<T extends DataObject> implements INetvirtSfcDataProcessor<T> {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDataTreeListener.class);
- protected INetvirtSfcOF13Provider provider;
- protected final Class<T> clazz;
- private final ExecutorService executorService = Executors.newFixedThreadPool(1);
-
- public AbstractDataTreeListener(INetvirtSfcOF13Provider provider, Class<T> clazz) {
- this.provider = Preconditions.checkNotNull(provider, "provider can not be null!");
- this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
- }
-
- private void processChanges(Collection<DataTreeModification<T>> changes) {
- LOG.info("onDataTreeChanged: Received Data Tree Changed ...", changes);
- for (DataTreeModification<T> change : changes) {
- final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
- final DataObjectModification<T> mod = change.getRootNode();
- LOG.info("onDataTreeChanged: Received Data Tree Changed Update of Type={} for Key={}",
- mod.getModificationType(), key);
- switch (mod.getModificationType()) {
- case DELETE:
- remove(key, mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- update(key, mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- add(key, mod.getDataAfter());
- } else {
- update(key, mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
- Preconditions.checkNotNull(changes, "Changes may not be null!");
- executorService.submit(new Runnable() {
- @Override
- public void run() {
- processChanges(changes);
- }
- });
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2016 Dell, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+
+import java.util.Collection;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Data-tree listener which delegates data processing to a {@link INetvirtSfcDataProcessor}.
+ */
+public class DelegatingDataTreeListener<T extends DataObject> implements AutoCloseable, DataTreeChangeListener<T> {
+ private static final Logger LOG = LoggerFactory.getLogger(DelegatingDataTreeListener.class);
+ protected INetvirtSfcOF13Provider provider;
+ private final ExecutorService executorService = Executors.newFixedThreadPool(1);
+ private final INetvirtSfcDataProcessor<T> dataProcessor;
+ private ListenerRegistration<DelegatingDataTreeListener<T>> listenerRegistration;
+
+ public DelegatingDataTreeListener(INetvirtSfcOF13Provider provider, INetvirtSfcDataProcessor<T> dataProcessor,
+ DataBroker db, DataTreeIdentifier<T> treeId) {
+ this.provider = Preconditions.checkNotNull(provider, "provider can not be null!");
+ this.dataProcessor = Preconditions.checkNotNull(dataProcessor, "Data processor can not be null!");
+ registerListener(Preconditions.checkNotNull(db, "Data broker can not be null!"),
+ Preconditions.checkNotNull(treeId, "Tree identifier can not be null!"));
+ }
+
+ private void registerListener(final DataBroker db, DataTreeIdentifier<T> treeId) {
+ try {
+ LOG.info("Registering Data Change Listener for {}", getClass().getSimpleName());
+ listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
+ } catch (final Exception e) {
+ LOG.warn("{} DataChange listener registration fail!", getClass().getSimpleName(), e);
+ throw new IllegalStateException("DataTreeListener startup fail! System needs restart.", e);
+ }
+ }
+
+ private void processChanges(Collection<DataTreeModification<T>> changes) {
+ LOG.info("onDataTreeChanged: Received Data Tree Changed ...", changes);
+ for (DataTreeModification<T> change : changes) {
+ final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
+ final DataObjectModification<T> mod = change.getRootNode();
+ LOG.info("onDataTreeChanged: Received Data Tree Changed Update of Type={} for Key={}",
+ mod.getModificationType(), key);
+ switch (mod.getModificationType()) {
+ case DELETE:
+ dataProcessor.remove(key, mod.getDataBefore());
+ break;
+ case SUBTREE_MODIFIED:
+ dataProcessor.update(key, mod.getDataBefore(), mod.getDataAfter());
+ break;
+ case WRITE:
+ if (mod.getDataBefore() == null) {
+ dataProcessor.add(key, mod.getDataAfter());
+ } else {
+ dataProcessor.update(key, mod.getDataBefore(), mod.getDataAfter());
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+ }
+ }
+ }
+
+ @Override
+ public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<T>> changes) {
+ Preconditions.checkNotNull(changes, "Changes may not be null!");
+ executorService.submit(new Runnable() {
+ @Override
+ public void run() {
+ processChanges(changes);
+ }
+ });
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ listenerRegistration.close();
+ listenerRegistration = null;
+ }
+ }
+}
/*
- * Copyright (c) 2013, 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2016 Dell, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* netvirt-sfc-dcl processor
* org.opendaylight.ovsdb.openstack.netvirt.sfc
*/
-public interface INetvirtSfcDataProcessor<D extends DataObject> extends AutoCloseable, DataTreeChangeListener<D> {
+public interface INetvirtSfcDataProcessor<D extends DataObject> {
/**
* Method removes DataObject which is identified by InstanceIdentifier.
--- /dev/null
+/*
+ * Copyright © 2015, 2016 Dell, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Data processor for AccessList.
+ */
+public class NetvirtSfcAclDataProcessor implements INetvirtSfcDataProcessor<Acl> {
+ private final INetvirtSfcOF13Provider provider;
+
+ /**
+ * {@link NetvirtSfcAclDataProcessor} constructor.
+ * @param provider OpenFlow 1.3 Provider
+ */
+ public NetvirtSfcAclDataProcessor(final INetvirtSfcOF13Provider provider) {
+ this.provider = Preconditions.checkNotNull(provider, "Provider can not be null!");
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<Acl> identifier,
+ final Acl change) {
+ Preconditions.checkNotNull(change, "Removed object can not be null!");
+ provider.removeClassifierRules(change);
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<Acl> identifier,
+ final Acl original, final Acl change) {
+ Preconditions.checkNotNull(original, "Updated original object can not be null!");
+ Preconditions.checkNotNull(original, "Updated update object can not be null!");
+ remove(identifier, original);
+ provider.addClassifierRules(change);
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<Acl> identifier,
+ final Acl change) {
+ Preconditions.checkNotNull(change, "Added object can not be null!");
+ provider.addClassifierRules(change);
+ }
+}
/*
- * Copyright © 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright © 2015, 2016 Dell, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Data tree listener for AccessList.
*/
-public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
- private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcAclListener.class);
- private ListenerRegistration<NetvirtSfcAclListener> listenerRegistration;
-
+public class NetvirtSfcAclListener extends DelegatingDataTreeListener<Acl> {
/**
* {@link NetvirtSfcAclListener} constructor.
* @param provider OpenFlow 1.3 Provider
* @param db MdSal {@link DataBroker}
*/
public NetvirtSfcAclListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
- super(provider, Acl.class);
- Preconditions.checkNotNull(db, "DataBroker can not be null!");
-
- registrationListener(db);
- }
-
- private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<Acl> treeId =
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getIetfAclIid());
- try {
- LOG.info("Registering Data Change Listener for NetvirtSfc AccessList configuration.");
- listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
- } catch (final Exception e) {
- LOG.warn("Netvirt AccessList DataChange listener registration fail!", e);
- throw new IllegalStateException("NetvirtSfcAccessListListener startup fail! System needs restart.", e);
- }
- }
-
- @Override
- public void close() {
- if (listenerRegistration != null) {
- try {
- listenerRegistration.close();
- } catch (final Exception e) {
- LOG.warn("Error while stopping IETF ACL ChangeListener", e);
- }
- listenerRegistration = null;
- }
- }
-
- @Override
- public void remove(final InstanceIdentifier<Acl> identifier,
- final Acl change) {
- Preconditions.checkNotNull(change, "Removed object can not be null!");
- provider.removeClassifierRules(change);
- }
-
- @Override
- public void update(final InstanceIdentifier<Acl> identifier,
- final Acl original, final Acl change) {
- Preconditions.checkNotNull(original, "Updated original object can not be null!");
- Preconditions.checkNotNull(original, "Updated update object can not be null!");
- remove(identifier, original);
- provider.addClassifierRules(change);
- }
-
- @Override
- public void add(final InstanceIdentifier<Acl> identifier,
- final Acl change) {
- Preconditions.checkNotNull(change, "Added object can not be null!");
- provider.addClassifierRules(change);
- }
-
- public InstanceIdentifier<Acl> getIetfAclIid() {
- return InstanceIdentifier.create(AccessLists.class).child(Acl.class);
+ super(provider, new NetvirtSfcAclDataProcessor(provider), db,
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(AccessLists.class).child(Acl.class)));
}
}
--- /dev/null
+/*
+ * Copyright © 2015, 2016 Dell, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers
+ .Classifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Data processor for Classifier.
+ */
+public class NetvirtSfcClassifierDataProcessor implements INetvirtSfcDataProcessor<Classifier> {
+ private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcClassifierDataProcessor.class);
+ private final MdsalUtils mdsalUtils;
+ private final INetvirtSfcOF13Provider provider;
+
+ /**
+ * {@link NetvirtSfcClassifierDataProcessor} constructor.
+ * @param provider OpenFlow 1.3 Provider
+ * @param db MdSal {@link DataBroker}
+ */
+ public NetvirtSfcClassifierDataProcessor(final INetvirtSfcOF13Provider provider, final DataBroker db) {
+ this.provider = Preconditions.checkNotNull(provider, "Provider can not be null!");
+ Preconditions.checkNotNull(db, "DataBroker can not be null!");
+ mdsalUtils = new MdsalUtils(db);
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<Classifier> identifier,
+ final Classifier change) {
+ Preconditions.checkNotNull(change, "Added object can not be null!");
+ String aclName = change.getAcl();
+ // Read the ACL information from data store and make sure it exists.
+ Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
+ if (acl == null) {
+ LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
+ return;
+ }
+
+ provider.removeClassifierRules(acl);
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<Classifier> identifier,
+ final Classifier original, final Classifier change) {
+ //TODO
+
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<Classifier> identifier,
+ final Classifier change) {
+ Preconditions.checkNotNull(change, "Added object can not be null!");
+ String aclName = change.getAcl();
+ // Read the ACL information from data store and make sure it exists.
+ Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
+ if (acl == null) {
+ LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
+ return;
+ }
+
+ provider.addClassifierRules(acl);
+ }
+
+ private InstanceIdentifier<Acl> getIetfAclIid(String aclName) {
+ return InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(aclName));
+ }
+}
/*
- * Copyright © 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright © 2015, 2016 Dell, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Data tree listener for Classifier.
*
* @author Arun Yerra
*/
-public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Classifier> {
- private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcClassifierListener.class);
- private MdsalUtils mdsalUtils;
- private ListenerRegistration<NetvirtSfcClassifierListener> listenerRegistration;
-
+public class NetvirtSfcClassifierListener extends DelegatingDataTreeListener<Classifier> {
/**
* {@link NetvirtSfcClassifierListener} constructor.
* @param provider OpenFlow 1.3 Provider
* @param db MdSal {@link DataBroker}
*/
public NetvirtSfcClassifierListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
- super(provider, Classifier.class);
- Preconditions.checkNotNull(db, "DataBroker can not be null!");
- mdsalUtils = new MdsalUtils(db);
- registrationListener(db);
- }
-
- private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<Classifier> treeId =
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
- try {
- LOG.info("Registering Data Change Listener for NetvirtSfc Classifier configuration.");
- listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
- } catch (final Exception e) {
- LOG.warn("Netvirt Classifier DataChange listener registration fail!", e);
- throw new IllegalStateException("NetvirtSfcClassifierListener startup fail! System needs restart.", e);
- }
- }
-
- @Override
- public void close() {
- if (listenerRegistration != null) {
- try {
- listenerRegistration.close();
- } catch (final Exception e) {
- LOG.warn("Error to stop Netvirt Classifier DataChange listener", e);
- }
- listenerRegistration = null;
- }
- }
-
- @Override
- public void remove(final InstanceIdentifier<Classifier> identifier,
- final Classifier change) {
- Preconditions.checkNotNull(change, "Added object can not be null!");
- String aclName = change.getAcl();
- // Read the ACL information from data store and make sure it exists.
- Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
- if (acl == null) {
- LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
- return;
- }
-
- provider.removeClassifierRules(acl);
- }
-
- @Override
- public void update(final InstanceIdentifier<Classifier> identifier,
- final Classifier original, final Classifier change) {
- //TODO
-
- }
-
- @Override
- public void add(final InstanceIdentifier<Classifier> identifier,
- final Classifier change) {
- Preconditions.checkNotNull(change, "Added object can not be null!");
- String aclName = change.getAcl();
- // Read the ACL information from data store and make sure it exists.
- Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
- if (acl == null) {
- LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
- return;
- }
-
- provider.addClassifierRules(acl);
- }
-
- public InstanceIdentifier<Classifier> getClassifierIid() {
- return InstanceIdentifier.create(Classifiers.class).child(Classifier.class);
- }
-
- private InstanceIdentifier<Acl> getIetfAclIid(String aclName) {
- return InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(aclName));
+ super(provider, new NetvirtSfcClassifierDataProcessor(provider, db), db,
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(Classifiers.class).child(Classifier.class)));
}
}
/*
- * Copyright © 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright © 2015, 2016 Dell, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcProvider.class);
- private NetvirtSfcAclListener aclListener;
- private NetvirtSfcClassifierListener classifierListener;
- private RspListener rspListener;
+ private AutoCloseable aclListener;
+ private AutoCloseable classifierListener;
+ private AutoCloseable rspListener;
private Boolean addSfFlows;
public void setOf13Provider(String of13Provider) {
--- /dev/null
+/*
+ * Copyright © 2015, 2016 Red Hat, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Data processor for {@link RenderedServicePath}
+ */
+public class RspDataProcessor implements INetvirtSfcDataProcessor<RenderedServicePath> {
+ private final INetvirtSfcOF13Provider provider;
+
+ public RspDataProcessor(final INetvirtSfcOF13Provider provider) {
+ this.provider = Preconditions.checkNotNull(provider, "Provider can not be null!");
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath change) {
+ Preconditions.checkNotNull(change, "Removed object can not be null!");
+ provider.removeRsp(change);
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath original,
+ RenderedServicePath change) {
+ Preconditions.checkNotNull(original, "Updated original object can not be null!");
+ Preconditions.checkNotNull(original, "Updated update object can not be null!");
+ remove(identifier, original);
+ provider.addRsp(change);
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath change) {
+ Preconditions.checkNotNull(change, "Created object can not be null!");
+ provider.addRsp(change);
+ }
+}
/*
- * Copyright © 2015 Red Hat, Inc. and others. All rights reserved.
+ * Copyright © 2015, 2016 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Data tree listener for {@link RenderedServicePath}
*/
-public class RspListener extends AbstractDataTreeListener<RenderedServicePath> {
- private static final Logger LOG = LoggerFactory.getLogger(RspListener.class);
- private ListenerRegistration<RspListener> listenerRegistration;
-
+public class RspListener extends DelegatingDataTreeListener<RenderedServicePath> {
public RspListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
- super(provider, RenderedServicePath.class);
- Preconditions.checkNotNull(db, "DataBroker can not be null!");
-
- registrationListener(db);
- }
-
- public InstanceIdentifier<RenderedServicePath> getRspIid() {
- return InstanceIdentifier.create(RenderedServicePaths.class).child(RenderedServicePath.class);
- }
-
- private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<RenderedServicePath> treeId =
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, getRspIid());
- try {
- LOG.info("Registering Data Change Listener for NetvirtSfc RenderedServicePath configuration.");
- listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
- } catch (final Exception e) {
- LOG.warn("Netvirt RenderedServicePath DataChange listener registration failed!", e);
- throw new IllegalStateException("RspListener startup failed! System needs restart.", e);
- }
- }
-
- @Override
- public void remove(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath change) {
- Preconditions.checkNotNull(change, "Removed object can not be null!");
- provider.removeRsp(change);
- }
-
- @Override
- public void update(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath original,
- RenderedServicePath change) {
- Preconditions.checkNotNull(original, "Updated original object can not be null!");
- Preconditions.checkNotNull(original, "Updated update object can not be null!");
- remove(identifier, original);
- provider.addRsp(change);
- }
-
- @Override
- public void add(final InstanceIdentifier<RenderedServicePath> identifier, final RenderedServicePath change) {
- Preconditions.checkNotNull(change, "Created object can not be null!");
- provider.addRsp(change);
- }
-
- @Override
- public void close() throws Exception {
-
+ super(provider, new RspDataProcessor(provider), db, new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(RenderedServicePaths.class).child(RenderedServicePath.class)));
}
}