Remove datarouter-node critical code smells 25/87225/3
authoreconwar <conor.ward@est.tech>
Wed, 8 May 2019 12:06:50 +0000 (12:06 +0000)
committereconwar <conor.ward@est.tech>
Wed, 8 May 2019 12:06:50 +0000 (12:06 +0000)
Change-Id: Iff0f9e2c4f326e75ee4bb5c8328c3a341468cf1b
Issue-ID: DMAAP-1195
Signed-off-by: econwar <conor.ward@est.tech>
13 files changed:
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java
datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java

index 30ad161..991d866 100644 (file)
@@ -74,7 +74,7 @@ public class DRNodeCadiFilter extends CadiFilter {
             try {
                 resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI.  Expecting <feed-publishing-url>/<fileid>.");
             } catch (IOException e) {
             try {
                 resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI.  Expecting <feed-publishing-url>/<fileid>.");
             } catch (IOException e) {
-                logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e.getMessage());
+                logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e);
             }
             return null;
         }
             }
             return null;
         }
@@ -88,7 +88,7 @@ public class DRNodeCadiFilter extends CadiFilter {
                 try {
                     resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI.  Expecting <feed-publishing-url>/<fileid>.  Possible missing fileid.");
                 } catch (IOException e) {
                 try {
                     resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI.  Expecting <feed-publishing-url>/<fileid>.  Possible missing fileid.");
                 } catch (IOException e) {
-                    logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e.getMessage());
+                    logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e);
                 }
                 return null;
             }
                 }
                 return null;
             }
index 501e489..4c21b34 100644 (file)
@@ -68,6 +68,24 @@ public class Delivery {
             this.pubid = pubid;
             this.spool = spool;
         }
             this.pubid = pubid;
             this.spool = spool;
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+            DelItem delItem = (DelItem) o;
+            return Objects.equals(pubid, delItem.pubid) &&
+                    Objects.equals(getSpool(), delItem.getSpool());
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(pubid, getSpool());
+        }
     }
 
     private double fdstart;
     }
 
     private double fdstart;
@@ -246,6 +264,7 @@ public class Delivery {
                 try {
                     wait(nextcheck + 500 - now);
                 } catch (Exception e) {
                 try {
                     wait(nextcheck + 500 - now);
                 } catch (Exception e) {
+                    logger.error("InterruptedException", e);
                 }
                 now = System.currentTimeMillis();
             }
                 }
                 now = System.currentTimeMillis();
             }
index bef8dab..3d48587 100644 (file)
@@ -24,6 +24,8 @@
 
 package org.onap.dmaap.datarouter.node;
 
 
 package org.onap.dmaap.datarouter.node;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import java.io.*;
 import java.util.*;
 
 import java.io.*;
 import java.util.*;
 
@@ -64,6 +66,7 @@ import java.util.*;
  * failure timer is active or if no files are found in a directory scan.
  */
 public class DeliveryQueue implements Runnable, DeliveryTaskHelper {
  * failure timer is active or if no files are found in a directory scan.
  */
 public class DeliveryQueue implements Runnable, DeliveryTaskHelper {
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(DeliveryQueue.class);
     private DeliveryQueueHelper deliveryQueueHelper;
     private DestInfo destinationInfo;
     private Hashtable<String, DeliveryTask> working = new Hashtable<>();
     private DeliveryQueueHelper deliveryQueueHelper;
     private DestInfo destinationInfo;
     private Hashtable<String, DeliveryTask> working = new Hashtable<>();
@@ -215,6 +218,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper {
                     try {
                         pidtime = Long.parseLong(fname2.substring(0, dot));
                     } catch (Exception e) {
                     try {
                         pidtime = Long.parseLong(fname2.substring(0, dot));
                     } catch (Exception e) {
+                        logger.error("Exception", e);
                     }
                     if (pidtime < 1000000000000L) {
                         continue;
                     }
                     if (pidtime < 1000000000000L) {
                         continue;
index cca6170..018c3af 100644 (file)
@@ -127,7 +127,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
                 hdrv.add(new String[]{h, v});
             }
         } catch (Exception e) {
                 hdrv.add(new String[]{h, v});
             }
         } catch (Exception e) {
-            eelfLogger.error("Exception "+ Arrays.toString(e.getStackTrace()), e.getMessage());
+            eelfLogger.error("Exception", e);
         }
         hdrs = hdrv.toArray(new String[hdrv.size()][]);
         url = deliveryTaskHelper.getDestURL(fileid);
         }
         hdrs = hdrv.toArray(new String[hdrv.size()][]);
         url = deliveryTaskHelper.getDestURL(fileid);
@@ -272,7 +272,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
                 outputStream.close();
             } catch (IOException e) {
                 httpURLConnection.setRequestProperty("Decompression_Status", "FAILURE");
                 outputStream.close();
             } catch (IOException e) {
                 httpURLConnection.setRequestProperty("Decompression_Status", "FAILURE");
-                eelfLogger.info("Could not decompress file");
+                eelfLogger.info("Could not decompress file", e);
                 sendFile(httpURLConnection);
             }
 
                 sendFile(httpURLConnection);
             }
 
