Fix build faliures due to OFPlugin checktyle fixes
[netvirt.git] / elanmanager / elanmanager-impl / src / main / java / org / opendaylight / netvirt / elan / evpn / listeners / MacVrfEntryListener.java
1 /*
2  * Copyright © 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netvirt.elan.evpn.listeners;
10
11 import javax.annotation.PostConstruct;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
17 import org.opendaylight.netvirt.elan.evpn.utils.EvpnMacVrfUtils;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25
26 /**
27  * When RT2 route (advertise of withdraw) is received from peer side.
28  * BGPManager will receive the RT2 msg.
29  * It will check if the EVPN is configured and Network is attached to EVPN or not.
30  * BGPManager will write in path (FibEntries.class).child(VrfTables.class).child(MacVrfEntry.class)
31  * which MacVrfEntryListener is listening to.
32  * When RT2 advertise route is received: add method of MacVrfEntryListener will install DMAC flows for the
33  * received dest MAC in all the DPN's (with this network footprint).
34  * When RT2 withdraw route is received: remove method of MacVrfEntryListener will remove DMAC flows for the
35  * received dest MAC in all the DPN's (with this network footprint).
36  */
37 @Singleton
38 public class MacVrfEntryListener extends AsyncDataTreeChangeListenerBase<MacVrfEntry, MacVrfEntryListener> {
39     private static final Logger LOG = LoggerFactory.getLogger(MacVrfEntryListener.class);
40     private final DataBroker broker;
41     private final EvpnMacVrfUtils evpnMacVrfUtils;
42
43     @Inject
44     public MacVrfEntryListener(final DataBroker broker, final EvpnMacVrfUtils evpnMacVrfUtils) {
45         this.broker = broker;
46         this.evpnMacVrfUtils = evpnMacVrfUtils;
47
48     }
49
50     @Override
51     @PostConstruct
52     public void init() {
53         registerListener(LogicalDatastoreType.CONFIGURATION, broker);
54     }
55
56     @Override
57     protected InstanceIdentifier<MacVrfEntry> getWildCardPath() {
58         return InstanceIdentifier.create(FibEntries.class).child(VrfTables.class).child(MacVrfEntry.class);
59     }
60
61     @Override
62     protected MacVrfEntryListener getDataTreeChangeListener() {
63         return MacVrfEntryListener.this;
64     }
65
66     @Override
67     protected void add(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
68         LOG.info("ADD: Adding DMAC Entry for MACVrfEntry {} ", macVrfEntry);
69         evpnMacVrfUtils.addEvpnDmacFlow(instanceIdentifier, macVrfEntry);
70     }
71
72     @Override
73     protected void update(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, MacVrfEntry t1) {
74
75     }
76
77     @Override
78     protected void remove(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
79         LOG.info("REMOVE: Removing DMAC Entry for MACVrfEntry {} ", macVrfEntry);
80         evpnMacVrfUtils.removeEvpnDmacFlow(instanceIdentifier, macVrfEntry);
81     }
82 }