BgpManager: Log categorization, log formatting and
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / BgpManager.java
index 35d492471d2e48227a0cafc39bcff876c19c077a..d8e387eaf58e52478b4e2d215045a37b2bf8bcf3 100644 (file)
@@ -96,14 +96,14 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     public void startBgpService() throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Start Bgp Service - bgpThriftClient is null. Unable to start BGP service.");
+            LOGGER.error("Start Bgp Service - bgpThriftClient is null. Unable to start BGP service.");
             return;
         }
 
         // Now try start bgp - if bgp is already Active, it will tell us, nothing to do then
         try {
             bgpThriftClient.startBgp((int)bgpConfiguration.getAsNum(), bgpConfiguration.getRouterId());
-            LOGGER.info("Started BGP with AS number " + (int)bgpConfiguration.getAsNum() + " and router id " + bgpConfiguration.getRouterId());
+            LOGGER.debug("Started BGP with AS number " + (int)bgpConfiguration.getAsNum() + " and router id " + bgpConfiguration.getRouterId());
         } catch (BgpRouterException be) {
             if(be.getErrorCode() == BgpRouterException.BGP_ERR_ACTIVE) {
                 LOGGER.info("bgp server already active");
@@ -121,12 +121,12 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
         }  catch (TException t) {
             LOGGER.error("Could not set up thrift connection with bgp server");
-            //LOGGER.trace("Transport error while starting bgp server ", t);
+            LOGGER.debug("Transport error while starting bgp server ", t);
             reInitConn();
             throw t;
         } catch (Exception e) {
             LOGGER.error("Error while starting bgp server");
-            //LOGGER.trace("Bgp Service not started due to exception", e);
+            LOGGER.debug("Bgp Service not started due to exception", e);
             return;
         }
 
@@ -174,15 +174,15 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     protected void addNeighbor(String ipAddress, long asNum) throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Add BGP Neighbor - bgpThriftClient is null. Unable to add BGP Neighbor.");
+            LOGGER.error("Add BGP Neighbor - bgpThriftClient is null. Unable to add BGP Neighbor.");
             return;
         }
 
         try {
             bgpThriftClient.addNeighbor(ipAddress, (int) asNum);
         } catch (BgpRouterException b) {
-            LOGGER.error("Failed to add BGP neighbor " + ipAddress + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.error("Failed to add BGP neighbor " + ipAddress + " due to BgpRouter Exception number " + b.getErrorCode());
+            LOGGER.debug("BgpRouterException trace ", b);
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding neighbor %s due to Transport error", ipAddress));
             reInitConn();
@@ -195,7 +195,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     protected void deleteNeighbor(String ipAddress) throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Delete BGP Neighbor - bgpThriftClient is null. Unable to delete BGP Neighbor.");
+            LOGGER.error("Delete BGP Neighbor - bgpThriftClient is null. Unable to delete BGP Neighbor.");
             return;
         }
 
@@ -203,7 +203,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delNeighbor(ipAddress);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP neighbor " + ipAddress + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
         }catch (TException t) {
             LOGGER.error(String.format("Failed deleting neighbor %s due to Transport error", ipAddress));
             reInitConn();
@@ -217,14 +217,14 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
     @Override
     public void addVrf(String rd, Collection<String> importRts, Collection<String> exportRts) throws Exception {
         if(bgpThriftClient == null) {
-            LOGGER.info("Add BGP vrf - bgpThriftClient is null. Unable to add BGP vrf.");
+            LOGGER.error("Add BGP vrf - bgpThriftClient is null. Unable to add BGP vrf.");
             return;
         }
         try {
             bgpThriftClient.addVrf(rd, new ArrayList<>(importRts), new ArrayList<>(exportRts));
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to add BGP vrf " + rd + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding vrf %s due to Transport error", rd));
@@ -246,7 +246,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delVrf(rd);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP vrf " + rd + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed deleting vrf %s due to Transport error", rd));
@@ -270,7 +270,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.addPrefix(rd, prefix, nextHop, vpnLabel);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to add BGP prefix " + prefix + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding prefix entry <vrf:prefix:nexthop:vpnlabel> %s:%s:%s:%d due to Transport error",
@@ -296,7 +296,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delPrefix(rd, prefix);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP prefix " + prefix + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed deleting prefix entry <vrf:prefix> %s:%s due to Transport error",
@@ -321,10 +321,10 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
         }
         try {
             bgpThriftClient.connect(host, port);
-            LOGGER.info("Connected to BGP server " + host + " on port " + port);
+            LOGGER.debug("Connected to BGP server {} on port {} ", host, port);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to connect to BGP server " + host + " on port " + port + " due to BgpRouter Exception number " + b.getErrorCode());
-            //_logger.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error("Failed to initialize BGP Connection due to Transport error ");
@@ -349,10 +349,10 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
         try {
             bgpThriftClient.reInit();
-            LOGGER.info("Reinitialized connection to BGP Server " + bgpHost);
+            LOGGER.debug("Reinitialized connection to BGP Server {}", bgpHost);
         } catch (BgpRouterException b) {
-            LOGGER.error("Failed to reinitialize connection to BGP server " + bgpHost + " on port " + bgpPort + " due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.error("Failed to reinitialize connection to BGP server {} on port {} due to BgpRouter Exception number {}", bgpHost, bgpPort, b.getErrorCode());
+            LOGGER.debug("BgpRouterException trace ", b);
         } catch (TException t) {
             LOGGER.error("Failed to reinitialize BGP Connection due to Transport error.");
         }