index f7cedd2..534b2b3 100644 (file)
@@ -71,7 +71,7 @@ public class IsFrom {
                     hostAddrArray.add(addr.getHostAddress());
                 }
             } catch (UnknownHostException e) {
                     hostAddrArray.add(addr.getHostAddress());
                 }
             } catch (UnknownHostException e) {
-                logger.error("IsFrom: UnknownHostEx: " + e.toString(), e.getMessage());
+                logger.error("IsFrom: UnknownHostEx: " + e.toString(), e);
             }
             ips = hostAddrArray.toArray(new String[0]);
             logger.info("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips));
             }
             ips = hostAddrArray.toArray(new String[0]);
             logger.info("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips));
@@ -90,9 +90,9 @@ public class IsFrom {
                 return true;
             }
         } catch (UnknownHostException e) {
                 return true;
             }
         } catch (UnknownHostException e) {
-            logger.error("IsFrom: UnknownHostEx: " + e.toString(), e.getMessage());
+            logger.error("IsFrom: UnknownHostEx: " + e.toString(), e);
         } catch (IOException e) {
         } catch (IOException e) {
-            logger.error("IsFrom: Failed to parse IP : " + ip + " : " + e.toString(), e.getMessage());
+            logger.error("IsFrom: Failed to parse IP : " + ip + " : " + e.toString(), e);
         }
         return false;
     }
         }
         return false;
     }
index 78a195b..6ffb760 100644 (file)
@@ -22,6 +22,8 @@
  ******************************************************************************/
 package org.onap.dmaap.datarouter.node;
 
  ******************************************************************************/
 package org.onap.dmaap.datarouter.node;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -43,7 +45,7 @@ import java.util.regex.Pattern;
  */
 
 public class LogManager extends TimerTask {
  */
 
 public class LogManager extends TimerTask {
-
+    private EELFLogger logger = EELFManager.getInstance().getLogger(LogManager.class);
     private NodeConfigManager config;
     private Matcher isnodelog;
     private Matcher iseventlog;
     private NodeConfigManager config;
     private Matcher isnodelog;
     private Matcher iseventlog;
@@ -52,6 +54,7 @@ public class LogManager extends TimerTask {
     private String logdir;
 
     private class Uploader extends Thread implements DeliveryQueueHelper {
     private String logdir;
 
     private class Uploader extends Thread implements DeliveryQueueHelper {
+        private EELFLogger logger = EELFManager.getInstance().getLogger(Uploader.class);
 
         public long getInitFailureTimer() {
             return (10000L);
 
         public long getInitFailureTimer() {
             return (10000L);
@@ -117,6 +120,7 @@ public class LogManager extends TimerTask {
             try {
                 wait(10000);
             } catch (Exception e) {
             try {
                 wait(10000);
             } catch (Exception e) {
+                logger.error("InterruptedException", e);
             }
         }
 
             }
         }
 
@@ -148,6 +152,7 @@ public class LogManager extends TimerTask {
                 lastqueued = br.readLine();
                 br.close();
             } catch (Exception e) {
                 lastqueued = br.readLine();
                 br.close();
             } catch (Exception e) {
+                logger.error("Exception", e);
             }
             for (String fn : fns) {
                 if (!isnodelog.reset(fn).matches()) {
             }
             for (String fn : fns) {
                 if (!isnodelog.reset(fn).matches()) {
@@ -161,6 +166,7 @@ public class LogManager extends TimerTask {
                             Files.createLink(Paths.get(uploaddir + "/" + pid), Paths.get(logdir + "/" + fn));
                             Files.createLink(Paths.get(uploaddir + "/" + pid + ".M"), Paths.get(uploaddir + "/.meta"));
                         } catch (Exception e) {
                             Files.createLink(Paths.get(uploaddir + "/" + pid), Paths.get(logdir + "/" + fn));
                             Files.createLink(Paths.get(uploaddir + "/" + pid + ".M"), Paths.get(uploaddir + "/.meta"));
                         } catch (Exception e) {
+                            logger.error("Exception", e);
                         }
                     }
                 }
                         }
                     }
                 }
@@ -173,6 +179,7 @@ public class LogManager extends TimerTask {
                 (new File(uploaddir + "/.meta")).delete();
                 w.write(lastqueued + "\n");
             } catch (Exception e) {
                 (new File(uploaddir + "/.meta")).delete();
                 w.write(lastqueued + "\n");
             } catch (Exception e) {
+                logger.error("Exception", e);
             }
         }
     }
             }
         }
     }
