Update for OOM integration
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / SynchronizerTask.java
index 898a3f0..9eeac23 100644 (file)
@@ -89,23 +89,32 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
  * </ol>
  * <p>For this to work correctly, the following code needs to be placed at the beginning of main().</p>
  * <code>
- *         Security.setProperty("networkaddress.cache.ttl", "10");
+ * Security.setProperty("networkaddress.cache.ttl", "10");
  * </code>
  *
  * @author Robert Eby
  * @version $Id: SynchronizerTask.java,v 1.10 2014/03/21 13:50:10 eby Exp $
  */
 public class SynchronizerTask extends TimerTask {
-    /** This is a singleton -- there is only one SynchronizerTask object in the server */
+
+    /**
+     * This is a singleton -- there is only one SynchronizerTask object in the server
+     */
     private static SynchronizerTask synctask;
 
-    /** This POD is unknown -- not on the list of PODs */
+    /**
+     * This POD is unknown -- not on the list of PODs
+     */
     public static final int UNKNOWN = 0;
-    /** This POD is active -- on the list of PODs, and the DNS CNAME points to us */
+    /**
+     * This POD is active -- on the list of PODs, and the DNS CNAME points to us
+     */
     public static final int ACTIVE = 1;
-    /** This POD is standby -- on the list of PODs, and the DNS CNAME does not point to us */
+    /**
+     * This POD is standby -- on the list of PODs, and the DNS CNAME does not point to us
+     */
     public static final int STANDBY = 2;
-    private static final String[] stnames = { "UNKNOWN", "ACTIVE", "STANDBY" };
+    private static final String[] stnames = {"UNKNOWN", "ACTIVE", "STANDBY"};
     private static final long ONE_HOUR = 60 * 60 * 1000L;
 
     private final Logger logger;
@@ -118,11 +127,13 @@ public class SynchronizerTask extends TimerTask {
 
     /**
      * Get the singleton SynchronizerTask object.
+     *
      * @return the SynchronizerTask
      */
     public static synchronized SynchronizerTask getSynchronizer() {
-        if (synctask == null)
+        if (synctask == null) {
             synctask = new SynchronizerTask();
+        }
         return synctask;
     }
 
@@ -138,16 +149,16 @@ public class SynchronizerTask extends TimerTask {
         logger.info("PROV5000: Sync task starting, server state is UNKNOWN");
         try {
             Properties props = (new DB()).getProperties();
-            String type  = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
+            String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
             String store = props.getProperty(Main.KEYSTORE_PATH_PROPERTY);
-            String pass  = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
+            String pass = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
             KeyStore keyStore = KeyStore.getInstance(type);
             FileInputStream instream = new FileInputStream(new File(store));
             keyStore.load(instream, pass.toCharArray());
             instream.close();
 
             store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY);
-            pass  = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
+            pass = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
             KeyStore trustStore = null;
             if (store != null && store.length() > 0) {
                 trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
@@ -158,12 +169,13 @@ public class SynchronizerTask extends TimerTask {
 
             // We are connecting with the node name, but the certificate will have the CNAME
             // So we need to accept a non-matching certificate name
-            String keystorepass  = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY); //itrack.web.att.com/browse/DATARTR-6 for changing hard coded passphase ref
+            String keystorepass = props.getProperty(
+                Main.KEYSTORE_PASSWORD_PROPERTY); //itrack.web.att.com/browse/DATARTR-6 for changing hard coded passphase ref
             AbstractHttpClient hc = new DefaultHttpClient();
             SSLSocketFactory socketFactory =
                 (trustStore == null)
-                ? new SSLSocketFactory(keyStore, keystorepass)
-                : new SSLSocketFactory(keyStore, keystorepass, trustStore);
+                    ? new SSLSocketFactory(keyStore, keystorepass)
+                    : new SSLSocketFactory(keyStore, keystorepass, trustStore);
             socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
             Scheme sch = new Scheme("https", 443, socketFactory);
             hc.getConnectionManager().getSchemeRegistry().register(sch);
@@ -179,12 +191,13 @@ public class SynchronizerTask extends TimerTask {
             }
             rolex.scheduleAtFixedRate(this, 0L, interval);
         } catch (Exception e) {
-            logger.warn("PROV5005: Problem starting the synchronizer: "+e);
+            logger.warn("PROV5005: Problem starting the synchronizer: " + e);
         }
     }
 
     /**
      * What is the state of this POD?
+     *
      * @return one of ACTIVE, STANDBY, UNKNOWN
      */
     public int getState() {
@@ -193,6 +206,7 @@ public class SynchronizerTask extends TimerTask {
 
     /**
      * Is this the active POD?
+     *
      * @return true if we are active (the master), false otherwise
      */
     public boolean isActive() {
@@ -200,8 +214,8 @@ public class SynchronizerTask extends TimerTask {
     }
 
     /**
-     * This method is used to signal that another POD (the active POD) has sent us a /fetchProv request,
-     * and that we should re-synchronize with the master.
+     * This method is used to signal that another POD (the active POD) has sent us a /fetchProv request, and that we
+     * should re-synchronize with the master.
      */
     public void doFetch() {
         doFetch = true;
@@ -226,20 +240,23 @@ public class SynchronizerTask extends TimerTask {
                     JSONObject jo = readProvisioningJSON();
                     if (jo != null) {
                         doFetch = false;
-                        syncFeeds( jo.getJSONArray("feeds"));
-                        syncSubs(  jo.getJSONArray("subscriptions"));
-                        syncGroups(  jo.getJSONArray("groups")); //Rally:US708115 - 1610
+                        syncFeeds(jo.getJSONArray("feeds"));
+                        syncSubs(jo.getJSONArray("subscriptions"));
+                        syncGroups(jo.getJSONArray("groups")); //Rally:US708115 - 1610
                         syncParams(jo.getJSONObject("parameters"));
                         // The following will not be present in a version=1.0 provfeed
                         JSONArray ja = jo.optJSONArray("ingress");
-                        if (ja != null)
+                        if (ja != null) {
                             syncIngressRoutes(ja);
+                        }
                         JSONObject j2 = jo.optJSONObject("egress");
-                        if (j2 != null)
-                            syncEgressRoutes( j2);
+                        if (j2 != null) {
+                            syncEgressRoutes(j2);
+                        }
                         ja = jo.optJSONArray("routing");
-                        if (ja != null)
+                        if (ja != null) {
                             syncNetworkRoutes(ja);
+                        }
                     }
                     logger.info("PROV5013: Sync completed.");
                     nextsynctime = System.currentTimeMillis() + ONE_HOUR;
@@ -254,53 +271,61 @@ public class SynchronizerTask extends TimerTask {
             if (lfl.isIdle()) {
                 // Only fetch new logs if the loader is waiting for them.
                 logger.trace("Checking for logs to replicate...");
-                RLEBitSet local  = lfl.getBitSet();
+                RLEBitSet local = lfl.getBitSet();
                 RLEBitSet remote = readRemoteLoglist();
                 remote.andNot(local);
                 if (!remote.isEmpty()) {
-                    logger.debug(" Replicating logs: "+remote);
+                    logger.debug(" Replicating logs: " + remote);
                     replicateDRLogs(remote);
                 }
             }
         } catch (Exception e) {
-            logger.warn("PROV0020: Caught exception in SynchronizerTask: "+e);
+            logger.warn("PROV0020: Caught exception in SynchronizerTask: " + e);
             e.printStackTrace();
         }
     }
 
     /**
-     * This method is used to lookup the CNAME that points to the active server.
-     * It returns 0 (UNKNOWN), 1(ACTIVE), or 2 (STANDBY) to indicate the state of this server.
+     * This method is used to lookup the CNAME that points to the active server. It returns 0 (UNKNOWN), 1(ACTIVE), or 2
+     * (STANDBY) to indicate the state of this server.
+     *
      * @return the current state
      */
     private int lookupState() {
         int newstate = UNKNOWN;
         try {
             InetAddress myaddr = InetAddress.getLocalHost();
-            if (logger.isTraceEnabled())
-                logger.trace("My address: "+myaddr);
-            String this_pod = myaddr.getHostName();
-            Set<String> pods = new TreeSet<String>(Arrays.asList(BaseServlet.getPods()));
-            if (pods.contains(this_pod)) {
-                InetAddress pserver = InetAddress.getByName(BaseServlet.active_prov_name);
+            if (logger.isTraceEnabled()) {
+                logger.trace("My address: " + myaddr);
+            }
+            String thisPod = myaddr.getHostName();
+            Set<String> pods = new TreeSet<>(Arrays.asList(BaseServlet.getPods()));
+            if (pods.contains(thisPod)) {
+                InetAddress pserver = InetAddress.getByName(BaseServlet.activeProvName);
                 newstate = myaddr.equals(pserver) ? ACTIVE : STANDBY;
-                if (logger.isDebugEnabled() && System.currentTimeMillis() >= next_msg) {
-                    logger.debug("Active POD = "+pserver+", Current state is "+stnames[newstate]);
-                    next_msg = System.currentTimeMillis() + (5 * 60 * 1000L);
+                if (logger.isDebugEnabled() && System.currentTimeMillis() >= nextMsg) {
+                    logger.debug("Active POD = " + pserver + ", Current state is " + stnames[newstate]);
+                    nextMsg = System.currentTimeMillis() + (5 * 60 * 1000L);
                 }
             } else {
-                logger.warn("PROV5003: My name ("+this_pod+") is missing from the list of provisioning servers.");
+                logger.warn("PROV5003: My name (" + thisPod + ") is missing from the list of provisioning servers.");
             }
         } catch (UnknownHostException e) {
             logger.warn("PROV5002: Cannot determine the name of this provisioning server.");
         }
 
-        if (newstate != state)
-            logger.info(String.format("PROV5001: Server state changed from %s to %s", stnames[state], stnames[newstate]));
+        if (newstate != state) {
+            logger
+                .info(String.format("PROV5001: Server state changed from %s to %s", stnames[state], stnames[newstate]));
+        }
         return newstate;
     }
-    private static long next_msg = 0;    // only display the "Current state" msg every 5 mins.
-    /** Synchronize the Feeds in the JSONArray, with the Feeds in the DB. */
+
+    private static long nextMsg = 0;    // only display the "Current state" msg every 5 mins.
+
+    /**
+     * Synchronize the Feeds in the JSONArray, with the Feeds in the DB.
+     */
     private void syncFeeds(JSONArray ja) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (int n = 0; n < ja.length(); n++) {
@@ -308,13 +333,17 @@ public class SynchronizerTask extends TimerTask {
                 Feed f = new Feed(ja.getJSONObject(n));
                 coll.add(f);
             } catch (Exception e) {
-                logger.warn("PROV5004: Invalid object in feed: "+ja.optJSONObject(n));
+                logger.warn("PROV5004: Invalid object in feed: " + ja.optJSONObject(n));
             }
         }
-        if (sync(coll, Feed.getAllFeeds()))
+        if (sync(coll, Feed.getAllFeeds())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
-    /** Synchronize the Subscriptions in the JSONArray, with the Subscriptions in the DB. */
+
+    /**
+     * Synchronize the Subscriptions in the JSONArray, with the Subscriptions in the DB.
+     */
     private void syncSubs(JSONArray ja) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (int n = 0; n < ja.length(); n++) {
@@ -325,14 +354,17 @@ public class SynchronizerTask extends TimerTask {
                 Subscription s = new Subscription(j);
                 coll.add(s);
             } catch (Exception e) {
-                logger.warn("PROV5004: Invalid object in subscription: "+ja.optJSONObject(n));
+                logger.warn("PROV5004: Invalid object in subscription: " + ja.optJSONObject(n));
             }
         }
-        if (sync(coll, Subscription.getAllSubscriptions()))
+        if (sync(coll, Subscription.getAllSubscriptions())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
 
-    /**  Rally:US708115  - Synchronize the Groups in the JSONArray, with the Groups in the DB. */
+    /**
+     * Rally:US708115  - Synchronize the Groups in the JSONArray, with the Groups in the DB.
+     */
     private void syncGroups(JSONArray ja) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (int n = 0; n < ja.length(); n++) {
@@ -340,15 +372,18 @@ public class SynchronizerTask extends TimerTask {
                 Group g = new Group(ja.getJSONObject(n));
                 coll.add(g);
             } catch (Exception e) {
-                logger.warn("PROV5004: Invalid object in subscription: "+ja.optJSONObject(n));
+                logger.warn("PROV5004: Invalid object in subscription: " + ja.optJSONObject(n));
             }
         }
-        if (sync(coll, Group.getAllgroups()))
+        if (sync(coll, Group.getAllgroups())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
 
 
-    /** Synchronize the Parameters in the JSONObject, with the Parameters in the DB. */
+    /**
+     * Synchronize the Parameters in the JSONObject, with the Parameters in the DB.
+     */
     private void syncParams(JSONObject jo) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (String k : jo.keySet()) {
@@ -357,12 +392,13 @@ public class SynchronizerTask extends TimerTask {
                 v = jo.getString(k);
             } catch (JSONException e) {
                 try {
-                    v = ""+jo.getInt(k);
+                    v = "" + jo.getInt(k);
                 } catch (JSONException e1) {
                     JSONArray ja = jo.getJSONArray(k);
                     for (int i = 0; i < ja.length(); i++) {
-                        if (i > 0)
+                        if (i > 0) {
                             v += "|";
+                        }
                         v += ja.getString(i);
                     }
                 }
@@ -374,6 +410,7 @@ public class SynchronizerTask extends TimerTask {
             BaseServlet.provisioningParametersChanged();
         }
     }
+
     private void syncIngressRoutes(JSONArray ja) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (int n = 0; n < ja.length(); n++) {
@@ -381,12 +418,14 @@ public class SynchronizerTask extends TimerTask {
                 IngressRoute in = new IngressRoute(ja.getJSONObject(n));
                 coll.add(in);
             } catch (NumberFormatException e) {
-                logger.warn("PROV5004: Invalid object in ingress routes: "+ja.optJSONObject(n));
+                logger.warn("PROV5004: Invalid object in ingress routes: " + ja.optJSONObject(n));
             }
         }
-        if (sync(coll, IngressRoute.getAllIngressRoutes()))
+        if (sync(coll, IngressRoute.getAllIngressRoutes())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
+
     private void syncEgressRoutes(JSONObject jo) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (String key : jo.keySet()) {
@@ -396,14 +435,16 @@ public class SynchronizerTask extends TimerTask {
                 EgressRoute er = new EgressRoute(sub, node);
                 coll.add(er);
             } catch (NumberFormatException e) {
-                logger.warn("PROV5004: Invalid subid in egress routes: "+key);
+                logger.warn("PROV5004: Invalid subid in egress routes: " + key);
             } catch (IllegalArgumentException e) {
-                logger.warn("PROV5004: Invalid node name in egress routes: "+key);
+                logger.warn("PROV5004: Invalid node name in egress routes: " + key);
             }
         }
-        if (sync(coll, EgressRoute.getAllEgressRoutes()))
+        if (sync(coll, EgressRoute.getAllEgressRoutes())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
+
     private void syncNetworkRoutes(JSONArray ja) {
         Collection<Syncable> coll = new ArrayList<Syncable>();
         for (int n = 0; n < ja.length(); n++) {
@@ -411,12 +452,14 @@ public class SynchronizerTask extends TimerTask {
                 NetworkRoute nr = new NetworkRoute(ja.getJSONObject(n));
                 coll.add(nr);
             } catch (JSONException e) {
-                logger.warn("PROV5004: Invalid object in network routes: "+ja.optJSONObject(n));
+                logger.warn("PROV5004: Invalid object in network routes: " + ja.optJSONObject(n));
             }
         }
-        if (sync(coll, NetworkRoute.getAllNetworkRoutes()))
+        if (sync(coll, NetworkRoute.getAllNetworkRoutes())) {
             BaseServlet.provisioningDataChanged();
+        }
     }
+
     private boolean sync(Collection<? extends Syncable> newc, Collection<? extends Syncable> oldc) {
         boolean changes = false;
         try {
@@ -431,18 +474,21 @@ public class SynchronizerTask extends TimerTask {
                 Syncable newobj = newmap.get(n);
                 Syncable oldobj = oldmap.get(n);
                 if (oldobj == null) {
-                    if (logger.isDebugEnabled())
-                        logger.debug("  Inserting record: "+newobj);
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("  Inserting record: " + newobj);
+                    }
                     newobj.doInsert(conn);
                     changes = true;
                 } else if (newobj == null) {
-                    if (logger.isDebugEnabled())
-                        logger.debug("  Deleting record: "+oldobj);
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("  Deleting record: " + oldobj);
+                    }
                     oldobj.doDelete(conn);
                     changes = true;
                 } else if (!newobj.equals(oldobj)) {
-                    if (logger.isDebugEnabled())
-                        logger.debug("  Updating record: "+newobj);
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("  Updating record: " + newobj);
+                    }
                     newobj.doUpdate(conn);
 
                     /**Rally US708115
@@ -455,11 +501,12 @@ public class SynchronizerTask extends TimerTask {
             }
             db.release(conn);
         } catch (SQLException e) {
-            logger.warn("PROV5009: problem during sync, exception: "+e);
+            logger.warn("PROV5009: problem during sync, exception: " + e);
             e.printStackTrace();
         }
         return changes;
     }
+
     private Map<String, Syncable> getMap(Collection<? extends Syncable> c) {
         Map<String, Syncable> map = new HashMap<String, Syncable>();
         for (Syncable v : c) {
@@ -468,29 +515,28 @@ public class SynchronizerTask extends TimerTask {
         return map;
     }
 
-
     /**Change owner of FEED/SUBSCRIPTION*/
-    /**Rally US708115
-     * Change Ownership of FEED - 1610
-     *
-     * */
+    /**
+     * Rally US708115 Change Ownership of FEED - 1610
+     */
     private void checkChnageOwner(Syncable newobj, Syncable oldobj) {
-        if(newobj instanceof Feed) {
+        if (newobj instanceof Feed) {
             Feed oldfeed = (Feed) oldobj;
             Feed newfeed = (Feed) newobj;
 
-            if(!oldfeed.getPublisher().equals(newfeed.getPublisher())){
-                logger.info("PROV5013 -  Previous publisher: "+oldfeed.getPublisher() +": New publisher-"+newfeed.getPublisher());
+            if (!oldfeed.getPublisher().equals(newfeed.getPublisher())) {
+                logger.info("PROV5013 -  Previous publisher: " + oldfeed.getPublisher() + ": New publisher-" + newfeed
+                    .getPublisher());
                 oldfeed.setPublisher(newfeed.getPublisher());
                 oldfeed.changeOwnerShip();
             }
-        }
-        else if(newobj instanceof Subscription) {
+        } else if (newobj instanceof Subscription) {
             Subscription oldsub = (Subscription) oldobj;
             Subscription newsub = (Subscription) newobj;
 
-            if(!oldsub.getSubscriber().equals(newsub.getSubscriber())){
-                logger.info("PROV5013 -  Previous subscriber: "+oldsub.getSubscriber() +": New subscriber-"+newsub.getSubscriber());
+            if (!oldsub.getSubscriber().equals(newsub.getSubscriber())) {
+                logger.info("PROV5013 -  Previous subscriber: " + oldsub.getSubscriber() + ": New subscriber-" + newsub
+                    .getSubscriber());
                 oldsub.setSubscriber(newsub.getSubscriber());
                 oldsub.changeOwnerShip();
             }
@@ -500,43 +546,47 @@ public class SynchronizerTask extends TimerTask {
 
     /**
      * Issue a GET on the peer POD's /internal/prov/ URL to get a copy of its provisioning data.
+     *
      * @return the provisioning data (as a JONObject)
      */
     private synchronized JSONObject readProvisioningJSON() {
-        String url  = URLUtilities.generatePeerProvURL();
+        String url = URLUtilities.generatePeerProvURL();
         HttpGet get = new HttpGet(url);
         try {
             HttpResponse response = httpclient.execute(get);
             int code = response.getStatusLine().getStatusCode();
             if (code != HttpServletResponse.SC_OK) {
-                logger.warn("PROV5010: readProvisioningJSON failed, bad error code: "+code);
+                logger.warn("PROV5010: readProvisioningJSON failed, bad error code: " + code);
                 return null;
             }
             HttpEntity entity = response.getEntity();
             String ctype = entity.getContentType().getValue().trim();
-            if (!ctype.equals(BaseServlet.PROVFULL_CONTENT_TYPE1) && !ctype.equals(BaseServlet.PROVFULL_CONTENT_TYPE2)) {
-                logger.warn("PROV5011: readProvisioningJSON failed, bad content type: "+ctype);
+            if (!ctype.equals(BaseServlet.PROVFULL_CONTENT_TYPE1) && !ctype
+                .equals(BaseServlet.PROVFULL_CONTENT_TYPE2)) {
+                logger.warn("PROV5011: readProvisioningJSON failed, bad content type: " + ctype);
                 return null;
             }
             return new JSONObject(new JSONTokener(entity.getContent()));
         } catch (Exception e) {
-            logger.warn("PROV5012: readProvisioningJSON failed, exception: "+e);
+            logger.warn("PROV5012: readProvisioningJSON failed, exception: " + e);
             return null;
         } finally {
             get.releaseConnection();
         }
     }
+
     /**
-     * Issue a GET on the peer POD's /internal/drlogs/ URL to get an RELBitSet representing the
-     * log records available in the remote database.
+     * Issue a GET on the peer POD's /internal/drlogs/ URL to get an RELBitSet representing the log records available in
+     * the remote database.
+     *
      * @return the bitset
      */
     private RLEBitSet readRemoteLoglist() {
         RLEBitSet bs = new RLEBitSet();
-        String url  = URLUtilities.generatePeerLogsURL();
+        String url = URLUtilities.generatePeerLogsURL();
 
         //Fixing if only one Prov is configured, not to give exception to fill logs, return empty bitset.
-        if(url.equals("")) {
+        if (url.equals("")) {
             return bs;
         }
         //End of fix.
@@ -546,66 +596,70 @@ public class SynchronizerTask extends TimerTask {
             HttpResponse response = httpclient.execute(get);
             int code = response.getStatusLine().getStatusCode();
             if (code != HttpServletResponse.SC_OK) {
-                logger.warn("PROV5010: readRemoteLoglist failed, bad error code: "+code);
+                logger.warn("PROV5010: readRemoteLoglist failed, bad error code: " + code);
                 return bs;
             }
             HttpEntity entity = response.getEntity();
             String ctype = entity.getContentType().getValue().trim();
             if (!ctype.equals("text/plain")) {
-                logger.warn("PROV5011: readRemoteLoglist failed, bad content type: "+ctype);
+                logger.warn("PROV5011: readRemoteLoglist failed, bad content type: " + ctype);
                 return bs;
             }
             InputStream is = entity.getContent();
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             int ch = 0;
-            while ((ch = is.read()) >= 0)
+            while ((ch = is.read()) >= 0) {
                 bos.write(ch);
+            }
             bs.set(bos.toString());
             is.close();
         } catch (Exception e) {
-            logger.warn("PROV5012: readRemoteLoglist failed, exception: "+e);
+            logger.warn("PROV5012: readRemoteLoglist failed, exception: " + e);
             return bs;
         } finally {
             get.releaseConnection();
         }
         return bs;
     }
+
     /**
-     * Issue a POST on the peer POD's /internal/drlogs/ URL to fetch log records available
-     * in the remote database that we wish to copy to the local database.
+     * Issue a POST on the peer POD's /internal/drlogs/ URL to fetch log records available in the remote database that
+     * we wish to copy to the local database.
+     *
      * @param bs the bitset (an RELBitSet) of log records to fetch
      */
     private void replicateDRLogs(RLEBitSet bs) {
-        String url  = URLUtilities.generatePeerLogsURL();
+        String url = URLUtilities.generatePeerLogsURL();
         HttpPost post = new HttpPost(url);
         try {
             String t = bs.toString();
             HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create("text/plain"));
             post.setEntity(body);
-            if (logger.isDebugEnabled())
-                logger.debug("Requesting records: "+t);
+            if (logger.isDebugEnabled()) {
+                logger.debug("Requesting records: " + t);
+            }
 
             HttpResponse response = httpclient.execute(post);
             int code = response.getStatusLine().getStatusCode();
             if (code != HttpServletResponse.SC_OK) {
-                logger.warn("PROV5010: replicateDRLogs failed, bad error code: "+code);
+                logger.warn("PROV5010: replicateDRLogs failed, bad error code: " + code);
                 return;
             }
             HttpEntity entity = response.getEntity();
             String ctype = entity.getContentType().getValue().trim();
             if (!ctype.equals("text/plain")) {
-                logger.warn("PROV5011: replicateDRLogs failed, bad content type: "+ctype);
+                logger.warn("PROV5011: replicateDRLogs failed, bad content type: " + ctype);
                 return;
             }
 
             String spoolname = "" + System.currentTimeMillis();
             Path tmppath = Paths.get(spooldir, spoolname);
-            Path donepath = Paths.get(spooldir, "IN."+spoolname);
+            Path donepath = Paths.get(spooldir, "IN." + spoolname);
             Files.copy(entity.getContent(), Paths.get(spooldir, spoolname), StandardCopyOption.REPLACE_EXISTING);
             Files.move(tmppath, donepath, StandardCopyOption.REPLACE_EXISTING);
-            logger.info("Approximately "+bs.cardinality()+" records replicated.");
+            logger.info("Approximately " + bs.cardinality() + " records replicated.");
         } catch (Exception e) {
-            logger.warn("PROV5012: replicateDRLogs failed, exception: "+e);
+            logger.warn("PROV5012: replicateDRLogs failed, exception: " + e);
         } finally {
             post.releaseConnection();
         }