2 * Copyright (c) 2016, 2017 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.netvirt.ipv6service;
10 import javax.annotation.PreDestroy;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.opendaylight.infrautils.utils.concurrent.Executors;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 public class NeutronRouterChangeListener extends AbstractClusteredAsyncDataTreeChangeListener<Router> {
26 private static final Logger LOG = LoggerFactory.getLogger(NeutronRouterChangeListener.class);
27 private final DataBroker dataBroker;
28 private final IfMgr ifMgr;
31 public NeutronRouterChangeListener(final DataBroker dataBroker, IfMgr ifMgr) {
32 super(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Neutron.class)
33 .child(Routers.class).child(Router.class),
34 Executors.newListeningSingleThreadExecutor("NeutronRouterChangeListener", LOG));
35 this.dataBroker = dataBroker;
40 LOG.info("{} init", getClass().getSimpleName());
47 Executors.shutdownAndAwaitTermination(getExecutorService());
51 public void add(InstanceIdentifier<Router> identifier, Router input) {
52 LOG.info("Add Router notification handler is invoked {}.", input.getUuid());
53 ifMgr.addRouter(input.getUuid(), input.getName(), input.getTenantId());
57 public void remove(InstanceIdentifier<Router> identifier, Router input) {
58 LOG.info("Remove Router notification handler is invoked {}.", input.getUuid());
59 ifMgr.removeRouter(input.getUuid());
63 public void update(InstanceIdentifier<Router> identifier, Router original, Router update) {
64 LOG.debug("Update Router notification handler is invoked. Original: {}, Updated: {}.", original, update);