@@ -189,6 +196,7 @@ public class LogManager extends TimerTask {
             isnodelog = Pattern.compile("node\\.log\\.\\d{8}").matcher("");
             iseventlog = Pattern.compile("events-\\d{12}\\.log").matcher("");
         } catch (Exception e) {
             isnodelog = Pattern.compile("node\\.log\\.\\d{8}").matcher("");
             iseventlog = Pattern.compile("events-\\d{12}\\.log").matcher("");
         } catch (Exception e) {
+            logger.error("Exception", e);
         }
         logdir = config.getLogDir();
         uploaddir = logdir + "/.spool";
         }
         logdir = config.getLogDir();
         uploaddir = logdir + "/.spool";
index 16099e6..884f7bf 100644 (file)
@@ -121,7 +121,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
                     .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")));
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("NodeConfigManager");
                     .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")));
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("NodeConfigManager");
-            eelfLogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR, System.getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"));
+            eelfLogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR, e, System.getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"));
         }
         provurl = drNodeProperties.getProperty("ProvisioningURL", "https://dmaap-dr-prov:8443/internal/prov");
         /*
         }
         provurl = drNodeProperties.getProperty("ProvisioningURL", "https://dmaap-dr-prov:8443/internal/prov");
         /*
@@ -144,7 +144,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
             provhost = (new URL(provurl)).getHost();
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("NodeConfigManager");
             provhost = (new URL(provurl)).getHost();
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("NodeConfigManager");
-            eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, provurl);
+            eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, e, provurl);
             System.exit(1);
         }
         eelfLogger.info("NODE0303 Provisioning server is " + provhost);
             System.exit(1);
         }
         eelfLogger.info("NODE0303 Provisioning server is " + provhost);
@@ -218,42 +218,52 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         try {
             initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
         try {
             initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_INIT_RETRY_INTERVAL", e);
         }
         try {
             waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL")) * 1000);
         } catch (Exception e) {
         }
         try {
             waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL")) * 1000);
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_FILE_PROCESS_INTERVAL", e);
         }
         try {
             maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
         }
         try {
             maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000);
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_MAX_RETRY_INTERVAL", e);
         }
         try {
             expirationtimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_AGE")) * 1000);
         } catch (Exception e) {
         }
         try {
             expirationtimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_AGE")) * 1000);
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_MAX_AGE", e);
         }
         try {
             failurebackoff = Double.parseDouble(getProvParam("DELIVERY_RETRY_RATIO"));
         } catch (Exception e) {
         }
         try {
             failurebackoff = Double.parseDouble(getProvParam("DELIVERY_RETRY_RATIO"));
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_RETRY_RATIO", e);
         }
         try {
             deliverythreads = Integer.parseInt(getProvParam("DELIVERY_THREADS"));
         } catch (Exception e) {
         }
         try {
             deliverythreads = Integer.parseInt(getProvParam("DELIVERY_THREADS"));
         } catch (Exception e) {
+            eelfLogger.error("Error parsing DELIVERY_THREADS", e);
         }
         try {
             fairfilelimit = Integer.parseInt(getProvParam("FAIR_FILE_LIMIT"));
         } catch (Exception e) {
         }
         try {
             fairfilelimit = Integer.parseInt(getProvParam("FAIR_FILE_LIMIT"));
         } catch (Exception e) {
+            eelfLogger.error("Error parsing FAIR_FILE_LIMIT", e);
         }
         try {
             fairtimelimit = (long) (Double.parseDouble(getProvParam("FAIR_TIME_LIMIT")) * 1000);
         } catch (Exception e) {
         }
         try {
             fairtimelimit = (long) (Double.parseDouble(getProvParam("FAIR_TIME_LIMIT")) * 1000);
         } catch (Exception e) {
+            eelfLogger.error("Error parsing FAIR_TIME_LIMIT", e);
         }
         try {
             fdpstart = Double.parseDouble(getProvParam("FREE_DISK_RED_PERCENT")) / 100.0;
         } catch (Exception e) {
         }
         try {
             fdpstart = Double.parseDouble(getProvParam("FREE_DISK_RED_PERCENT")) / 100.0;
         } catch (Exception e) {
+            eelfLogger.error("Error parsing FREE_DISK_RED_PERCENT", e);
         }
         try {
             fdpstop = Double.parseDouble(getProvParam("FREE_DISK_YELLOW_PERCENT")) / 100.0;
         } catch (Exception e) {
         }
         try {
             fdpstop = Double.parseDouble(getProvParam("FREE_DISK_YELLOW_PERCENT")) / 100.0;
         } catch (Exception e) {
+            eelfLogger.error("Error parsing FREE_DISK_YELLOW_PERCENT", e);
         }
         if (fdpstart < 0.01) {
             fdpstart = 0.01;
         }
         if (fdpstart < 0.01) {
             fdpstart = 0.01;
@@ -287,7 +297,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("fetchconfigs");
             eelfLogger.error(EelfMsgs.MESSAGE_CONF_FAILED, e.toString());
         } catch (Exception e) {
             NodeUtils.setIpAndFqdnForEelf("fetchconfigs");
             eelfLogger.error(EelfMsgs.MESSAGE_CONF_FAILED, e.toString());
-            eelfLogger.error("NODE0306 Configuration failed " + e.toString() + " - try again later", e.getMessage());
+            eelfLogger.error("NODE0306 Configuration failed " + e.toString() + " - try again later", e);
             pfetcher.request();
         }
     }
             pfetcher.request();
         }
     }
@@ -842,7 +852,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
             }
             return type + "|" + aafInstance + "|" + action;
         } catch (Exception e) {
             }
             return type + "|" + aafInstance + "|" + action;
         } catch (Exception e) {
-            eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e.getMessage());
+            eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e);
         }
         return null;
     }
         }
         return null;
     }
index 058295d..7a2691e 100644 (file)
@@ -56,7 +56,7 @@ public class NodeMain {
             try {
                 in = getClass().getClassLoader().getResourceAsStream("drNodeCadi.properties");
             } catch (Exception e) {
             try {
                 in = getClass().getClassLoader().getResourceAsStream("drNodeCadi.properties");
             } catch (Exception e) {
-                nodeMainLogger.error("Exception in Inner.getCadiProps() method " + e.getMessage());
+                nodeMainLogger.error("Exception in Inner.getCadiProps() method ", e);
             }
             return in;
         }
             }
             return in;
         }
@@ -181,7 +181,7 @@ public class NodeMain {
                         InputStream in = obj.getCadiProps();
                         cadiProperties.load(in);
                     } catch (IOException e1) {
                         InputStream in = obj.getCadiProps();
                         cadiProperties.load(in);
                     } catch (IOException e1) {
-                        nodeMainLogger.error("NODE00005 Exception in NodeMain.Main() loading CADI properties " + e1.getMessage());
+                        nodeMainLogger.error("NODE00005 Exception in NodeMain.Main() loading CADI properties ", e1);
                     }
                     cadiProperties.setProperty("aaf_locate_url", nodeConfigManager.getAafURL());
                     nodeMainLogger.info("NODE00005  aaf_url set to - " + cadiProperties.getProperty("aaf_url"));
                     }
                     cadiProperties.setProperty("aaf_locate_url", nodeConfigManager.getAafURL());
                     nodeMainLogger.info("NODE00005  aaf_url set to - " + cadiProperties.getProperty("aaf_url"));
@@ -199,7 +199,7 @@ public class NodeMain {
             server.start();
             nodeMainLogger.info("NODE00006 Node Server started-" + server.getState());
         } catch (Exception e) {
             server.start();
             nodeMainLogger.info("NODE00006 Node Server started-" + server.getState());
         } catch (Exception e) {
-            nodeMainLogger.info("NODE00006 Jetty failed to start. Reporting will we unavailable", e.getMessage());
+            nodeMainLogger.info("NODE00006 Jetty failed to start. Reporting will we unavailable", e);
         }
         server.join();
         nodeMainLogger.info("NODE00007 Node Server joined - " + server.getState());
         }
         server.join();
         nodeMainLogger.info("NODE00007 Node Server joined - " + server.getState());
index a984211..d665080 100644 (file)
@@ -117,7 +117,7 @@ public class NodeServlet extends HttpServlet {
                 }
 
             } catch (IOException ioe) {
                 }
 
             } catch (IOException ioe) {
-                eelfLogger.error("IOException" + ioe.getMessage());
+                eelfLogger.error("IOException", ioe);
             }
             String path = req.getPathInfo();
             String qs = req.getQueryString();
             }
             String path = req.getPathInfo();
             String qs = req.getQueryString();
@@ -158,7 +158,7 @@ public class NodeServlet extends HttpServlet {
         try {
             common(req, resp, true);
         } catch (IOException ioe) {
         try {
             common(req, resp, true);
         } catch (IOException ioe) {
-            eelfLogger.error("IOException" + ioe.getMessage());
+            eelfLogger.error("IOException", ioe);
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
@@ -176,7 +176,7 @@ public class NodeServlet extends HttpServlet {
         try {
             common(req, resp, false);
         } catch (IOException ioe) {
         try {
             common(req, resp, false);
         } catch (IOException ioe) {
-            eelfLogger.error("IOException " + ioe.getMessage());
+            eelfLogger.error("IOException", ioe);
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
@@ -437,7 +437,7 @@ public class NodeServlet extends HttpServlet {
                 try {
                     exlen = Long.parseLong(req.getHeader("Content-Length"));
                 } catch (Exception e) {
                 try {
                     exlen = Long.parseLong(req.getHeader("Content-Length"));
                 } catch (Exception e) {
-                    eelfLogger.error("NODE00000 Exception common: " + e.getMessage());
+                    eelfLogger.error("NODE00000 Exception common", e);
                 }
                 StatusLog.logPubFail(pubid, feedid, logurl, req.getMethod(), ctype, exlen, data.length(), ip, user, ioe.getMessage());
                 //Fortify scan fixes - log forging
                 }
                 StatusLog.logPubFail(pubid, feedid, logurl, req.getMethod(), ctype, exlen, data.length(), ip, user, ioe.getMessage());
                 //Fortify scan fixes - log forging
@@ -520,7 +520,7 @@ public class NodeServlet extends HttpServlet {
             }
         } catch (IOException ioe) {
             eelfLogger.error("NODE0117 Unable to delete files (" + pubid + ", " + pubid + ".M) from DR Node: "
             }
         } catch (IOException ioe) {
             eelfLogger.error("NODE0117 Unable to delete files (" + pubid + ", " + pubid + ".M) from DR Node: "
-                    + config.getMyName() + ". Error: " + ioe.getMessage());
+                    + config.getMyName(), ioe);
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
             eelfLogger.info(EelfMsgs.EXIT);
         }
     }
@@ -562,7 +562,8 @@ public class NodeServlet extends HttpServlet {
                 return false;
             }
         } catch (NullPointerException npe) {
                 return false;
             }
         } catch (NullPointerException npe) {
-            eelfLogger.error("NODE0114 " + errorMessage + " Error: Subscription " + subscriptionId + " does not exist");
+            eelfLogger.error("NODE0114 " + errorMessage + " Error: Subscription " + subscriptionId +
+                    " does not exist", npe);
             resp.sendError(HttpServletResponse.SC_NOT_FOUND);
             eelfLogger.info(EelfMsgs.EXIT);
             return false;
             resp.sendError(HttpServletResponse.SC_NOT_FOUND);
             eelfLogger.info(EelfMsgs.EXIT);
             return false;
index 4601f99..da84ae5 100644 (file)
@@ -126,7 +126,7 @@ public class NodeUtils {
             }
         } catch (Exception e) {
             setIpAndFqdnForEelf("getCanonicalName");
             }
         } catch (Exception e) {
             setIpAndFqdnForEelf("getCanonicalName");
-            eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_LOAD_ERROR, ksfile, e.toString());
+            eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_LOAD_ERROR, e, ksfile);
             return (null);
         }
         return (getCanonicalName(ks));
             return (null);
         }
         return (getCanonicalName(ks));
@@ -161,7 +161,7 @@ public class NodeUtils {
                 }
             }
         } catch (Exception e) {
                 }
             }
         } catch (Exception e) {
-            eelfLogger.error("NODE0402 Error extracting my name from my keystore file " + e.toString(), e.getMessage());
+            eelfLogger.error("NODE0402 Error extracting my name from my keystore file " + e.toString(), e);
         }
         return (null);
     }
         }
         return (null);
     }
@@ -283,7 +283,7 @@ public class NodeUtils {
         try {
             response.sendError(errorCode);
         } catch (IOException ioe) {
         try {
             response.sendError(errorCode);
         } catch (IOException ioe) {
-            intlogger.error("IOException" + ioe.getMessage());
+            intlogger.error("IOException", ioe);
         }
     }
 
         }
     }
 
index 7e4078f..4cd650b 100644 (file)
 
 package org.onap.dmaap.datarouter.node;
 
 
 package org.onap.dmaap.datarouter.node;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import java.io.BufferedReader;
 import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.BufferedReader;
 import java.io.FileOutputStream;
 import java.io.FileReader;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Hashtable;
 import java.util.Timer;
 import java.io.OutputStream;
 import java.util.Hashtable;
 import java.util.Timer;
@@ -35,7 +38,7 @@ import java.util.Timer;
  * Track redirections of subscriptions
  */
 public class RedirManager {
  * Track redirections of subscriptions
  */
 public class RedirManager {
-
+    private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(RedirManager.class);
     private Hashtable<String, String> sid2primary = new Hashtable<String, String>();
     private Hashtable<String, String> sid2secondary = new Hashtable<String, String>();
     private String redirfile;
     private Hashtable<String, String> sid2primary = new Hashtable<String, String>();
     private Hashtable<String, String> sid2secondary = new Hashtable<String, String>();
     private String redirfile;
@@ -63,6 +66,7 @@ public class RedirManager {
                         os.write(sb.toString().getBytes());
                     }
                 } catch (Exception e) {
                         os.write(sb.toString().getBytes());
                     }
                 } catch (Exception e) {
+                    eelfLogger.error("Exception", e);
                 }
             }
         };
                 }
             }
         };
