diff options
Diffstat (limited to 'datarouter-node/src')
17 files changed, 202 insertions, 72 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java index 30ad1618..991d8660 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java @@ -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) { - logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e.getMessage()); + logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e); } 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) { - logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e.getMessage()); + logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e); } return null; } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java index 501e489c..4c21b342 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java @@ -68,6 +68,24 @@ public class Delivery { 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; @@ -246,6 +264,7 @@ public class Delivery { try { wait(nextcheck + 500 - now); } catch (Exception e) { + logger.error("InterruptedException", e); } now = System.currentTimeMillis(); } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java index bef8dab2..3d485878 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java @@ -24,6 +24,8 @@ package org.onap.dmaap.datarouter.node; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; 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 { + private static EELFLogger logger = EELFManager.getInstance().getLogger(DeliveryQueue.class); 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) { + logger.error("Exception", e); } if (pidtime < 1000000000000L) { continue; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java index cca61707..018c3aff 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java @@ -127,7 +127,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> { 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); @@ -272,7 +272,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> { 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); } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java index 8aa339f5..8890fe96 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java @@ -41,35 +41,105 @@ public class DestInfo { private boolean decompress; private boolean followRedirects; private String aafInstance; - /** - * Create a destination information object. - * - * @param name n:fqdn or s:subid - * @param spool The directory where files are spooled. - * @param subid The subscription ID (if applicable). - * @param logdata Text to be included in log messages - * @param url The URL to deliver to. - * @param authuser The auth user for logging. - * @param authentication The credentials. - * @param metaonly Is this a metadata only delivery? - * @param use100 Should I use expect 100-continue? - * @param privilegedSubscriber Can we wait to receive a file processed acknowledgement before deleting file - * @param followRedirects Is follow redirect of destination enabled? - * @param decompress To see if the they want there information compressed or decompressed - */ - public DestInfo(String name, String spool, String subid, String logdata, String url, String authuser, String authentication, boolean metaonly, boolean use100, boolean privilegedSubscriber, boolean followRedirects, boolean decompress) { - this.name = name; - this.spool = spool; - this.subid = subid; - this.logdata = logdata; - this.url = url; - this.authuser = authuser; - this.authentication = authentication; - this.metaonly = metaonly; - this.use100 = use100; - this.privilegedSubscriber = privilegedSubscriber; - this.followRedirects = followRedirects; - this.decompress = decompress; + + public static class DestInfoBuilder { + private String name; + private String spool; + private String subid; + private String logdata; + private String url; + private String authuser; + private String authentication; + private boolean metaonly; + private boolean use100; + private boolean privilegedSubscriber; + private boolean followRedirects; + private boolean decompress; + private NodeConfig.ProvSubscription subscription; + + public DestInfoBuilder setName(String name) { + this.name = name; + return this; + } + + public DestInfoBuilder setSpool(String spool) { + this.spool = spool; + return this; + } + + public DestInfoBuilder setSubid(String subid) { + this.subid = subid; + return this; + } + + public DestInfoBuilder setLogdata(String logdata) { + this.logdata = logdata; + return this; + } + + public DestInfoBuilder setUrl(String url) { + this.url = url; + return this; + } + + public DestInfoBuilder setAuthuser(String authuser) { + this.authuser = authuser; + return this; + } + + public DestInfoBuilder setAuthentication(String authentication) { + this.authentication = authentication; + return this; + } + + public DestInfoBuilder setMetaonly(boolean metaonly) { + this.metaonly = metaonly; + return this; + } + + public DestInfoBuilder setUse100(boolean use100) { + this.use100 = use100; + return this; + } + + public DestInfoBuilder setPrivilegedSubscriber(boolean privilegedSubscriber) { + this.privilegedSubscriber = privilegedSubscriber; + return this; + } + + public DestInfoBuilder setFollowRedirects(boolean followRedirects) { + this.followRedirects = followRedirects; + return this; + } + + public DestInfoBuilder setDecompress(boolean decompress) { + this.decompress = decompress; + return this; + } + + public DestInfoBuilder setSubscription(NodeConfig.ProvSubscription subscription) { + this.subscription = subscription; + return this; + } + + public DestInfo createDestInfo() { + return new DestInfo(this); + } + } + + public DestInfo(DestInfoBuilder destInfoBuilder) { + this.name = destInfoBuilder.name; + this.spool = destInfoBuilder.spool; + this.subid = destInfoBuilder.subid; + this.logdata = destInfoBuilder.logdata; + this.url = destInfoBuilder.url; + this.authuser = destInfoBuilder.authuser; + this.authentication = destInfoBuilder.authentication; + this.metaonly = destInfoBuilder.metaonly; + this.use100 = destInfoBuilder.use100; + this.privilegedSubscriber = destInfoBuilder.privilegedSubscriber; + this.followRedirects = destInfoBuilder.followRedirects; + this.decompress = destInfoBuilder.decompress; } /** diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java index f7cedd22..534b2b35 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java @@ -71,7 +71,7 @@ public class IsFrom { 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)); @@ -90,9 +90,9 @@ public class IsFrom { return true; } } catch (UnknownHostException e) { - logger.error("IsFrom: UnknownHostEx: " + e.toString(), e.getMessage()); + logger.error("IsFrom: UnknownHostEx: " + e.toString(), 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; } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java index 3fa5dc29..6ffb7604 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java @@ -22,6 +22,8 @@ ******************************************************************************/ 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; @@ -43,7 +45,7 @@ import java.util.regex.Pattern; */ public class LogManager extends TimerTask { - + private EELFLogger logger = EELFManager.getInstance().getLogger(LogManager.class); 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 EELFLogger logger = EELFManager.getInstance().getLogger(Uploader.class); public long getInitFailureTimer() { return (10000L); @@ -104,7 +107,10 @@ public class LogManager extends TimerTask { public Uploader() { dq = new DeliveryQueue(this, - new DestInfo("LogUpload", uploaddir, null, null, null, config.getMyName(), config.getMyAuth(), false, false, false, false, false)); + new DestInfo.DestInfoBuilder().setName("LogUpload").setSpool(uploaddir).setSubid(null).setLogdata(null) + .setUrl(null).setAuthuser(config.getMyName()).setAuthentication(config.getMyAuth()) + .setMetaonly(false).setUse100(false).setPrivilegedSubscriber(false).setFollowRedirects(false) + .setDecompress(false).createDestInfo()); setDaemon(true); setName("Log Uploader"); start(); @@ -114,6 +120,7 @@ public class LogManager extends TimerTask { try { wait(10000); } catch (Exception e) { + logger.error("InterruptedException", e); } } @@ -145,6 +152,7 @@ public class LogManager extends TimerTask { lastqueued = br.readLine(); br.close(); } catch (Exception e) { + logger.error("Exception", e); } for (String fn : fns) { if (!isnodelog.reset(fn).matches()) { @@ -158,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) { + logger.error("Exception", e); } } } @@ -170,6 +179,7 @@ public class LogManager extends TimerTask { (new File(uploaddir + "/.meta")).delete(); w.write(lastqueued + "\n"); } catch (Exception e) { + logger.error("Exception", e); } } } @@ -186,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) { + logger.error("Exception", e); } logdir = config.getLogDir(); uploaddir = logdir + "/.spool"; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java index 23512a14..d455f2d9 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java @@ -559,8 +559,10 @@ public class NodeConfig { continue; } String auth = NodeUtils.getNodeAuthHdr(cName, nodeauthkey); - DestInfo di = new DestInfo("n:" + cName, spooldir + "/n/" + cName, null, "n2n-" + cName, - "https://" + cName + ":" + port + "/internal/publish", cName, myauth, false, true, false, false, false); + DestInfo di = new DestInfo.DestInfoBuilder().setName("n:" + cName).setSpool(spooldir + "/n/" + cName).setSubid(null) + .setLogdata("n2n-" + cName).setUrl("https://" + cName + ":" + port + "/internal/publish") + .setAuthuser(cName).setAuthentication(myauth).setMetaonly(false).setUse100(true) + .setPrivilegedSubscriber(false).setFollowRedirects(false).setDecompress(false).createDestInfo(); (new File(di.getSpool())).mkdirs(); destInfos.add(di); nodeinfo.put(cName, di); diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java index 16099e62..884f7bf9 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java @@ -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"); - 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"); /* @@ -144,7 +144,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { 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); @@ -218,42 +218,52 @@ public class NodeConfigManager implements DeliveryQueueHelper { 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) { + eelfLogger.error("Error parsing DELIVERY_FILE_PROCESS_INTERVAL", 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) { + eelfLogger.error("Error parsing DELIVERY_MAX_AGE", 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) { + eelfLogger.error("Error parsing DELIVERY_THREADS", 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) { + eelfLogger.error("Error parsing FAIR_TIME_LIMIT", 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) { + eelfLogger.error("Error parsing FREE_DISK_YELLOW_PERCENT", e); } 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()); - 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(); } } @@ -842,7 +852,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { } return type + "|" + aafInstance + "|" + action; } catch (Exception e) { - eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e.getMessage()); + eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e); } return null; } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java index 058295d3..7a2691e4 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java @@ -56,7 +56,7 @@ public class NodeMain { 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; } @@ -181,7 +181,7 @@ public class NodeMain { 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")); @@ -199,7 +199,7 @@ public class NodeMain { 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()); diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java index a9842116..d665080b 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java @@ -117,7 +117,7 @@ public class NodeServlet extends HttpServlet { } } catch (IOException ioe) { - eelfLogger.error("IOException" + ioe.getMessage()); + eelfLogger.error("IOException", ioe); } 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) { - eelfLogger.error("IOException" + ioe.getMessage()); + eelfLogger.error("IOException", ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -176,7 +176,7 @@ public class NodeServlet extends HttpServlet { try { common(req, resp, false); } catch (IOException ioe) { - eelfLogger.error("IOException " + ioe.getMessage()); + eelfLogger.error("IOException", ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -437,7 +437,7 @@ public class NodeServlet extends HttpServlet { 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 @@ -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: " - + config.getMyName() + ". Error: " + ioe.getMessage()); + + config.getMyName(), ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -562,7 +562,8 @@ public class NodeServlet extends HttpServlet { 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; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java index 4601f99c..da84ae54 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java @@ -126,7 +126,7 @@ public class NodeUtils { } } 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)); @@ -161,7 +161,7 @@ public class NodeUtils { } } } 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); } @@ -283,7 +283,7 @@ public class NodeUtils { try { response.sendError(errorCode); } catch (IOException ioe) { - intlogger.error("IOException" + ioe.getMessage()); + intlogger.error("IOException", ioe); } } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java index 7e4078f8..4cd650b0 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java @@ -24,9 +24,12 @@ 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.IOException; 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 { - + 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; @@ -63,6 +66,7 @@ public class RedirManager { os.write(sb.toString().getBytes()); } } catch (Exception e) { + eelfLogger.error("Exception", e); } } }; @@ -80,7 +84,7 @@ public class RedirManager { } } } catch (Exception e) { - // missing file is normal + eelfLogger.error("Missing file is normal", e); } } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java index c8a7bd0c..1be3408a 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java @@ -23,6 +23,8 @@ 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.*; @@ -33,6 +35,7 @@ import java.text.*; * 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; @@ -49,6 +52,7 @@ public class StatusLog { 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) { + eelfLogger.error("Exception", e); } return (def); } @@ -133,6 +138,7 @@ public class StatusLog { try { instance.checkRoll(System.currentTimeMillis()); } catch (Exception e) { + eelfLogger.error("Exception", e); } 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) { + eelfLogger.error("IOException", ioe); } } diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java index 6dc334fc..fa868b26 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java @@ -45,20 +45,18 @@ public class DeliveryQueueTest { DeliveryQueueHelper deliveryQueueHelper; private String dirPath = "/tmp/dir001/"; - private String FileName1 = "10000000000004.fileName.M"; + private String fileName = "10000000000004.fileName.M"; @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() { - when(destInfo.getSpool()).thenReturn("tmp"); - File file = new File("tmp"); + File file = new File("/tmp"); assertTrue(file.exists()); - deleteFile("tmp"); } @Test @@ -75,7 +73,7 @@ public class DeliveryQueueTest { deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo); DeliveryTask nt = deliveryQueue.getNext(); assertEquals("10000000000004.fileName", nt.getPublishId()); - deleteFile(dirPath + FileName1); + deleteFile(dirPath + fileName); deleteFile(dirPath); } @@ -87,9 +85,7 @@ public class DeliveryQueueTest { 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) { diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java index efa43e11..08120073 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java @@ -97,7 +97,10 @@ public class DeliveryTest { private DestInfo[] createDestInfoObjects() { DestInfo[] destInfos = new DestInfo[1]; - DestInfo destInfo = new DestInfo("node.datarouternew.com", "spool/s/0/1", "1", "logs/", "/subs/1", "user1", "Basic dXNlcjE6cGFzc3dvcmQx", false, true, false, false, false); + DestInfo destInfo = new DestInfo.DestInfoBuilder().setName("node.datarouternew.com").setSpool("spool/s/0/1").setSubid("1") + .setLogdata("logs/").setUrl("/subs/1").setAuthuser("user1").setAuthentication("Basic dXNlcjE6cGFzc3dvcmQx") + .setMetaonly(false).setUse100(true).setPrivilegedSubscriber(false).setFollowRedirects(false) + .setDecompress(false).createDestInfo(); destInfos[0] = destInfo; return destInfos; } diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java index 7dddd67a..5e357373 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java @@ -36,7 +36,8 @@ import java.io.Reader; import java.io.StringReader; @RunWith(PowerMockRunner.class) -@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.ProvData", "org.onap.dmaap.datarouter.node.NodeUtils"}) +@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.ProvData", + "org.onap.dmaap.datarouter.node.NodeUtils"}) public class NodeConfigTest { private static NodeConfig nodeConfig; @@ -72,7 +73,7 @@ public class NodeConfigTest { } @Test - public void Given_SubId_Then_Get_Feed_Id_Returns_Correct_Id() { + public void Given_SubId_Then_Get_Feed_Id_Returns_Correct_Id(){ String feedId = nodeConfig.getFeedId("1"); Assert.assertEquals("1", feedId); } @@ -134,13 +135,15 @@ public class NodeConfigTest { @Test public void Given_Same_Ip_Then_Is_Another_Node_Returns_False() { - Boolean isAnotherNode = nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.1"); + Boolean isAnotherNode = + nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.1"); Assert.assertFalse(isAnotherNode); } @Test public void Given_Different_Ip_Then_Is_Another_Node_Returns_True() { - Boolean isAnotherNode = nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.4"); + Boolean isAnotherNode = + nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.4"); Assert.assertTrue(isAnotherNode); } |