From fa025d68d5b71fd43d9958696493e5d7aad3aa09 Mon Sep 17 00:00:00 2001 From: August Kilponen Date: Wed, 15 Jan 2025 17:21:23 +0200 Subject: [PATCH] =?UTF-8?q?Taulujen=20kopiointi=20S3-=C3=A4mp=C3=A4riin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/fi/oph/opintopolku/ovara/App.java | 6 +++++- .../java/fi/oph/opintopolku/ovara/db/DatabaseToS3.java | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/App.java b/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/App.java index 19e1307..98d228b 100644 --- a/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/App.java +++ b/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/App.java @@ -2,6 +2,8 @@ import com.amazonaws.regions.Regions; import fi.oph.opintopolku.ovara.db.DatabaseToS3; +import fi.oph.opintopolku.ovara.db.domain.S3ExportResult; +import org.javatuples.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,7 +32,9 @@ public static void main(String[] args) throws Exception { try { LOG.info("Haetaan scheman {} taulut", schemaName); List tableNames = db.getTableNames("pub"); - LOG.info("Scheman {} taulut: ", tableNames); + LOG.info("Scheman {} taulut: {}", schemaName, tableNames); + LOG.info("Viedään scheman {} datat Ovaran AWS S3-ämpäriin", schemaName); + List> results = db.exportTablesToS3(schemaName, tableNames); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/db/DatabaseToS3.java b/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/db/DatabaseToS3.java index 0723a66..27d0956 100644 --- a/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/db/DatabaseToS3.java +++ b/lampi-siirtaja-container/lampi-siirtaja/src/main/java/fi/oph/opintopolku/ovara/db/DatabaseToS3.java @@ -9,6 +9,8 @@ import org.apache.commons.dbutils.handlers.BeanHandler; import org.apache.commons.dbutils.handlers.BeanListHandler; import org.javatuples.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.List; @@ -16,6 +18,8 @@ public class DatabaseToS3 { + private static final Logger LOG = LoggerFactory.getLogger(DatabaseToS3.class); + private final Config config; public DatabaseToS3(Config config) throws Exception { @@ -71,6 +75,7 @@ public List> exportTablesToS3(String schemaName, Li } private Pair exportTableToS3(String schemaName, String tableName) throws Exception { + LOG.info("Aloitetaan scheman {} taulun {} vienti Ovaran S3-ämpäriin", schemaName, tableName); ResultSetHandler h = new BeanHandler(S3ExportResult.class); Connection connection = getConnection(); @@ -86,6 +91,8 @@ private Pair exportTableToS3(String schemaName, String t String.format("%s.csv", tableName), config.awsRegion()); + LOG.info("Scheman {} taulun {} vienti Ovaran S3-ämpäriin valmistui. Tulokset: {}", schemaName, tableName, s3ExportResult.toString()); + return new Pair<>(tableName, s3ExportResult); } finally {