@@ -80,7 +84,7 @@ public class RedirManager {
                 }
             }
         } catch (Exception e) {
                 }
             }
         } catch (Exception e) {
-            // missing file is normal
+            eelfLogger.error("Missing file is normal", e);
         }
     }
 
         }
     }
 
index c8a7bd0..1be3408 100644 (file)
@@ -23,6 +23,8 @@
 
 package org.onap.dmaap.datarouter.node;
 
 
 package org.onap.dmaap.datarouter.node;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import java.util.regex.*;
 import java.util.*;
 import java.io.*;
 import java.util.regex.*;
 import java.util.*;
 import java.io.*;
@@ -33,6 +35,7 @@ import java.text.*;
  * Logging for data router delivery events (PUB/DEL/EXP)
  */
 public class StatusLog {
  * Logging for data router delivery events (PUB/DEL/EXP)
  */
 public class StatusLog {
+    private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(StatusLog.class);
     private static StatusLog instance = new StatusLog();
     private HashSet<String> toship = new HashSet<String>();
     private SimpleDateFormat filedate;
     private static StatusLog instance = new StatusLog();
     private HashSet<String> toship = new HashSet<String>();
     private SimpleDateFormat filedate;
@@ -49,6 +52,7 @@ public class StatusLog {
         try {
             filedate = new SimpleDateFormat("-yyyyMMddHHmm");
         } catch (Exception e) {
         try {
             filedate = new SimpleDateFormat("-yyyyMMddHHmm");
         } catch (Exception e) {
+            eelfLogger.error("Exception", e);
         }
     }
 
         }
     }
 
@@ -104,6 +108,7 @@ public class StatusLog {
                 def = best * 1000;
             }
         } catch (Exception e) {
                 def = best * 1000;
             }
         } catch (Exception e) {
+            eelfLogger.error("Exception", e);
         }
         return (def);
     }
         }
         return (def);
     }
