bd650ffe1106ad154e93a44d26414baf74d43c71
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / thrift / server / implementation / BgpUpdateHandler.java
1 /*
2  * Copyright (c) 2015 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.bgpmanager.thrift.server.implementation;
10
11 import org.opendaylight.bgpmanager.BgpManager;
12 import org.opendaylight.bgpmanager.FibDSWriter;
13 import org.opendaylight.bgpmanager.thrift.gen.BgpUpdater;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 class BgpUpdateHandler implements BgpUpdater.Iface {
18
19     private static final Logger LOGGER = LoggerFactory.getLogger(BgpUpdateHandler.class);
20     private BgpManager bgpManager;
21     private FibDSWriter fibDSWriter;
22
23     public BgpUpdateHandler(BgpManager bgpMgr, FibDSWriter dsWriter) {
24         bgpManager = bgpMgr;
25         fibDSWriter = dsWriter;
26     }
27
28     public void onUpdatePushRoute(String rd, String prefix, int plen,
29                                 String nexthop, int label) {
30
31        LOGGER.debug("Route add ** {} ** {}/{} ** {} ** {} ", rd, prefix, plen, nexthop, label);
32         //Write to FIB in Data Store
33         fibDSWriter.addFibEntryToDS(rd, prefix + "/" + plen, nexthop, label);
34
35    }
36
37    public void onUpdateWithdrawRoute(String rd, String prefix, int plen) {
38        LOGGER.debug("Route del ** {} ** {}/{} ", rd, prefix, plen);
39        fibDSWriter.removeFibEntryFromDS(rd, prefix + "/" + plen);
40
41    }
42
43    public void onStartConfigResyncNotification() {
44        LOGGER.debug("BGP (re)started");
45        bgpManager.reInitConn();
46    }
47
48 }
49