diff options
author | Fiachra Corcoran <fiachra.corcoran@est.tech> | 2019-07-25 13:59:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-25 13:59:27 +0000 |
commit | 06271b9df78dadfdab95dc2f6f853cdaa3148d9d (patch) | |
tree | 95191017911ea0c62a527ba495ac58710ec25c80 /datarouter-node/src/main/java/org | |
parent | f20778ffa99aa9c6f30a0f84112a5392b259ea63 (diff) | |
parent | 5ad15107613e7aa41af1a0c1e61c3be2e608e4c4 (diff) |
Merge "Logging changes and unit tests"
Diffstat (limited to 'datarouter-node/src/main/java/org')
11 files changed, 127 insertions, 44 deletions
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 150d2aa2..82a4e9f0 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 @@ -126,14 +126,14 @@ public class Delivery { DelItem[] items = cv.toArray(new DelItem[cv.size()]); Arrays.sort(items); long stop = (long) (tspace * fdstop); - logger.info( + logger.warn( "NODE0501 Free disk space below red threshold. current=" + cur + " red=" + start + TOTAL + tspace); if (determineFreeDiskSpace(spoolfile, tspace, stop, cur, items)) { return; } cur = spoolfile.getUsableSpace(); if (cur >= stop) { - logger.info("NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop + logger.warn("NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop + TOTAL + tspace); return; } @@ -248,7 +248,7 @@ public class Delivery { private boolean determineFreeDiskSpace(File spoolfile, long tspace, long stop, long cur, DelItem[] items) { for (DelItem item : items) { long amount = dqs.get(item.getSpool()).cancelTask(item.getPublishId()); - logger.info("NODE0502 Attempting to discard " + item.getSpool() + "/" + item.getPublishId() + logger.debug("NODE0502 Attempting to discard " + item.getSpool() + "/" + item.getPublishId() + " to free up disk"); if (amount > 0) { cur += amount; @@ -256,7 +256,7 @@ public class Delivery { cur = spoolfile.getUsableSpace(); } if (cur >= stop) { - logger.info( + logger.warn( "NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop + TOTAL + tspace); return true; 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 0ba9ecfd..a3df26ac 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 @@ -117,7 +117,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { */ private synchronized void markSuccess(DeliveryTask task) { working.remove(task.getPublishId()); - logger.debug(task.getPublishId() + " marked as success."); + logger.info(task.getPublishId() + " marked as success."); task.clean(); failed = false; failduration = 0; @@ -127,7 +127,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { * Mark that a delivery task has expired. */ private synchronized void markExpired(DeliveryTask task) { - logger.debug(task.getPublishId() + " marked as expired."); + logger.info(task.getPublishId() + " marked as expired."); task.clean(); } @@ -136,7 +136,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { */ private synchronized void markFailNoRetry(DeliveryTask task) { working.remove(task.getPublishId()); - logger.debug(task.getPublishId() + " marked as failed permanently"); + logger.info(task.getPublishId() + " marked as failed permanently"); task.clean(); failed = false; failduration = 0; @@ -166,7 +166,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { */ private synchronized void markRedirect(DeliveryTask task) { working.remove(task.getPublishId()); - logger.debug(task.getPublishId() + " marked as redirected."); + logger.info(task.getPublishId() + " marked as redirected."); retry.put(task.getPublishId(), task); } @@ -175,7 +175,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { */ private synchronized void markFailWithRetry(DeliveryTask task) { working.remove(task.getPublishId()); - logger.debug(task.getPublishId() + " marked as temporarily failed."); + logger.info(task.getPublishId() + " marked as temporarily failed."); retry.put(task.getPublishId(), task); fdupdate(); } @@ -334,7 +334,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { long endtime = System.currentTimeMillis() + deliveryQueueHelper.getFairTimeLimit(); int filestogo = deliveryQueueHelper.getFairFileLimit(); while ((task = getNext()) != null) { - logger.debug("Processing file: " + task.getPublishId()); + logger.info("Processing file: " + task.getPublishId()); task.run(); if (--filestogo <= 0 || System.currentTimeMillis() > endtime) { break; 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 49852680..91622b3c 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 @@ -75,7 +75,7 @@ public class IsFrom { logger.error("IsFrom: UnknownHostEx: " + e.toString(), e); } ips = hostAddrArray.toArray(new String[0]); - logger.info("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips)); + logger.debug("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips)); } for (String ipAddr : ips) { if (ipAddr.equals(ip)) { 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 786befce..be77d244 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 @@ -109,7 +109,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { Properties drNodeProperties = new Properties(); try { - eelfLogger.info("NODE0301 Loading local config file node.properties"); + eelfLogger.debug("NODE0301 Loading local config file node.properties"); drNodeProperties.load(new FileInputStream(System .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"))); } catch (Exception e) { @@ -142,7 +142,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, e, provurl); System.exit(1); } - eelfLogger.info("NODE0303 Provisioning server is " + provhost); + eelfLogger.debug("NODE0303 Provisioning server is " + provhost); eventlogurl = drNodeProperties.getProperty("LogUploadURL", "https://feeds-drtr.web.att.com/internal/logs"); provcheck = new IsFrom(provhost); gfport = Integer.parseInt(drNodeProperties.getProperty("IntHttpPort", "8080")); @@ -183,7 +183,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { eelfLogger.error("NODE0309 Unable to fetch canonical name from keystore file " + ksfile); System.exit(1); } - eelfLogger.info("NODE0304 My certificate says my name is " + myname); + eelfLogger.debug("NODE0304 My certificate says my name is " + myname); pid = new PublishId(myname); long minrsinterval = Long.parseLong(drNodeProperties.getProperty("MinRedirSaveInterval", "10000")); long minpfinterval = Long.parseLong(drNodeProperties.getProperty("MinProvFetchInterval", "10000")); @@ -193,7 +193,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { fetchconfig(); } }; - eelfLogger.info("NODE0305 Attempting to fetch configuration at " + provurl); + eelfLogger.debug("NODE0305 Attempting to fetch configuration at " + provurl); pfetcher.request(); } @@ -284,7 +284,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { private void fetchconfig() { try { - eelfLogger.info("NodeConfigMan.fetchConfig: provurl:: " + provurl); + eelfLogger.debug("NodeConfigMan.fetchConfig: provurl:: " + provurl); Reader reader = new InputStreamReader((new URL(provurl)).openStream()); config = new NodeConfig(new ProvData(reader), myname, spooldir, port, nak); localconfig(); @@ -316,10 +316,10 @@ public class NodeConfigManager implements DeliveryQueueHelper { */ public synchronized void gofetch(String remoteAddr) { if (provcheck.isReachable(remoteAddr)) { - eelfLogger.info("NODE0307 Received configuration fetch request from provisioning server " + remoteAddr); + eelfLogger.debug("NODE0307 Received configuration fetch request from provisioning server " + remoteAddr); pfetcher.request(); } else { - eelfLogger.info("NODE0308 Received configuration fetch request from unexpected server " + remoteAddr); + eelfLogger.debug("NODE0308 Received configuration fetch request from unexpected server " + remoteAddr); } } @@ -596,15 +596,15 @@ public class NodeConfigManager implements DeliveryQueueHelper { if (provcheck.isFrom(remoteaddr)) { String sdir = config.getSpoolDir(subid); if (sdir != null) { - eelfLogger.info("NODE0310 Received subscription reset request for subscription " + subid + eelfLogger.debug("NODE0310 Received subscription reset request for subscription " + subid + " from provisioning server " + remoteaddr); } else { - eelfLogger.info("NODE0311 Received subscription reset request for unknown subscription " + subid + eelfLogger.debug("NODE0311 Received subscription reset request for unknown subscription " + subid + " from provisioning server " + remoteaddr); } return (sdir); } else { - eelfLogger.info("NODE0312 Received subscription reset request from unexpected server " + remoteaddr); + eelfLogger.debug("NODE0312 Received subscription reset request from unexpected server " + remoteaddr); 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 abec7393..6086168b 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 @@ -71,10 +71,10 @@ public class NodeMain { * system property. By default, it is "/opt/app/datartr/etc/node.properties". */ public static void main(String[] args) throws Exception { - nodeMainLogger.info("NODE0001 Data Router Node Starting"); + nodeMainLogger.debug("NODE0001 Data Router Node Starting"); IsFrom.setDNSCache(); nodeConfigManager = NodeConfigManager.getInstance(); - nodeMainLogger.info("NODE0002 I am " + nodeConfigManager.getMyName()); + nodeMainLogger.debug("NODE0002 I am " + nodeConfigManager.getMyName()); (new WaitForConfig(nodeConfigManager)).waitForConfig(); delivery = new Delivery(nodeConfigManager); new LogManager(nodeConfigManager); @@ -112,11 +112,11 @@ public class NodeMain { sslContextFactory.addExcludeProtocols("SSLv3"); sslContextFactory.setIncludeProtocols(nodeConfigManager.getEnabledprotocols()); - nodeMainLogger.info("NODE00004 Unsupported protocols node server:-" + nodeMainLogger.debug("NODE00004 Unsupported protocols node server:-" + String.join(",", sslContextFactory.getExcludeProtocols())); - nodeMainLogger.info("NODE00004 Supported protocols node server:-" + nodeMainLogger.debug("NODE00004 Supported protocols node server:-" + String.join(",", sslContextFactory.getIncludeProtocols())); - nodeMainLogger.info("NODE00004 Unsupported ciphers node server:-" + nodeMainLogger.debug("NODE00004 Unsupported ciphers node server:-" + String.join(",", sslContextFactory.getExcludeCipherSuites())); HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration); @@ -153,12 +153,12 @@ public class NodeMain { try { server.start(); - nodeMainLogger.info("NODE00006 Node Server started-" + server.getState()); + nodeMainLogger.debug("NODE00006 Node Server started-" + server.getState()); } catch (Exception e) { - nodeMainLogger.info("NODE00006 Jetty failed to start. Reporting will we unavailable: " + e.getMessage(), e); + nodeMainLogger.error("NODE00006 Jetty failed to start. Reporting will we unavailable: " + e.getMessage(), e); } server.join(); - nodeMainLogger.info("NODE00007 Node Server joined - " + server.getState()); + nodeMainLogger.debug("NODE00007 Node Server joined - " + server.getState()); } private static void enableCadi(ServletContextHandler servletContextHandler) throws ServletException { @@ -172,7 +172,7 @@ public class NodeMain { .error("NODE00005 Exception in NodeMain.Main() loading CADI properties " + e1.getMessage(), e1); } cadiProperties.setProperty("aaf_locate_url", nodeConfigManager.getAafURL()); - nodeMainLogger.info("NODE00005 aaf_url set to - " + cadiProperties.getProperty("aaf_url")); + nodeMainLogger.debug("NODE00005 aaf_url set to - " + cadiProperties.getProperty("aaf_url")); PropAccess access = new PropAccess(cadiProperties); servletContextHandler.addFilter(new FilterHolder(new DRNodeCadiFilter(true, access)), "/*", EnumSet @@ -194,7 +194,7 @@ public class NodeMain { synchronized void waitForConfig() { localNodeConfigManager.registerConfigTask(this); while (!localNodeConfigManager.isConfigured()) { - nodeMainLogger.info("NODE0003 Waiting for Node Configuration"); + nodeMainLogger.debug("NODE0003 Waiting for Node Configuration"); try { wait(); } catch (Exception exception) { @@ -204,7 +204,7 @@ public class NodeMain { } } localNodeConfigManager.deregisterConfigTask(this); - nodeMainLogger.info("NODE0004 Node Configuration Data Received"); + nodeMainLogger.debug("NODE0004 Node Configuration Data Received"); } } 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 3b82484a..163b59ea 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 @@ -91,13 +91,13 @@ public class NodeServlet extends HttpServlet { @Override public void init() { config = NodeConfigManager.getInstance(); - eelfLogger.info("NODE0101 Node Servlet Configured"); + eelfLogger.debug("NODE0101 Node Servlet Configured"); } private boolean down(HttpServletResponse resp) { if (config.isShutdown() || !config.isConfigured()) { sendResponseError(resp, HttpServletResponse.SC_SERVICE_UNAVAILABLE, eelfLogger); - eelfLogger.info("NODE0102 Rejecting request: Service is being quiesced"); + eelfLogger.error("NODE0102 Rejecting request: Service is being quiesced"); return true; } return false; @@ -112,7 +112,7 @@ public class NodeServlet extends HttpServlet { NodeUtils.setRequestIdAndInvocationId(req); eelfLogger.info(EelfMsgs.ENTRY); try { - eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), + eelfLogger.debug(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), getIdFromPath(req) + ""); if (down(resp)) { return; @@ -136,7 +136,7 @@ public class NodeServlet extends HttpServlet { } } - eelfLogger.info("NODE0103 Rejecting invalid GET of " + path + FROM + ip); + eelfLogger.debug("NODE0103 Rejecting invalid GET of " + path + FROM + ip); sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, eelfLogger); } finally { eelfLogger.info(EelfMsgs.EXIT); @@ -151,7 +151,7 @@ public class NodeServlet extends HttpServlet { NodeUtils.setIpAndFqdnForEelf("doPut"); NodeUtils.setRequestIdAndInvocationId(req); eelfLogger.info(EelfMsgs.ENTRY); - eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), + eelfLogger.debug(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), getIdFromPath(req) + ""); try { common(req, resp, true); @@ -169,7 +169,7 @@ public class NodeServlet extends HttpServlet { NodeUtils.setIpAndFqdnForEelf("doDelete"); NodeUtils.setRequestIdAndInvocationId(req); eelfLogger.info(EelfMsgs.ENTRY); - eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), + eelfLogger.debug(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(ON_BEHALF_OF), getIdFromPath(req) + ""); try { common(req, resp, false); @@ -228,7 +228,7 @@ public class NodeServlet extends HttpServlet { if (!("legacy".equalsIgnoreCase(aafInstance))) { isAAFFeed = true; String permission = config.getPermission(aafInstance); - eelfLogger.info("NodeServlet.common() permission string - " + permission); + eelfLogger.debug("NodeServlet.common() permission string - " + permission); //Check in CADI Framework API if user has AAF permission or not if (!req.isUserInRole(permission)) { String message = "AAF disallows access to permission string - " + permission; @@ -303,7 +303,7 @@ public class NodeServlet extends HttpServlet { .cleanString(feedid) + " fileid " + PathUtil.cleanString(fileid) + FROM + PathUtil .cleanString(ip) + " reason Invalid AAF user- " + PathUtil.cleanString(reason)); String message = "Invalid AAF user- " + PathUtil.cleanString(reason); - eelfLogger.info("NODE0308 Rejecting unauthenticated PUT or DELETE of " + PathUtil + eelfLogger.debug("NODE0308 Rejecting unauthenticated PUT or DELETE of " + PathUtil .cleanString(req.getPathInfo()) + FROM + PathUtil.cleanString(req.getRemoteAddr())); resp.sendError(HttpServletResponse.SC_FORBIDDEN, message); return; @@ -326,7 +326,7 @@ public class NodeServlet extends HttpServlet { } String redirto = HTTPS + newnode + port + PUBLISH + feedid + "/" + fileid; eelfLogger - .info("NODE0108 Redirecting publish attempt for feed " + PathUtil.cleanString(feedid) + USER + .debug("NODE0108 Redirecting publish attempt for feed " + PathUtil.cleanString(feedid) + USER + PathUtil.cleanString(user) + " ip " + PathUtil.cleanString(ip) + " to " + PathUtil .cleanString(redirto)); //Fortify scan fixes - log forging resp.sendRedirect(PathUtil.cleanString(redirto)); //Fortify scan fixes-open redirect - 2 issues @@ -517,7 +517,7 @@ public class NodeServlet extends HttpServlet { } boolean result = delivery.markTaskSuccess(config.getSpoolBase() + "/s/" + subIdDir + "/" + subId, pubid); if (result) { - eelfLogger.info("NODE0115 Successfully deleted files (" + pubid + ", " + pubid + FROM_DR_MESSAGE + eelfLogger.debug("NODE0115 Successfully deleted files (" + pubid + ", " + pubid + FROM_DR_MESSAGE + config.getMyName()); resp.setStatus(HttpServletResponse.SC_OK); eelfLogger.info(EelfMsgs.EXIT); 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 53e53145..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 @@ -158,6 +158,8 @@ 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); } /** @@ -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,6 +206,8 @@ 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); } /** @@ -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); } /** @@ -242,6 +250,7 @@ public class StatusLog { 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 { diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/DebugFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/DebugFilter.java new file mode 100644 index 00000000..58cd1706 --- /dev/null +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/DebugFilter.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.dmaap.datarouter.node.eelf; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + + +public class DebugFilter extends Filter<ILoggingEvent> { + @Override + public FilterReply decide(ILoggingEvent event) { + if (event.getLevel().equals(Level.DEBUG) && !event.getMessage().contains("org.eclipse.jetty")) { + return FilterReply.ACCEPT; + } else { + return FilterReply.DENY; + } + } +} diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/ErrorFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/ErrorFilter.java new file mode 100644 index 00000000..84f71cf5 --- /dev/null +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/ErrorFilter.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.dmaap.datarouter.node.eelf; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + + +public class ErrorFilter extends Filter<ILoggingEvent> { + @Override + public FilterReply decide(ILoggingEvent event) { + if ((event.getLevel().equals(Level.ERROR) || event.getLevel().equals(Level.WARN)) && !event.getMessage().contains("org.eclipse.jetty")) { + return FilterReply.ACCEPT; + } else { + return FilterReply.DENY; + } + } +} diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java index 69f51d82..d5e520ea 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java @@ -28,7 +28,7 @@ import ch.qos.logback.core.spi.FilterReply; public class JettyFilter extends Filter<ILoggingEvent> { @Override public FilterReply decide(ILoggingEvent event) { - if (event.getMessage().contains("org.eclipse.jetty")) { + if (event.getMessage().contains("org.eclipse.jetty") || event.getLoggerName().contains("org.eclipse.jetty")) { return FilterReply.ACCEPT; } else { return FilterReply.DENY; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java index 0fa57d4a..f3e27fee 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java @@ -29,7 +29,7 @@ import ch.qos.logback.core.spi.FilterReply; public class MetricsFilter extends Filter<ILoggingEvent> { @Override public FilterReply decide(ILoggingEvent event) { - if (event.getLevel().equals(Level.INFO) && !event.getMessage().contains("jetty")) { + if (event.getLevel().equals(Level.INFO) && !event.getMessage().contains("org.eclipse.jetty") && !event.getLoggerName().contains("org.eclipse.jetty")) { if (!event.getMessage().contains("DEL|") && !event.getMessage().contains("PUB|") && !event.getMessage().contains( "PBF|") && !event.getMessage().contains("EXP|") && !event.getMessage().contains("DLX|")) { return FilterReply.ACCEPT; |