BgpManager commit for code refactoring & bug fixes
[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.info("Route add ** " + rd + " ** " + prefix + "/" + plen
24                + " ** " + nexthop + " ** " + label);
25         //Write to FIB in Data Store
26         fibDSWriter.addFibEntryToDS(rd, prefix + "/" + plen, nexthop, label);
27
28    }
29
30    public void onUpdateWithdrawRoute(String rd, String prefix, int plen) {
31        logger.info("Route del ** " + rd + " ** " + prefix + "/" + plen);
32        fibDSWriter.removeFibEntryFromDS(rd, prefix + "/" + plen);
33
34    }
35
36    public void onStartConfigResyncNotification() {
37        logger.info("BGP (re)started");
38        bgpManager.reInitConn();
39    }
40
41 }
42