d0825d9ded0f62e356ba49d7db903e2df952b86e
[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         //Test
20         onUpdatePushRoute("5", "10.1.1.2", 32, "1.2.3.4", 200);
21         onUpdatePushRoute("5", "10.1.1.3", 32, "1.2.3.5", 400);
22         onUpdatePushRoute("10", "10.10.0.10", 32, "5.4.3.2", 600);
23         onUpdateWithdrawRoute("5", "10.1.1.3", 32);
24
25
26     }
27
28     public void onUpdatePushRoute(String rd, String prefix, int plen,
29                                 String nexthop, int label) {
30
31        logger.info("Route add ** " + rd + " ** " + prefix + "/" + plen
32                + " ** " + nexthop + " ** " + label);
33         //Write to FIB in Data Store
34         fibDSWriter.addFibEntryToDS(rd, prefix + "/" + plen, nexthop, label);
35
36    }
37
38    public void onUpdateWithdrawRoute(String rd, String prefix, int plen) {
39        logger.info("Route del ** " + rd + " ** " + prefix + "/" + plen);
40        fibDSWriter.removeFibEntryFromDS(rd, prefix + "/" + plen);
41
42    }
43
44    public void onStartConfigResyncNotification() {
45        logger.info("BGP (re)started");
46        bgpManager.reInitConn();
47    }
48
49 }
50