2 * Copyright © 2015 Red Hat, 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
8 package org.opendaylight.ovsdb.openstack.netvirt.sfc;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
15 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Data tree listener for {@link RenderedServicePath}
24 public class RspListener extends AbstractDataTreeListener<RenderedServicePath> {
25 private static final Logger LOG = LoggerFactory.getLogger(RspListener.class);
27 public RspListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
28 super(provider, RenderedServicePath.class);
29 Preconditions.checkNotNull(db, "DataBroker can not be null!");
31 registrationListener(db);
34 public InstanceIdentifier<RenderedServicePath> getRspIid() {
35 return InstanceIdentifier.create(RenderedServicePaths.class).child(RenderedServicePath.class);
38 private void registrationListener(final DataBroker db) {
39 final DataTreeIdentifier<RenderedServicePath> treeId =
40 new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getRspIid());
42 LOG.info("Registering Data Change Listener for NetvirtSfc RenderedServicePath configuration.");
43 ListenerRegistration<RspListener> listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
44 } catch (final Exception e) {
45 LOG.warn("Netvirt RenderedServicePath DataChange listener registration failed!");
46 throw new IllegalStateException("NetvirtSfcAccessListListener startup failed! System needs restart.", e);
51 public void remove(InstanceIdentifier<RenderedServicePath> identifier, RenderedServicePath change) {
52 Preconditions.checkNotNull(change, "Object can not be null!");
53 LOG.debug("remove RenderedServicePath iid = {}, change = {}", identifier, change);
54 provider.removeRsp(change);
58 public void update(InstanceIdentifier<RenderedServicePath> identifier, RenderedServicePath original,
59 RenderedServicePath change) {
60 Preconditions.checkNotNull(change, "Object can not be null!");
61 LOG.debug("Update RenderedServicePath iid = {}, change = {}", identifier, change);
62 //provider.addClassifierRules(update);
66 public void add(InstanceIdentifier<RenderedServicePath> identifier, RenderedServicePath change) {
67 Preconditions.checkNotNull(change, "Object can not be null!");
68 LOG.debug("Add RenderedServicePath iid = {}, change = {}", identifier, change);
72 public void close() throws Exception {