add distr

This commit is contained in:
etreshenkov 2022-08-04 12:03:56 +03:00
parent 031bc087fc
commit 72de7e595a
17 changed files with 38 additions and 37 deletions

View file

@ -49,6 +49,16 @@
</dependencies> </dependencies>
<build> <build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View file

@ -2,6 +2,7 @@ package ru.spcex.clearing.dbf.exporter.config;
import com.mchange.v2.c3p0.ComboPooledDataSource; import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -18,12 +19,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
@Configuration @Configuration
@EnableConfigurationProperties
@ComponentScan(basePackages = {"ru.spcex.clearing.dbf.exporter"}) @ComponentScan(basePackages = {"ru.spcex.clearing.dbf.exporter"})
public class DBFExportConfig { public class DBFExportConfig {
private final AProperties properties; private final AProperties properties;
private final ApplicationContext context; private final ApplicationContext context;
public DBFExportConfig(@Qualifier("dbfExportProperties") AProperties properties, ApplicationContext context) { public DBFExportConfig(@Qualifier("dbfExporterProperties") AProperties properties, ApplicationContext context) {
this.properties = properties; this.properties = properties;
this.context = context; this.context = context;
} }

View file

@ -38,7 +38,7 @@ public class ExportFromDB extends Stage implements InitializingBean {
private Charset dbfCharset; private Charset dbfCharset;
public ExportFromDB(@Qualifier("dbfExportProperties") AProperties properties, public ExportFromDB(@Qualifier("dbfExporterProperties") AProperties properties,
@Qualifier("dbfJdbcTemplate") JdbcTemplate dbfJdbcTemplate) { @Qualifier("dbfJdbcTemplate") JdbcTemplate dbfJdbcTemplate) {
this.properties = properties; this.properties = properties;
this.dbfJdbcTemplate = dbfJdbcTemplate; this.dbfJdbcTemplate = dbfJdbcTemplate;

View file

@ -23,7 +23,7 @@ public class PrepareDBFFiles extends Stage implements InitializingBean {
private final AProperties properties; private final AProperties properties;
private String outDirWithDateTime; private String outDirWithDateTime;
public PrepareDBFFiles(@Qualifier("dbfExportProperties") AProperties properties) { public PrepareDBFFiles(@Qualifier("dbfExporterProperties") AProperties properties) {
this.properties = properties; this.properties = properties;
} }

View file

@ -1,12 +1,9 @@
package ru.spcex.clearing.dbf.exporter.properties; package ru.spcex.clearing.dbf.exporter.properties;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component("dbfExportProperties") @Component("dbfExporterProperties")
@PropertySource(value = {"classpath:dbf_export.properties"})
@PropertySource(value = {"file:dbf_export.properties"}, ignoreResourceNotFound = true)
public class AProperties { public class AProperties {
@Value("${db.jdbc-url}") @Value("${db.jdbc-url}")

View file

@ -8,7 +8,7 @@
</appender> </appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs//dbf_export.log</file> <file>./logs/dbf_exporter.log</file>
<encoder> <encoder>
<charset>UTF-8</charset> <charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

View file

@ -2,6 +2,7 @@ package ru.spcex.clearing.dbf.importer.config;
import com.mchange.v2.c3p0.ComboPooledDataSource; import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -18,12 +19,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
@Configuration @Configuration
@EnableConfigurationProperties
@ComponentScan(basePackages = {"ru.spcex.clearing.dbf.importer"}) @ComponentScan(basePackages = {"ru.spcex.clearing.dbf.importer"})
public class DBFLoaderConfig { public class DBFLoaderConfig {
private final AProperties properties; private final AProperties properties;
private final ApplicationContext context; private final ApplicationContext context;
public DBFLoaderConfig(@Qualifier("dbfLoaderProperties") AProperties properties, ApplicationContext context) { public DBFLoaderConfig(@Qualifier("dbfImporterProperties") AProperties properties, ApplicationContext context) {
this.properties = properties; this.properties = properties;
this.context = context; this.context = context;
} }

View file

@ -31,7 +31,7 @@ public class ImportToDB extends Stage {
private final AProperties properties; private final AProperties properties;
private final JdbcTemplate dbfJdbcTemplate; private final JdbcTemplate dbfJdbcTemplate;
public ImportToDB(@Qualifier("dbfLoaderProperties") AProperties properties, public ImportToDB(@Qualifier("dbfImporterProperties") AProperties properties,
@Qualifier("dbfJdbcTemplate") JdbcTemplate dbfJdbcTemplate) { @Qualifier("dbfJdbcTemplate") JdbcTemplate dbfJdbcTemplate) {
this.properties = properties; this.properties = properties;
this.dbfJdbcTemplate = dbfJdbcTemplate; this.dbfJdbcTemplate = dbfJdbcTemplate;

View file

@ -1,12 +1,9 @@
package ru.spcex.clearing.dbf.importer.properties; package ru.spcex.clearing.dbf.importer.properties;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component("dbfLoaderProperties") @Component("dbfImporterProperties")
@PropertySource(value = {"classpath:dbf_loader.properties"})
@PropertySource(value = {"file:dbf_loader.properties"}, ignoreResourceNotFound = true)
public class AProperties { public class AProperties {
@Value("${db.jdbc-url}") @Value("${db.jdbc-url}")

View file

@ -1,8 +1,6 @@
package ru.spcex.clearing.dbf.importer.services; package ru.spcex.clearing.dbf.importer.services;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.spcex.clearing.dbf.importer.logic.data.ResultContainer; import ru.spcex.clearing.dbf.importer.logic.data.ResultContainer;
import ru.spcex.clearing.dbf.importer.logic.data.enums.StageResult; import ru.spcex.clearing.dbf.importer.logic.data.enums.StageResult;
@ -13,7 +11,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
@Service @Service
@EnableScheduling //@EnableScheduling
public class DBFLoaderService { public class DBFLoaderService {
private final AProperties properties; private final AProperties properties;
private final MessageListener messageListener; private final MessageListener messageListener;
@ -27,7 +25,7 @@ public class DBFLoaderService {
this.pipeline = pipeline; this.pipeline = pipeline;
} }
@Scheduled(fixedDelayString = "${dbf.execute-timeout}") // @Scheduled(fixedDelayString = "${dbf.execute-timeout}")
public void run() { public void run() {
List<ResultContainer> newTaskList = messageListener.getTasks(); List<ResultContainer> newTaskList = messageListener.getTasks();
for (ResultContainer newTask : newTaskList) { for (ResultContainer newTask : newTaskList) {

View file

@ -2,11 +2,7 @@ package ru.spcex.clearing.dbf.importer.services;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.spcex.clearing.dbf.importer.exceptions.ConfigException;
import ru.spcex.clearing.dbf.importer.logic.data.enums.Table; import ru.spcex.clearing.dbf.importer.logic.data.enums.Table;
import ru.spcex.clearing.dbf.importer.properties.AProperties; import ru.spcex.clearing.dbf.importer.properties.AProperties;
@ -19,8 +15,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
@Service("fileMessageListener") @Service("fileMessageListener")
@EnableScheduling public class FileMessageListener extends MessageListener {
public class FileMessageListener extends MessageListener implements InitializingBean {
private final Logger log = LoggerFactory.getLogger(getClass()); private final Logger log = LoggerFactory.getLogger(getClass());
private final AProperties properties; private final AProperties properties;
@ -29,7 +24,6 @@ public class FileMessageListener extends MessageListener implements Initializing
} }
@Override @Override
@Scheduled(fixedDelayString = "${dbf.check-source-timeout}")
public void checkMessage() { public void checkMessage() {
String srcDir = properties.getSrcDir(); String srcDir = properties.getSrcDir();
List<File> dbfFiles = lsDBF(srcDir); List<File> dbfFiles = lsDBF(srcDir);
@ -75,13 +69,4 @@ public class FileMessageListener extends MessageListener implements Initializing
return resultFiles; return resultFiles;
} }
@Override
public void afterPropertiesSet() {
String dbfSourceDirPath = properties.getSrcDir();
File dbfSourceDir = new File(dbfSourceDirPath);
if (!dbfSourceDir.exists()) throw new ConfigException(String.format("DBF directory (%s) doesn't exist", dbfSourceDirPath));
if (!dbfSourceDir.isDirectory()) throw new ConfigException(String.format("DBF path (%s) isn't directory", dbfSourceDirPath));
}
} }

View file

@ -8,7 +8,7 @@
</appender> </appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs//dbf_loader.log</file> <file>./logs/dbf_importer.log</file>
<encoder> <encoder>
<charset>UTF-8</charset> <charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

View file

@ -119,6 +119,10 @@
<sourceFile>${folder_root_dbf-exporter}/target/dbf-exporter.jar</sourceFile> <sourceFile>${folder_root_dbf-exporter}/target/dbf-exporter.jar</sourceFile>
<destinationFile>${folder.clearing.distr.modules}/dbf-exporter/dbf-exporter.jar</destinationFile> <destinationFile>${folder.clearing.distr.modules}/dbf-exporter/dbf-exporter.jar</destinationFile>
</fileSet> </fileSet>
<fileSet>
<sourceFile>${folder_root_dbf-exporter}/src/main/resources/application.properties</sourceFile>
<destinationFile>${folder.clearing.distr.modules}/dbf-exporter/application.properties</destinationFile>
</fileSet>
</fileSets> </fileSets>
</configuration> </configuration>
</execution> </execution>
@ -134,6 +138,10 @@
<sourceFile>${folder_root_dbf-importer}/target/dbf-importer.jar</sourceFile> <sourceFile>${folder_root_dbf-importer}/target/dbf-importer.jar</sourceFile>
<destinationFile>${folder.clearing.distr.modules}/dbf-importer/dbf-importer.jar</destinationFile> <destinationFile>${folder.clearing.distr.modules}/dbf-importer/dbf-importer.jar</destinationFile>
</fileSet> </fileSet>
<fileSet>
<sourceFile>${folder_root_dbf-importer}/src/main/resources/application.properties</sourceFile>
<destinationFile>${folder.clearing.distr.modules}/dbf-importer/application.properties</destinationFile>
</fileSet>
</fileSets> </fileSets>
</configuration> </configuration>
</execution> </execution>

View file

@ -1,5 +1,6 @@
FROM debian:stable-20220125-jdk17 FROM debian:stable-20220125-jdk17
ADD dbf-exporter.jar /opt/clearing/bin/dbf-exporter.jar ADD dbf-exporter.jar /opt/clearing/bin/dbf-exporter.jar
ADD application.properties /opt/clearing/bin/application.properties
USER root USER root
ENTRYPOINT java -jar /opt/clearing/bin/dbf-exporter.jar ENTRYPOINT java -jar /opt/clearing/bin/dbf-exporter.jar --spring.config.location=/opt/clearing/bin/

View file

@ -1,5 +1,6 @@
FROM debian:stable-20220125-jdk17 FROM debian:stable-20220125-jdk17
ADD dbf-importer.jar /opt/clearing/bin/dbf-importer.jar ADD dbf-importer.jar /opt/clearing/bin/dbf-importer.jar
ADD application.properties /opt/clearing/bin/application.properties
USER root USER root
ENTRYPOINT java -jar /opt/clearing/bin/dbf-importer.jar ENTRYPOINT java -jar /opt/clearing/bin/dbf-importer.jar --spring.config.location=/opt/clearing/bin/