@@ -133,6 +138,7 @@ public class StatusLog {
         try {
             instance.checkRoll(System.currentTimeMillis());
         } catch (Exception e) {
         try {
             instance.checkRoll(System.currentTimeMillis());
         } catch (Exception e) {
+            eelfLogger.error("Exception", e);
         }
         return (instance.curfile);
     }
         }
         return (instance.curfile);
     }
@@ -149,6 +155,7 @@ public class StatusLog {
             os.write((NodeUtils.logts(new Date(now)) + '|' + s + '\n').getBytes());
             os.flush();
         } catch (IOException ioe) {
             os.write((NodeUtils.logts(new Date(now)) + '|' + s + '\n').getBytes());
             os.flush();
         } catch (IOException ioe) {
+            eelfLogger.error("IOException", ioe);
         }
     }
 
         }
     }
 
index 6dc334f..fa868b2 100644 (file)
@@ -45,20 +45,18 @@ public class DeliveryQueueTest {
     DeliveryQueueHelper deliveryQueueHelper;
 
     private String dirPath = "/tmp/dir001/";
     DeliveryQueueHelper deliveryQueueHelper;
 
     private String dirPath = "/tmp/dir001/";
-    private String FileName1 = "10000000000004.fileName.M";
+    private String fileName = "10000000000004.fileName.M";
 
     @Before
     public void setUp() {
 
     @Before
     public void setUp() {
-        when(destInfo.getSpool()).thenReturn("tmp");
+        when(destInfo.getSpool()).thenReturn(dirPath);
         deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
     }
 
     @Test
     public void Given_New_DeliveryQueue_Directory_Is_Created_As_Defined_By_DestInfo() {
         deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
     }
 
     @Test
     public void Given_New_DeliveryQueue_Directory_Is_Created_As_Defined_By_DestInfo() {
-        when(destInfo.getSpool()).thenReturn("tmp");
-        File file = new File("tmp");
+        File file = new File("/tmp");
         assertTrue(file.exists());
         assertTrue(file.exists());
-        deleteFile("tmp");
     }
 
     @Test
     }
 
     @Test
@@ -75,7 +73,7 @@ public class DeliveryQueueTest {
         deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
         DeliveryTask nt = deliveryQueue.getNext();
         assertEquals("10000000000004.fileName", nt.getPublishId());
         deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
         DeliveryTask nt = deliveryQueue.getNext();
         assertEquals("10000000000004.fileName", nt.getPublishId());
-        deleteFile(dirPath + FileName1);
+        deleteFile(dirPath + fileName);
         deleteFile(dirPath);
     }
 
         deleteFile(dirPath);
     }
 
@@ -87,9 +85,7 @@ public class DeliveryQueueTest {
 
     private void prepareFiles() throws Exception {
         createFolder(dirPath);
 
     private void prepareFiles() throws Exception {
         createFolder(dirPath);
-        createFile(FileName1, dirPath);
-        String[] files = new String[2];
-        files[0] = dirPath + FileName1;
+        createFile(fileName, dirPath);
     }
 
     private void createFolder(String dirName) {
     }
 
     private void createFolder(String dirName) {