X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-node%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fnode%2FStatusLog.java;h=a9a48ade2b7e830d2f36c81299fa8d47582b3615;hp=e6165588bf26f6cda692f54474a52c612d9dd5b9;hb=5ad15107613e7aa41af1a0c1e61c3be2e608e4c4;hpb=0a440fd3ae3b413cd7de57677aec690f14ec7d53 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 e6165588..a9a48ade 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 @@ -37,7 +37,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * Logging for data router delivery events (PUB/DEL/EXP) + * Logging for data router delivery events (PUB/DEL/EXP). */ public class StatusLog { @@ -53,7 +53,7 @@ public class StatusLog { private long nexttime; private OutputStream os; private long intvl; - private NodeConfigManager config = NodeConfigManager.getInstance(); + private static NodeConfigManager config = NodeConfigManager.getInstance(); private StatusLog() { } @@ -64,9 +64,9 @@ public class StatusLog { */ public static long parseInterval(String interval, int def) { try { - Matcher m = Pattern.compile("(?:(\\d+)[Hh])?(?:(\\d+)[Mm])?(?:(\\d+)[Ss]?)?").matcher(interval); - if (m.matches()) { - int dur = getDur(m); + Matcher matcher = Pattern.compile("(?:(\\d+)[Hh])?(?:(\\d+)[Mm])?(?:(\\d+)[Ss]?)?").matcher(interval); + if (matcher.matches()) { + int dur = getDur(matcher); int best = 86400; int dist = best - dur; if (dur > best) { @@ -106,19 +106,19 @@ public class StatusLog { return best; } - private static int getDur(Matcher m) { + private static int getDur(Matcher matcher) { int dur = 0; - String x = m.group(1); - if (x != null) { - dur += 3600 * Integer.parseInt(x); + String match = matcher.group(1); + if (match != null) { + dur += 3600 * Integer.parseInt(match); } - x = m.group(2); - if (x != null) { - dur += 60 * Integer.parseInt(x); + match = matcher.group(2); + if (match != null) { + dur += 60 * Integer.parseInt(match); } - x = m.group(3); - if (x != null) { - dur += Integer.parseInt(x); + match = matcher.group(3); + if (match != null) { + dur += Integer.parseInt(match); } if (dur < 60) { dur = 60; @@ -127,7 +127,7 @@ public class StatusLog { } /** - * Get the name of the current log file + * Get the name of the current log file. * * @return The full path name of the current event log file */ @@ -158,10 +158,12 @@ public class StatusLog { instance.log( "PUB|" + pubid + "|" + feedid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + srcip + "|" + user + "|" + status); + eelfLogger.info("PUB|" + pubid + "|" + feedid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + srcip + + "|" + user + "|" + status); } /** - * Log a data transfer error receiving a publication attempt + * Log a data transfer error receiving a publication attempt. * * @param pubid The publish ID assigned by the node * @param feedid The feed id given by the publisher @@ -178,6 +180,8 @@ public class StatusLog { long rcvd, String srcip, String user, String error) { instance.log("PBF|" + pubid + "|" + feedid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + rcvd + "|" + srcip + "|" + user + "|" + error); + eelfLogger.info("PBF|" + pubid + "|" + feedid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + rcvd + + "|" + srcip + "|" + user + "|" + error); } /** @@ -202,10 +206,12 @@ public class StatusLog { instance.log( "DEL|" + pubid + "|" + feedid + "|" + subid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + user + "|" + status + "|" + xpubid); + eelfLogger.info("DEL|" + pubid + "|" + feedid + "|" + subid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + + "|" + user + "|" + status + "|" + xpubid); } /** - * Log delivery attempts expired + * Log delivery attempts expired. * * @param pubid The publish ID assigned by the node * @param feedid The feed ID @@ -225,6 +231,8 @@ public class StatusLog { instance.log( "EXP|" + pubid + "|" + feedid + "|" + subid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + "|" + reason + "|" + attempts); + eelfLogger.info("EXP|" + pubid + "|" + feedid + "|" + subid + "|" + requrl + "|" + method + "|" + ctype + "|" + clen + + "|" + reason + "|" + attempts); } /** @@ -235,13 +243,14 @@ public class StatusLog { * @param subid The (space delimited list of) subscription ID * @param clen The content length * @param sent The # of bytes sent or -1 if subscriber returned an error instead of 100 Continue, otherwise, the - * number of bytes sent before an error occurred. + * number of bytes sent before an error occurred. */ public static void logDelExtra(String pubid, String feedid, String subid, long clen, long sent) { if (feedid == null) { return; } instance.log("DLX|" + pubid + "|" + feedid + "|" + subid + "|" + clen + "|" + sent); + eelfLogger.info("DLX|" + pubid + "|" + feedid + "|" + subid + "|" + clen + "|" + sent); } private synchronized void checkRoll(long now) throws IOException { @@ -260,7 +269,7 @@ public class StatusLog { } } - private synchronized void log(String s) { + private synchronized void log(String string) { try { long now = System.currentTimeMillis(); checkRoll(now); @@ -269,7 +278,7 @@ public class StatusLog { (new File(plainfile)).delete(); Files.createLink(Paths.get(plainfile), Paths.get(curfile)); } - os.write((NodeUtils.logts(new Date(now)) + '|' + s + '\n').getBytes()); + os.write((NodeUtils.logts(new Date(now)) + '|' + string + '\n').getBytes()); os.flush(); } catch (IOException ioe) { eelfLogger.error("IOException", ioe);