diff --git a/LICENSE-THIRD-PARTY.txt b/LICENSE-THIRD-PARTY.txt index 1d0a3152..c80b0076 100644 --- a/LICENSE-THIRD-PARTY.txt +++ b/LICENSE-THIRD-PARTY.txt @@ -1,5 +1,5 @@ -Lists of 155 third-party dependencies. +Lists of 165 third-party dependencies. (Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.2.3 - http://logback.qos.ch/logback-classic) (Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.2.3 - http://logback.qos.ch/logback-core) (The Apache License, Version 2.0) spock-reports (com.athaydes:spock-reports:1.7.1 - https://github.com/renatoathaydes/spock-reports) @@ -51,6 +51,9 @@ Lists of 155 third-party dependencies. (Eclipse Distribution License - v 1.0) Jakarta XML Binding API (jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 - https://github.com/eclipse-ee4j/jaxb-api/jakarta.xml.bind-api) (COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0) JavaBeans(TM) Activation Framework (javax.activation:activation:1.1.1 - http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) (CDDL/GPLv2+CE) JavaBeans Activation Framework API jar (javax.activation:javax.activation-api:1.2.0 - http://java.net/all/javax.activation-api/) + (COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0) JSR-250 Common Annotations for the JavaTM Platform (javax.annotation:jsr250-api:1.0 - http://jcp.org/aboutJava/communityprocess/final/jsr250/index.html) + (Apache License, Version 2.0) CDI APIs (javax.enterprise:cdi-api:1.0 - http://www.seamframework.org/Weld/cdi-api) + (The Apache Software License, Version 2.0) javax.inject (javax.inject:javax.inject:1 - http://code.google.com/p/atinject/) (CDDL 1.1) (GPL2 w/ CPE) jaxb-api (javax.xml.bind:jaxb-api:2.3.1 - https://github.com/javaee/jaxb-spec/jaxb-api) (Eclipse Public License 1.0) JUnit (junit:junit:4.13 - http://junit.org) (Apache License, Version 2.0) Byte Buddy (without dependencies) (net.bytebuddy:byte-buddy:1.10.14 - https://bytebuddy.net/byte-buddy) @@ -66,6 +69,10 @@ Lists of 155 third-party dependencies. (Apache License, Version 2.0) Apache HttpClient Mime (org.apache.httpcomponents:httpmime:4.5.12 - http://hc.apache.org/httpcomponents-client) (Apache License, Version 2.0) Apache Log4j API (org.apache.logging.log4j:log4j-api:2.13.3 - https://logging.apache.org/log4j/2.x/log4j-api/) (Apache License, Version 2.0) Apache Log4j to SLF4J Adapter (org.apache.logging.log4j:log4j-to-slf4j:2.13.3 - https://logging.apache.org/log4j/2.x/log4j-to-slf4j/) + (Apache License, Version 2.0) Maven Artifact (org.apache.maven:maven-artifact:3.6.3 - https://maven.apache.org/ref/3.6.3/maven-artifact/) + (Apache License, Version 2.0) Maven Model (org.apache.maven:maven-model:3.6.3 - https://maven.apache.org/ref/3.6.3/maven-model/) + (Apache License, Version 2.0) Maven Plugin API (org.apache.maven:maven-plugin-api:3.6.3 - https://maven.apache.org/ref/3.6.3/maven-plugin-api/) + (Apache License, Version 2.0) Maven Plugin Tools Java Annotations (org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0 - https://maven.apache.org/plugin-tools/maven-plugin-annotations) (The Apache Software License, Version 2.0) Apache Sling javax.activation bundle (org.apache.sling:org.apache.sling.javax.activation:0.1.0 - http://sling.apache.org/org.apache.sling.javax.activation) (Apache License, Version 2.0) Apache Tika core (org.apache.tika:tika-core:1.24.1 - http://tika.apache.org/) (Apache License, Version 2.0) tomcat-embed-core (org.apache.tomcat.embed:tomcat-embed-core:9.0.38 - https://tomcat.apache.org/) @@ -82,6 +89,9 @@ Lists of 155 third-party dependencies. (The Apache Software License, Version 2.0) Apache Groovy (org.codehaus.groovy:groovy-templates:2.5.13 - https://groovy-lang.org) (The Apache Software License, Version 2.0) Apache Groovy (org.codehaus.groovy:groovy-test:2.5.13 - https://groovy-lang.org) (The Apache Software License, Version 2.0) Apache Groovy (org.codehaus.groovy:groovy-xml:2.5.13 - https://groovy-lang.org) + (Apache License, Version 2.0) Plexus Classworlds (org.codehaus.plexus:plexus-classworlds:2.6.0 - http://codehaus-plexus.github.io/plexus-classworlds/) + (The Apache Software License, Version 2.0) Plexus :: Component Annotations (org.codehaus.plexus:plexus-component-annotations:1.5.5 - http://plexus.codehaus.org/plexus-containers/plexus-component-annotations/) + (Apache License, Version 2.0) Plexus Common Utilities (org.codehaus.plexus:plexus-utils:3.2.1 - http://codehaus-plexus.github.io/plexus-utils/) (Apache License, Version 2.0) flyway-core (org.flywaydb:flyway-core:6.4.4 - https://flywaydb.org/flyway-core) (Apache License, Version 2.0) Apache FreeMarker (org.freemarker:freemarker:2.3.30 - https://freemarker.apache.org/) (EPL 2.0) (GPL2 w/ CPE) Jakarta Expression Language 3.0 (org.glassfish:jakarta.el:3.0.3 - https://projects.eclipse.org/projects/ee4j.el) diff --git a/appstore-metadata-service/pom.xml b/appstore-metadata-service/pom.xml index d2851ab4..2bc0cc02 100644 --- a/appstore-metadata-service/pom.xml +++ b/appstore-metadata-service/pom.xml @@ -18,6 +18,7 @@ postgres localhost 46576 + 46577 appstore_metadata_service jdbc:postgresql://${db.host}:${db.port}/${db.name} org.postgresql.Driver @@ -26,9 +27,21 @@ 2.2.0 current latest + /var/run/docker.sock + + windows-specific-settings + + + Windows + + + + //var/run/docker.sock + + dev @@ -142,12 +155,48 @@ + + com.lgi.common.maven + tcp-msg-maven-plugin + 0.0.1-SNAPSHOT + + + write-death-note-for-postgres + generate-sources + + tcpmsg + + + ${ryuk.port} + label=killme + 6 + + + + io.fabric8 docker-maven-plugin 0.34.0 + true + true + + ryuk-summoned + testcontainers/ryuk:0.3.0 + + + ryuk.port:8080 + + + + ${sock-dir-docker-host}:/var/run/docker.sock + + + true + + postgres postgres:11 @@ -161,6 +210,10 @@ + true + + true + @@ -173,13 +226,6 @@ start - - stop-postgres - process-sources - - stop - - diff --git a/pom.xml b/pom.xml index 0cb0d1be..0f89e0ee 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ appstore-metadata-service appstore-metadata-service-tests + tcp-msg-maven-plugin @@ -64,6 +65,8 @@ The MIT License|${line.separator} The MIT License (MIT) + (^org\.eclipse\.sisu)|(^com\.sun\.xml\.bind) + diff --git a/tcp-msg-maven-plugin/pom.xml b/tcp-msg-maven-plugin/pom.xml new file mode 100644 index 00000000..0423ff7b --- /dev/null +++ b/tcp-msg-maven-plugin/pom.xml @@ -0,0 +1,51 @@ + + + appstore-metadata-service-parent + com.lgi.appstore.metadata + 0.0.1-SNAPSHOT + + + com.lgi.common.maven + tcp-msg-maven-plugin + + maven-plugin + 4.0.0 + + + + org.apache.maven + maven-plugin-api + 3.6.3 + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.6.0 + provided + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.6.0 + + + default-descriptor + process-classes + + + help-goal + + helpmojo + + + + + + + diff --git a/tcp-msg-maven-plugin/src/main/java/com/lgi/commons/maven/TcpMessagingMojo.java b/tcp-msg-maven-plugin/src/main/java/com/lgi/commons/maven/TcpMessagingMojo.java new file mode 100644 index 00000000..030d39ac --- /dev/null +++ b/tcp-msg-maven-plugin/src/main/java/com/lgi/commons/maven/TcpMessagingMojo.java @@ -0,0 +1,117 @@ +package com.lgi.commons.maven; + +/* + * Copyright 2001-2005 The Apache Software 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.Socket; +import java.util.stream.IntStream; + + +@Mojo(name = "tcpmsg") +public class TcpMessagingMojo extends AbstractMojo { + private static final String LOG_PREFIX = "maven-tcpmsg"; + + @Parameter(property = "tcpmsg.host", defaultValue = "localhost") + private String host; + + @Parameter(property = "tcpmsg.repeatAmount", defaultValue = "1") + private Integer repeatAmount; + + @Parameter(property = "tcpmsg.intervalSec", defaultValue = "5") + private Integer intervalSec; + + @Parameter(property = "tcpmsg.port") + private Integer port; + + @Parameter(property = "tcpmsg.command") + private String msg; + + @Override + public void execute() throws MojoExecutionException { + if (port == null) { + getLog().error("Please specify 'port' param. of TCP socket."); + throw new MojoExecutionException(getPluginContext().keySet().toString()); + } else if (msg == null) { + getLog().warn("Please specify 'msg' param. with message to send."); + } else { + doCommunicate(); + } + } + + private void doCommunicate() { + Thread communicationChannel = new Thread( + new ThreadGroup(LOG_PREFIX), + this::sendMessages, + String.format("%s-send", LOG_PREFIX) + ); + communicationChannel.setDaemon(true); + communicationChannel.start(); + } + + private void sendMessages() { + IntStream.range(0, repeatAmount).forEach(attempt -> { + sleepForConfiguredInterval(); + getLog().info(String.format("%s: Attempting [%d] to send message '%s' to TCP socket on %s:%d", LOG_PREFIX, attempt, msg, host, port)); + handleSendAttempt(); + }); + } + + private void sleepForConfiguredInterval() { + try { + Thread.sleep(intervalSec * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private void handleSendAttempt() { + try (Socket clientSocket = new Socket(host, port)) { + try (PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true)) { + try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()))) { + String response = communicate(in, out); + getLog().info(String.format("%s: Received: %s", LOG_PREFIX, response)); + } + } + } catch (IOException e) { + logSocketIssue(e); + } + } + + private String communicate(BufferedReader in, PrintWriter out) { + try { + out.println(msg); + return in.readLine(); + } catch (IOException e) { + String errorMsg = String.format("%s: Issue with sending message '%s' to TCP socket on %s:%d: %s - %s", LOG_PREFIX, msg, host, port, e.getClass().getSimpleName(), e.getMessage()); + getLog().error(errorMsg); + return null; + } + } + + private void logSocketIssue(Exception e) { + String warnMsg = String.format("%s: Issue with connection to TCP socket on %s:%d - %s: %s", LOG_PREFIX, host, port, e.getClass().getSimpleName(), e.getMessage()); + getLog().warn(warnMsg); + } +} \ No newline at end of file