diff options
Diffstat (limited to 'datarouter-subscriber/src')
6 files changed, 39 insertions, 101 deletions
diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java index 34a844c6..b820f3df 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java @@ -23,8 +23,9 @@ package org.onap.dmaap.datarouter.subscriber; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -32,18 +33,18 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SampleSubscriberServlet extends HttpServlet { - private static EELFLogger logger = EELFManager.getInstance().getLogger(SampleSubscriberServlet.class); + private final Logger logger = LoggerFactory.getLogger(SampleSubscriberServlet.class); + private static String outputDirectory; private static String basicAuth; @@ -67,7 +68,7 @@ public class SampleSubscriberServlet extends HttpServlet { try { Files.createDirectory(Paths.get(outputDirectory)); } catch (IOException e) { - logger.info("SubServlet: Failed to create delivery dir: " + e.getMessage(), e); + logger.error("SubServlet: Failed to create delivery dir: " + e.getMessage(), e); } basicAuth = "Basic " + Base64.encodeBase64String((login + ":" + password).getBytes()); } @@ -77,7 +78,7 @@ public class SampleSubscriberServlet extends HttpServlet { try { common(req, resp, false); } catch (IOException e) { - logger.info("SampleSubServlet: Failed to doPut: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e); + logger.error("SampleSubServlet: Failed to doPut: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e); } } @@ -86,7 +87,7 @@ public class SampleSubscriberServlet extends HttpServlet { try { common(req, resp, true); } catch (IOException e) { - logger.info("SampleSubServlet: Failed to doDelete: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e); + logger.error("SampleSubServlet: Failed to doDelete: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e); } } @@ -115,7 +116,7 @@ public class SampleSubscriberServlet extends HttpServlet { return; } if (!basicAuth.equals(authHeader)) { - logger.info("SampleSubServlet: Rejecting request with incorrect Authorization header from " + logger.error("SampleSubServlet: Rejecting request with incorrect Authorization header from " + req.getRemoteAddr() + ": " + req.getPathInfo()); resp.sendError(HttpServletResponse.SC_FORBIDDEN); return; @@ -127,7 +128,7 @@ public class SampleSubscriberServlet extends HttpServlet { fileid = fileid + "?" + queryString; } String publishid = req.getHeader("X-DMAAP-DR-PUBLISH-ID"); - String filename = URLEncoder.encode(fileid, "UTF-8").replaceAll("^\\.", "%2E").replaceAll("\\*", "%2A"); + String filename = URLEncoder.encode(fileid, StandardCharsets.UTF_8).replaceAll("^\\.", "%2E").replaceAll("\\*", "%2A"); String fullPath = outputDirectory + "/" + filename; String tmpPath = outputDirectory + "/." + filename; String fullMetaDataPath = outputDirectory + "/" + filename + ".M"; @@ -164,7 +165,7 @@ public class SampleSubscriberServlet extends HttpServlet { } catch (IOException ioe) { Files.deleteIfExists(Paths.get(tmpPath)); Files.deleteIfExists(Paths.get(tmpMetaDataPath)); - logger.info("SampleSubServlet: Failed to process file " + fullPath + " from " + req.getRemoteAddr() + ": " + logger.error("SampleSubServlet: Failed to process file " + fullPath + " from " + req.getRemoteAddr() + ": " + req.getPathInfo()); throw ioe; } diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java index 9184dce4..0e8d92fc 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java @@ -23,8 +23,6 @@ package org.onap.dmaap.datarouter.subscriber; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import java.util.Arrays; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.Connector; @@ -37,11 +35,13 @@ import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SubscriberMain { - private static EELFLogger logger = EELFManager.getInstance().getLogger(SubscriberMain.class); + private static final Logger logger = LoggerFactory.getLogger(SubscriberMain.class); /** * Main class for Subscriber. @@ -66,7 +66,7 @@ public class SubscriberMain { httpServerConnector.setIdleTimeout(30000); // SSL Context Factory - SslContextFactory sslContextFactory = new SslContextFactory.Server(); + SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); // SSL HTTP Configuration HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); @@ -81,7 +81,7 @@ public class SubscriberMain { /*Skip SSLv3 Fixes*/ sslContextFactory.addExcludeProtocols("SSLv3"); - logger.info("Excluded protocols for SubscriberMain:" + logger.debug("Excluded protocols for SubscriberMain:" + Arrays.toString(sslContextFactory.getExcludeProtocols())); /*End of SSLv3 Fixes*/ @@ -102,10 +102,10 @@ public class SubscriberMain { try { server.start(); } catch ( Exception e ) { - logger.info("Jetty failed to start. Reporting will be unavailable-" + e); + logger.error("Jetty failed to start. Reporting will be unavailable-" + e); } server.join(); - logger.info("org.onap.dmaap.datarouter.subscriber.SubscriberMain started-" + server.getState()); + logger.debug("org.onap.dmaap.datarouter.subscriber.SubscriberMain started-" + server.getState()); } }
\ No newline at end of file diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java index 49cad503..c060a9b0 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java @@ -23,17 +23,18 @@ package org.onap.dmaap.datarouter.subscriber; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import java.io.IOException; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SubscriberProps { + private static final Logger logger = LoggerFactory.getLogger(SubscriberProps.class); + private static SubscriberProps instance = null; - private static EELFLogger logger = EELFManager.getInstance().getLogger(SubscriberProps.class); - private Properties properties; + private final Properties properties; private SubscriberProps(String propsPath) throws IOException { properties = new Properties(); diff --git a/datarouter-subscriber/src/main/resources/docker/Dockerfile b/datarouter-subscriber/src/main/resources/docker/Dockerfile index 7bc92c83..f3ad036e 100644 --- a/datarouter-subscriber/src/main/resources/docker/Dockerfile +++ b/datarouter-subscriber/src/main/resources/docker/Dockerfile @@ -19,7 +19,7 @@ # limitations under the License. # ============LICENSE_END==================================================== # -FROM nexus3.onap.org:10001/onap/integration-java11:8.0.0 +FROM nexus3.onap.org:10001/onap/integration-java11:10.0.0 COPY /opt /opt @@ -29,8 +29,6 @@ ARG group=onap USER root RUN apk add --no-cache curl -EXPOSE 8080 8443 - WORKDIR /opt RUN chmod 0700 startup.sh diff --git a/datarouter-subscriber/src/test/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServletTest.java b/datarouter-subscriber/src/test/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServletTest.java index 006dee76..bab9d011 100755 --- a/datarouter-subscriber/src/test/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServletTest.java +++ b/datarouter-subscriber/src/test/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServletTest.java @@ -22,6 +22,7 @@ ******************************************************************************/ package org.onap.dmaap.datarouter.subscriber; +import jakarta.servlet.ServletInputStream; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; @@ -31,9 +32,8 @@ import org.mockito.Mock; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.modules.junit4.PowerMockRunner; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; diff --git a/datarouter-subscriber/src/test/resources/logback-test.xml b/datarouter-subscriber/src/test/resources/logback-test.xml index 76390505..515732b4 100644 --- a/datarouter-subscriber/src/test/resources/logback-test.xml +++ b/datarouter-subscriber/src/test/resources/logback-test.xml @@ -21,92 +21,30 @@ * --> <configuration scan="true" scanPeriod="3 seconds" debug="false"> - <property name="logDir" value="logs/EELF" /> + <property name="logDir" value="logs" /> <property name="generalLogName" value="application" /> - <property name="errorLogName" value="errors" /> - <property name="defaultPattern" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{InvocationId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%msg%n" /> + <property name="defaultPattern" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{InvocationId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%msg%n" /> <property name="logDirectory" value="${logDir}" /> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <!-- ============================================================================ --> - <!-- EELF Appenders --> - <!-- ============================================================================ --> - - <!-- The EELFAppender is used to record events to the general application - log --> - - <appender name="EELF" - class="ch.qos.logback.core.rolling.RollingFileAppender"> + <appender name="file" class="ch.qos.logback.core.FileAppender"> <file>${logDirectory}/${generalLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> + <append>true</append> + <immediateFlush>true</immediateFlush> <encoder> <pattern>${defaultPattern}</pattern> </encoder> </appender> - <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELF" /> - </appender> - - <appender name="EELFError" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${errorLogName}.log</file> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>ERROR</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> + <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${defaultPattern}</pattern> </encoder> </appender> - <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFError"/> - </appender> - - <!-- ============================================================================ --> - <!-- EELF loggers --> - <!-- ============================================================================ --> - <logger name="com.att.eelf" level="info" additivity="false"> - <appender-ref ref="asyncEELF" /> - </logger> - - <logger name="com.att.eelf.error" level="error" additivity="false"> - <appender-ref ref="asyncEELFError" /> - </logger> + <logger name="org.eclipse.jetty" level="INFO"/> <root level="DEBUG"> - <appender-ref ref="asyncEELF" /> - <appender-ref ref="asyncEELFError" /> + <appender-ref ref="file" /> + <appender-ref ref="console" /> </root> - </configuration> |