Merge "JUnit for IdManager"
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / thrift / server / implementation / BgpUpdateHandler.java
1 package org.opendaylight.bgpmanager.thrift.server.implementation;
2
3 import org.opendaylight.bgpmanager.BgpManager;
4 import org.opendaylight.bgpmanager.FibDSWriter;
5 import org.opendaylight.bgpmanager.thrift.gen.BgpUpdater;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8
9 class BgpUpdateHandler implements BgpUpdater.Iface {
10
11     private static final Logger LOGGER = LoggerFactory.getLogger(BgpUpdateHandler.class);
12     private BgpManager bgpManager;
13     private FibDSWriter fibDSWriter;
14
15     public BgpUpdateHandler(BgpManager bgpMgr, FibDSWriter dsWriter) {
16         bgpManager = bgpMgr;
17         fibDSWriter = dsWriter;
18     }
19
20     public void onUpdatePushRoute(String rd, String prefix, int plen,
21                                 String nexthop, int label) {
22
23        LOGGER.debug("Route add ** {} ** {}/{} ** {} ** {} ", rd, prefix, plen, nexthop, label);
24         //Write to FIB in Data Store
25         fibDSWriter.addFibEntryToDS(rd, prefix + "/" + plen, nexthop, label);
26
27    }
28
29    public void onUpdateWithdrawRoute(String rd, String prefix, int plen) {
30        LOGGER.debug("Route del ** {} ** {}/{} ", rd, prefix, plen);
31        fibDSWriter.removeFibEntryFromDS(rd, prefix + "/" + plen);
32
33    }
34
35    public void onStartConfigResyncNotification() {
36        LOGGER.debug("BGP (re)started");
37        bgpManager.reInitConn();
38    }
39
40 }
41