From 23f79a7228b070ac54b78a4936c8a43e2e5cf606 Mon Sep 17 00:00:00 2001 From: Sushant Date: Wed, 9 Oct 2024 21:19:42 +0530 Subject: [PATCH 1/4] Added Raw logic for Get config from PSQL Db --- .../java/org/jembi/jempi/libapi/BackEnd.java | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java index 6d4842120..76a29bb75 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java @@ -4,6 +4,8 @@ import akka.actor.typed.Behavior; import akka.actor.typed.javadsl.*; import akka.http.javadsl.server.directives.FileInfo; + +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.vavr.control.Either; import org.apache.commons.io.FileUtils; @@ -30,11 +32,15 @@ import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; +import java.sql.PreparedStatement; +import java.sql.ResultSet; public final class BackEnd extends AbstractBehavior { private static final Logger LOGGER = LogManager.getLogger(BackEnd.class); + private final PsqlClient psqlClient; private final String pgIP; + private final int pgPort; private final String pgUser; private final String pgPassword; private final String pgNotificationsDb; @@ -74,7 +80,7 @@ private BackEnd( this.dgraphHosts = dgraphHosts; this.dgraphPorts = dgraphPorts; this.pgIP = sqlIP; - Integer pgPort = sqlPort; + this.pgPort = sqlPort; this.pgUser = sqlUser; this.pgPassword = sqlPassword; this.pgNotificationsDb = sqlNotificationsDb; @@ -87,6 +93,7 @@ private BackEnd( psqlNotifications = new PsqlNotifications(sqlIP, sqlPort, sqlNotificationsDb, sqlUser, sqlPassword); psqlAuditTrail = new PsqlAuditTrail(sqlIP, sqlPort, sqlAuditDb, sqlUser, sqlPassword); openMPI(kafkaBootstrapServers, kafkaClientId, debugLevel); + psqlClient = new PsqlClient(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); } catch (Exception e) { LOGGER.error(e.getMessage(), e); throw e; @@ -498,7 +505,7 @@ private Behavior getSqlDashboardDataHandler(final SQLDashboardDataRequest return Behaviors.same(); } - private Behavior getConfigurationHandler(final GetConfigurationRequest request) { + private Behavior getConfigurationHandlers(final GetConfigurationRequest request) { Path configMasterJsonFilePath = Paths.get(systemConfigDirectory, configMasterFileName); Path configReferenceJsonFilePath = Paths.get(systemConfigDirectory, configReferenceFileName); @@ -519,7 +526,61 @@ private Behavior getConfigurationHandler(final GetConfigurationRequest re return Behaviors.same(); } + private Behavior getConfigurationHandler(final GetConfigurationRequest request) { + try { + psqlClient.connect(); + String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1"; + try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); + ResultSet rs = preparedStatement.executeQuery()) { + + if (rs.next()) { + LOGGER.info("rs.....getConfigurationHandler.........................................: {}", rs); + String configFileContent = rs.getString("json"); + LOGGER.info("configFileContent..........getConfigurationHandler....................................: {}", configFileContent); + ObjectMapper mapper = new ObjectMapper(); + Configuration configuration = mapper.readValue(configFileContent, Configuration.class); + request.replyTo.tell(new GetConfigurationResponse(configuration)); + } else { + LOGGER.warn("No configuration found in the database."); + request.replyTo.tell(new GetConfigurationResponse(null)); + } + } + } catch (SQLException | JsonProcessingException e) { + LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); + } + + return Behaviors.same(); + } + private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) { + try { + psqlClient.connect(); + String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1"; + try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); + ResultSet rs = preparedStatement.executeQuery()) { + + if (rs.next()) { + LOGGER.info("rs...............getFieldsConfigurationHandler...............................: {}", rs); + String configFileContent = rs.getString("json"); + LOGGER.info("configFileContent...........getFieldsConfigurationHandler...................................: {}", configFileContent); + FieldsConfiguration fieldsConfiguration = AppUtils.OBJECT_MAPPER.readValue(configFileContent, FieldsConfiguration.class); + ArrayList fields = new ArrayList<>(); + fields.addAll(fieldsConfiguration.systemFields()); + fields.addAll(fieldsConfiguration.fields()); + request.replyTo.tell(new GetFieldsConfigurationResponse(fields)); + } else { + LOGGER.warn("No configuration found in the database."); + request.replyTo.tell(new GetFieldsConfigurationResponse(null)); + } + } + } catch (SQLException | JsonProcessingException e) { + LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); + } + + return Behaviors.same(); + } + + private Behavior getFieldsConfigurationHandlers(final GetFieldsConfigurationRequest request) { final var separator = FileSystems.getDefault().getSeparator(); final String configDir = System.getenv("SYSTEM_CONFIG_DIRS"); Path filePath = Paths.get(""); // Start with an empty path From a8d54e4ccf96679de2844c2c1914768472c3ac5a Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 10 Oct 2024 11:34:05 +0530 Subject: [PATCH 2/4] Added Interface for PSQL logic --- .../java/org/jembi/jempi/libapi/BackEnd.java | 136 +++------------- .../jembi/jempi/libapi/PostgresClientDao.java | 15 ++ .../jempi/libapi/PostgresClientDaoImpl.java | 150 ++++++++++++++++++ 3 files changed, 188 insertions(+), 113 deletions(-) create mode 100644 JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java create mode 100644 JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java index 76a29bb75..fd8db2291 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java @@ -4,9 +4,6 @@ import akka.actor.typed.Behavior; import akka.actor.typed.javadsl.*; import akka.http.javadsl.server.directives.FileInfo; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import io.vavr.control.Either; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -26,14 +23,12 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; -import java.sql.PreparedStatement; -import java.sql.ResultSet; + public final class BackEnd extends AbstractBehavior { @@ -56,6 +51,8 @@ public final class BackEnd extends AbstractBehavior { private String[] dgraphHosts = null; private int[] dgraphPorts = null; + private final PostgresClientDao postgresClientDao; + private BackEnd( final Level debugLevel, final ActorContext context, @@ -94,6 +91,7 @@ private BackEnd( psqlAuditTrail = new PsqlAuditTrail(sqlIP, sqlPort, sqlAuditDb, sqlUser, sqlPassword); openMPI(kafkaBootstrapServers, kafkaClientId, debugLevel); psqlClient = new PsqlClient(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); + this.postgresClientDao = new PostgresClientDaoImpl(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); } catch (Exception e) { LOGGER.error(e.getMessage(), e); throw e; @@ -505,131 +503,42 @@ private Behavior getSqlDashboardDataHandler(final SQLDashboardDataRequest return Behaviors.same(); } - private Behavior getConfigurationHandlers(final GetConfigurationRequest request) { - Path configMasterJsonFilePath = Paths.get(systemConfigDirectory, configMasterFileName); - Path configReferenceJsonFilePath = Paths.get(systemConfigDirectory, configReferenceFileName); - - Path configFilePath = configMasterJsonFilePath; - if (!Files.exists(configFilePath)) { - configFilePath = configReferenceJsonFilePath; - } - - try { - String configFileContent = new String(Files.readAllBytes(configFilePath), StandardCharsets.UTF_8); - ObjectMapper mapper = new ObjectMapper(); - Configuration configuration = mapper.readValue(configFileContent, Configuration.class); - request.replyTo.tell(new GetConfigurationResponse(configuration)); - } catch (Exception exception) { - LOGGER.error("getConfigurationHandler failed with error: {}", exception.getMessage()); - } - - return Behaviors.same(); - } - private Behavior getConfigurationHandler(final GetConfigurationRequest request) { try { - psqlClient.connect(); - String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1"; - try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); - ResultSet rs = preparedStatement.executeQuery()) { - - if (rs.next()) { - LOGGER.info("rs.....getConfigurationHandler.........................................: {}", rs); - String configFileContent = rs.getString("json"); - LOGGER.info("configFileContent..........getConfigurationHandler....................................: {}", configFileContent); - ObjectMapper mapper = new ObjectMapper(); - Configuration configuration = mapper.readValue(configFileContent, Configuration.class); - request.replyTo.tell(new GetConfigurationResponse(configuration)); - } else { - LOGGER.warn("No configuration found in the database."); - request.replyTo.tell(new GetConfigurationResponse(null)); - } - } - } catch (SQLException | JsonProcessingException e) { + postgresClientDao.connect(); + Configuration configuration = postgresClientDao.getConfiguration(); + request.replyTo.tell(new GetConfigurationResponse(configuration)); + } catch (SQLException e) { LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); } - return Behaviors.same(); } private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) { try { - psqlClient.connect(); - String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1"; - try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); - ResultSet rs = preparedStatement.executeQuery()) { - - if (rs.next()) { - LOGGER.info("rs...............getFieldsConfigurationHandler...............................: {}", rs); - String configFileContent = rs.getString("json"); - LOGGER.info("configFileContent...........getFieldsConfigurationHandler...................................: {}", configFileContent); - FieldsConfiguration fieldsConfiguration = AppUtils.OBJECT_MAPPER.readValue(configFileContent, FieldsConfiguration.class); - ArrayList fields = new ArrayList<>(); - fields.addAll(fieldsConfiguration.systemFields()); - fields.addAll(fieldsConfiguration.fields()); - request.replyTo.tell(new GetFieldsConfigurationResponse(fields)); - } else { - LOGGER.warn("No configuration found in the database."); - request.replyTo.tell(new GetFieldsConfigurationResponse(null)); - } - } - } catch (SQLException | JsonProcessingException e) { - LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); - } - - return Behaviors.same(); - } - - private Behavior getFieldsConfigurationHandlers(final GetFieldsConfigurationRequest request) { - final var separator = FileSystems.getDefault().getSeparator(); - final String configDir = System.getenv("SYSTEM_CONFIG_DIRS"); - Path filePath = Paths.get(""); // Start with an empty path - // Create ubuntuFilePath - Path ubuntuFilePath = new File(String.format("%sapp%sconf_system%s%s", separator, separator, separator, fieldsConfigurationFileName)).toPath(); - // Check if ubuntuFilePath exists - if (Files.exists(ubuntuFilePath)) { - filePath = ubuntuFilePath; - } else { - // If ubuntuFilePath does not exist, assign the alternative path - filePath = Paths.get(configDir, "config-api.json"); - } - try { - String configFileContent = new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8); - FieldsConfiguration fieldsConfiguration = AppUtils.OBJECT_MAPPER.readValue(configFileContent, FieldsConfiguration.class); - ArrayList fields = new ArrayList<>(); - fields.addAll(fieldsConfiguration.systemFields()); - fields.addAll(fieldsConfiguration.fields()); + postgresClientDao.connect(); + List fields = postgresClientDao.getFieldsConfiguration(); request.replyTo.tell(new GetFieldsConfigurationResponse(fields)); - } catch (Exception exception) { - LOGGER.error("getFieldsConfigurationHandler failed with error: {}", exception.getLocalizedMessage()); + } catch (SQLException e) { + LOGGER.error("getFieldsConfigurationHandler failed with error: {}", e.getMessage()); } - return Behaviors.same(); } private Behavior postConfigurationHandler(final PostConfigurationRequest request) { - Path configMasterJsonFilePath = Paths.get(systemConfigDirectory, configMasterFileName); - ObjectMapper objectMapper = new ObjectMapper(); - Configuration configJson = request.configuration; - - if (configJson == null) { - request.replyTo.tell(new PostConfigurationResponse("error: configuration is missing")); - LOGGER.error("postConfigurationHandler failed: configuration is missing in the request"); - return Behaviors.same(); - } - try { - String jsonConfig = objectMapper.writeValueAsString(configJson); - Files.write(configMasterJsonFilePath, - jsonConfig.getBytes(StandardCharsets.UTF_8), - StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING); + postgresClientDao.connect(); + postgresClientDao.saveConfiguration(request.configuration); request.replyTo.tell(new PostConfigurationResponse("ok")); - } catch (Exception exception) { - LOGGER.error("postConfigurationHandler failed with error: {}", exception.getMessage()); - request.replyTo.tell(new PostConfigurationResponse("error: " + exception.getMessage())); + } catch (SQLException e) { + LOGGER.error("postConfigurationHandler failed with error: {}", e.getMessage()); + } finally { + try { + postgresClientDao.disconnect(); + } catch (SQLException e) { + LOGGER.error("Error disconnecting from database: {}", e.getMessage()); + } } - return Behaviors.same(); } @@ -819,3 +728,4 @@ public record PostUploadCsvFileRequest( public record PostUploadCsvFileResponse() implements EventResponse { } } + diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java new file mode 100644 index 000000000..8557d7e94 --- /dev/null +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java @@ -0,0 +1,15 @@ +package org.jembi.jempi.libapi; + +import org.jembi.jempi.shared.models.ConfigurationModel.Configuration; +import org.jembi.jempi.shared.models.FieldsConfiguration; + +import java.sql.SQLException; +import java.util.List; + +public interface PostgresClientDao { + void connect() throws SQLException; + void disconnect() throws SQLException; + Configuration getConfiguration() throws SQLException; + List getFieldsConfiguration() throws SQLException; + void saveConfiguration(Configuration configuration) throws SQLException; +} diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java new file mode 100644 index 000000000..d306aa1f4 --- /dev/null +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java @@ -0,0 +1,150 @@ +package org.jembi.jempi.libapi; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jembi.jempi.shared.models.ConfigurationModel.Configuration; +import org.jembi.jempi.shared.models.FieldsConfiguration; +import org.jembi.jempi.shared.utils.AppUtils; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Implementation of PostgresClientDao interface for interacting with a PostgreSQL database. + * This class can be extended to provide custom behavior for database operations. + */ +public class PostgresClientDaoImpl implements PostgresClientDao { + private static final Logger LOGGER = LogManager.getLogger(PostgresClientDaoImpl.class); + private final PsqlClient psqlClient; + + /** + * Constructs a new PostgresClientDaoImpl with the given database connection parameters. + * + * @param pgIP The IP address of the PostgreSQL server + * @param pgPort The port number of the PostgreSQL server + * @param pgDatabase The name of the database to connect to + * @param pgUser The username for database authentication + * @param pgPassword The password for database authentication + */ + public PostgresClientDaoImpl( + final String pgIP, + final int pgPort, + final String pgDatabase, + final String pgUser, + final String pgPassword) { + this.psqlClient = new PsqlClient(pgIP, pgPort, pgDatabase, pgUser, pgPassword); + } + + /** + * Establishes a connection to the PostgreSQL database. + * This method can be overridden to provide custom connection logic. + * + * @throws SQLException if a database access error occurs + */ + @Override + public void connect() throws SQLException { + LOGGER.info("Connecting to PostgreSQL database"); + psqlClient.connect(); + LOGGER.info("Successfully connected to PostgreSQL database"); + } + + /** + * Closes the connection to the PostgreSQL database. + * This method can be overridden to provide custom disconnection logic. + * + * @throws SQLException if a database access error occurs + */ + @Override + public void disconnect() throws SQLException { + LOGGER.info("Disconnecting from PostgreSQL database"); + psqlClient.disconnect(); + LOGGER.info("Successfully disconnected from PostgreSQL database"); + } + + /** + * Retrieves the current configuration from the database. + * This method can be overridden to provide custom configuration retrieval logic. + * + * @return The Configuration object, or null if no configuration is found + * @throws SQLException if a database access error occurs or the retrieved JSON is invalid + */ + @Override + public Configuration getConfiguration() throws SQLException { + LOGGER.info("Retrieving configuration from database"); + String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1"; + try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); + ResultSet rs = preparedStatement.executeQuery()) { + + if (rs.next()) { + String configFileContent = rs.getString("json"); + ObjectMapper mapper = new ObjectMapper(); + Configuration config = mapper.readValue(configFileContent, Configuration.class); + LOGGER.info("Successfully retrieved configuration from database"); + return config; + } else { + LOGGER.info("No configuration found in the database"); + return null; + } + } catch (JsonProcessingException e) { + LOGGER.error("Error parsing configuration JSON: {}", e.getMessage()); + } + } + + /** + * Retrieves the fields configuration from the database. + * This method can be overridden to provide custom fields configuration retrieval logic. + * + * @return A List of FieldsConfiguration.Field objects, or null if no configuration is found + * @throws SQLException if a database access error occurs or the retrieved JSON is invalid + */ + @Override + public List getFieldsConfiguration() throws SQLException { + LOGGER.info("Retrieving fields configuration from database"); + String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1"; + try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); + ResultSet rs = preparedStatement.executeQuery()) { + if (rs.next()) { + String configFileContent = rs.getString("json"); + FieldsConfiguration fieldsConfiguration = AppUtils.OBJECT_MAPPER.readValue(configFileContent, FieldsConfiguration.class); + ArrayList fields = new ArrayList<>(); + if (fieldsConfiguration != null && fieldsConfiguration.systemFields() != null && fieldsConfiguration.fields() != null) { + fields.addAll(fieldsConfiguration.systemFields()); + fields.addAll(fieldsConfiguration.fields()); + } + LOGGER.info("Successfully retrieved fields configuration from database"); + return fields; + } else { + LOGGER.info("No fields configuration found in the database"); + return null; + } + } catch (JsonProcessingException e) { + LOGGER.error("Error parsing fields configuration JSON: {}", e.getMessage()); + } + } + + /** + * Saves the given configuration to the database. + * This method can be overridden to provide custom configuration saving logic. + * + * @param configuration The Configuration object to be saved + * @throws SQLException if a database access error occurs or the configuration cannot be converted to JSON + */ + @Override + public void saveConfiguration(final Configuration configuration) throws SQLException { + LOGGER.info("Saving configuration to database"); + String sql = "INSERT INTO CONFIGURATION (key, json) VALUES (?, ?::json)"; + try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql)) { + String jsonConfig = AppUtils.OBJECT_MAPPER.writeValueAsString(configuration); + preparedStatement.setString(1, "config-api"); + preparedStatement.setString(2, jsonConfig); + int rowsAffected = preparedStatement.executeUpdate(); + LOGGER.info("Successfully saved configuration to database. Rows affected: {}", rowsAffected); + } catch (JsonProcessingException e) { + LOGGER.error("Error converting configuration to JSON: {}", e.getMessage()); + } + } +} + + From cb8f4fd95473458baa707706e3e3f5aca57d6d0c Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 10 Oct 2024 12:01:05 +0530 Subject: [PATCH 3/4] Added Logs and code clean --- .../java/org/jembi/jempi/libapi/BackEnd.java | 18 ++---- .../jembi/jempi/libapi/PostgresClientDao.java | 12 ++-- .../jempi/libapi/PostgresClientDaoImpl.java | 62 ++++++++++++++----- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java index fd8db2291..3e59972c0 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java @@ -91,7 +91,7 @@ private BackEnd( psqlAuditTrail = new PsqlAuditTrail(sqlIP, sqlPort, sqlAuditDb, sqlUser, sqlPassword); openMPI(kafkaBootstrapServers, kafkaClientId, debugLevel); psqlClient = new PsqlClient(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); - this.postgresClientDao = new PostgresClientDaoImpl(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); + this.postgresClientDao = PostgresClientDaoImpl.create(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword); } catch (Exception e) { LOGGER.error(e.getMessage(), e); throw e; @@ -505,10 +505,9 @@ private Behavior getSqlDashboardDataHandler(final SQLDashboardDataRequest private Behavior getConfigurationHandler(final GetConfigurationRequest request) { try { - postgresClientDao.connect(); Configuration configuration = postgresClientDao.getConfiguration(); request.replyTo.tell(new GetConfigurationResponse(configuration)); - } catch (SQLException e) { + } catch (Exception e) { LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); } return Behaviors.same(); @@ -516,10 +515,9 @@ private Behavior getConfigurationHandler(final GetConfigurationRequest re private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) { try { - postgresClientDao.connect(); List fields = postgresClientDao.getFieldsConfiguration(); request.replyTo.tell(new GetFieldsConfigurationResponse(fields)); - } catch (SQLException e) { + } catch (Exception e) { LOGGER.error("getFieldsConfigurationHandler failed with error: {}", e.getMessage()); } return Behaviors.same(); @@ -527,17 +525,10 @@ private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurati private Behavior postConfigurationHandler(final PostConfigurationRequest request) { try { - postgresClientDao.connect(); postgresClientDao.saveConfiguration(request.configuration); request.replyTo.tell(new PostConfigurationResponse("ok")); - } catch (SQLException e) { + } catch (Exception e) { LOGGER.error("postConfigurationHandler failed with error: {}", e.getMessage()); - } finally { - try { - postgresClientDao.disconnect(); - } catch (SQLException e) { - LOGGER.error("Error disconnecting from database: {}", e.getMessage()); - } } return Behaviors.same(); } @@ -728,4 +719,3 @@ public record PostUploadCsvFileRequest( public record PostUploadCsvFileResponse() implements EventResponse { } } - diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java index 8557d7e94..12583875c 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java @@ -2,14 +2,12 @@ import org.jembi.jempi.shared.models.ConfigurationModel.Configuration; import org.jembi.jempi.shared.models.FieldsConfiguration; - -import java.sql.SQLException; import java.util.List; public interface PostgresClientDao { - void connect() throws SQLException; - void disconnect() throws SQLException; - Configuration getConfiguration() throws SQLException; - List getFieldsConfiguration() throws SQLException; - void saveConfiguration(Configuration configuration) throws SQLException; + void connect(); + void disconnect(); + Configuration getConfiguration(); + List getFieldsConfiguration(); + void saveConfiguration(Configuration configuration); } diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java index d306aa1f4..2958ac61d 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java @@ -1,6 +1,5 @@ package org.jembi.jempi.libapi; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,7 +14,7 @@ * Implementation of PostgresClientDao interface for interacting with a PostgreSQL database. * This class can be extended to provide custom behavior for database operations. */ -public class PostgresClientDaoImpl implements PostgresClientDao { +public final class PostgresClientDaoImpl implements PostgresClientDao { private static final Logger LOGGER = LogManager.getLogger(PostgresClientDaoImpl.class); private final PsqlClient psqlClient; @@ -28,7 +27,7 @@ public class PostgresClientDaoImpl implements PostgresClientDao { * @param pgUser The username for database authentication * @param pgPassword The password for database authentication */ - public PostgresClientDaoImpl( + private PostgresClientDaoImpl( final String pgIP, final int pgPort, final String pgDatabase, @@ -37,6 +36,29 @@ public PostgresClientDaoImpl( this.psqlClient = new PsqlClient(pgIP, pgPort, pgDatabase, pgUser, pgPassword); } + /** + * Creates a new instance of PostgresClientDaoImpl with the given database connection parameters. + * + * @param ip The IP address of the PostgreSQL server + * @param port The port number of the PostgreSQL server + * @param db The name of the database to connect to + * @param user The username for database authentication + * @param password The password for database authentication + */ + public static PostgresClientDaoImpl create( + final String ip, + final int port, + final String db, + final String user, + final String password) { + return new PostgresClientDaoImpl( + ip, + port, + db, + user, + password); + } + /** * Establishes a connection to the PostgreSQL database. * This method can be overridden to provide custom connection logic. @@ -44,7 +66,7 @@ public PostgresClientDaoImpl( * @throws SQLException if a database access error occurs */ @Override - public void connect() throws SQLException { + public void connect() { LOGGER.info("Connecting to PostgreSQL database"); psqlClient.connect(); LOGGER.info("Successfully connected to PostgreSQL database"); @@ -57,7 +79,7 @@ public void connect() throws SQLException { * @throws SQLException if a database access error occurs */ @Override - public void disconnect() throws SQLException { + public void disconnect() { LOGGER.info("Disconnecting from PostgreSQL database"); psqlClient.disconnect(); LOGGER.info("Successfully disconnected from PostgreSQL database"); @@ -71,7 +93,8 @@ public void disconnect() throws SQLException { * @throws SQLException if a database access error occurs or the retrieved JSON is invalid */ @Override - public Configuration getConfiguration() throws SQLException { + public Configuration getConfiguration() { + this.connect(); LOGGER.info("Retrieving configuration from database"); String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1"; try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); @@ -87,9 +110,11 @@ public Configuration getConfiguration() throws SQLException { LOGGER.info("No configuration found in the database"); return null; } - } catch (JsonProcessingException e) { - LOGGER.error("Error parsing configuration JSON: {}", e.getMessage()); - } + } catch (Exception e) { + LOGGER.error(e); + } + this.disconnect(); + return null; } /** @@ -100,7 +125,8 @@ public Configuration getConfiguration() throws SQLException { * @throws SQLException if a database access error occurs or the retrieved JSON is invalid */ @Override - public List getFieldsConfiguration() throws SQLException { + public List getFieldsConfiguration() { + this.connect(); LOGGER.info("Retrieving fields configuration from database"); String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1"; try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); @@ -119,9 +145,11 @@ public List getFieldsConfiguration() throws SQLExcept LOGGER.info("No fields configuration found in the database"); return null; } - } catch (JsonProcessingException e) { - LOGGER.error("Error parsing fields configuration JSON: {}", e.getMessage()); + } catch (Exception e) { + LOGGER.error(e); } + this.disconnect(); + return null; } /** @@ -132,8 +160,9 @@ public List getFieldsConfiguration() throws SQLExcept * @throws SQLException if a database access error occurs or the configuration cannot be converted to JSON */ @Override - public void saveConfiguration(final Configuration configuration) throws SQLException { + public void saveConfiguration(final Configuration configuration) { LOGGER.info("Saving configuration to database"); + this.connect(); String sql = "INSERT INTO CONFIGURATION (key, json) VALUES (?, ?::json)"; try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql)) { String jsonConfig = AppUtils.OBJECT_MAPPER.writeValueAsString(configuration); @@ -141,10 +170,9 @@ public void saveConfiguration(final Configuration configuration) throws SQLExcep preparedStatement.setString(2, jsonConfig); int rowsAffected = preparedStatement.executeUpdate(); LOGGER.info("Successfully saved configuration to database. Rows affected: {}", rowsAffected); - } catch (JsonProcessingException e) { - LOGGER.error("Error converting configuration to JSON: {}", e.getMessage()); + } catch (Exception e) { + LOGGER.error(e); } + this.disconnect(); } } - - From 71f5e9e4079f1c912b8e5ad03705802dbec5698f Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 10 Oct 2024 14:09:04 +0530 Subject: [PATCH 4/4] Added variable and removed hardcoded values --- .../jempi/bootstrapper/BootstrapperConfig.java | 6 ++++++ .../sql/postgres/PostgresDataBootstrapper.java | 13 +++++++------ .../data/postgres/configuration-schema.sql | 2 +- .../java/org/jembi/jempi/libapi/BackEnd.java | 6 +++--- .../jembi/jempi/libapi/PostgresClientDao.java | 6 +++--- .../jempi/libapi/PostgresClientDaoImpl.java | 16 ++++++++-------- .../jempi/shared/models/GlobalConstants.java | 4 ++++ .../conf/postgres/config-configuration.sql | 2 +- .../docker/conf/stack/docker-stack-high-0.yml | 3 +++ .../docker/conf/stack/docker-stack-high-1.yml | 3 +++ .../docker/conf/stack/docker-stack-low-0.yml | 3 +++ .../docker/conf/stack/docker-stack-low-1.yml | 5 ++++- 12 files changed, 46 insertions(+), 23 deletions(-) diff --git a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/BootstrapperConfig.java b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/BootstrapperConfig.java index a72c56828..9962cdd01 100644 --- a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/BootstrapperConfig.java +++ b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/BootstrapperConfig.java @@ -23,6 +23,9 @@ public class BootstrapperConfig { public final String KAFKA_APPLICATION_ID; public final String[] DGRAPH_ALPHA_HOSTS; public final int[] DGRAPH_ALPHA_PORTS; + public final String API_CONFIG_REFERENCE_FILENAME; + public final String API_FIELDS_CONFIG_FILENAME; + public final String SYSTEM_CONFIG_DIR; public BootstrapperConfig(final Config parsedConfig) { POSTGRESQL_IP = parsedConfig.getString("POSTGRESQL_IP"); @@ -40,6 +43,9 @@ public BootstrapperConfig(final Config parsedConfig) { KAFKA_BOOTSTRAP_SERVERS = parsedConfig.getString("KAFKA_BOOTSTRAP_SERVERS"); KAFKA_APPLICATION_ID = parsedConfig.getString("KAFKA_APPLICATION_ID"); DGRAPH_ALPHA_HOSTS = parsedConfig.getString("DGRAPH_HOSTS").split(","); + API_CONFIG_REFERENCE_FILENAME = parsedConfig.getString("API_CONFIG_REFERENCE_FILENAME"); + API_FIELDS_CONFIG_FILENAME = parsedConfig.getString("API_FIELDS_CONFIG_FILENAME"); + SYSTEM_CONFIG_DIR = parsedConfig.getString("SYSTEM_CONFIG_DIR"); DGRAPH_ALPHA_PORTS = Arrays.stream(parsedConfig.getString("DGRAPH_PORTS").split(",")).mapToInt(s -> { try { return Integer.parseInt(s); diff --git a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/data/sql/postgres/PostgresDataBootstrapper.java b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/data/sql/postgres/PostgresDataBootstrapper.java index 18481888c..4d1ac9d0f 100644 --- a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/data/sql/postgres/PostgresDataBootstrapper.java +++ b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/java/org/jembi/jempi/bootstrapper/data/sql/postgres/PostgresDataBootstrapper.java @@ -2,6 +2,7 @@ import org.jembi.jempi.bootstrapper.data.DataBootstrapper; import org.jembi.jempi.bootstrapper.data.utils.DataBootstraperConsts; +import org.jembi.jempi.shared.models.GlobalConstants; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -150,7 +151,7 @@ public Boolean insertConfigurationData() throws SQLException, IOException { } private String[][] getConfigFiles(final String configurationTable) { - String configDir = Optional.of(Paths.get("/app/conf_system")) + String configDir = Optional.of(Paths.get(this.loadedConfig.SYSTEM_CONFIG_DIR)) .filter(Files::exists) .map(Path::toString) .orElseGet(() -> System.getenv("SYSTEM_CSV_DIR")); @@ -159,11 +160,11 @@ private String[][] getConfigFiles(final String configurationTable) { LOGGER.info("configDir " + configDir); // Define an array of config file paths and their corresponding keys String[][] configFiles = { - {configDir + "/config.json", "config"}, - {configDir + "/config-api.json", "config-api"}, - // Add more configuration files as needed - }; - return configFiles; + {configDir + "/" + this.loadedConfig.API_CONFIG_REFERENCE_FILENAME, GlobalConstants.CONFIGURATION_CONFIG_KEY}, + {configDir + "/" + this.loadedConfig.API_FIELDS_CONFIG_FILENAME, GlobalConstants.CONFIGURATION_CONFIG_API_KEY}, + // Add more configuration files as needed + }; + return configFiles; } private String readJsonFile(final String filePath) throws IOException { diff --git a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/resources/data/postgres/configuration-schema.sql b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/resources/data/postgres/configuration-schema.sql index 42f8941eb..a72ec57b8 100644 --- a/JeMPI_Apps/JeMPI_Bootstrapper/src/main/resources/data/postgres/configuration-schema.sql +++ b/JeMPI_Apps/JeMPI_Bootstrapper/src/main/resources/data/postgres/configuration-schema.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS configuration ( id SERIAL PRIMARY KEY, - key VARCHAR(255) NOT NULL, + key VARCHAR(255) NOT NULL UNIQUE, json JSON NOT NULL, dateCreated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, dateUpdated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java index 3e59972c0..25c8736dd 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java @@ -505,7 +505,7 @@ private Behavior getSqlDashboardDataHandler(final SQLDashboardDataRequest private Behavior getConfigurationHandler(final GetConfigurationRequest request) { try { - Configuration configuration = postgresClientDao.getConfiguration(); + Configuration configuration = postgresClientDao.getConfiguration(GlobalConstants.CONFIGURATION_CONFIG_KEY); request.replyTo.tell(new GetConfigurationResponse(configuration)); } catch (Exception e) { LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage()); @@ -515,7 +515,7 @@ private Behavior getConfigurationHandler(final GetConfigurationRequest re private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) { try { - List fields = postgresClientDao.getFieldsConfiguration(); + List fields = postgresClientDao.getFieldsConfiguration(GlobalConstants.CONFIGURATION_CONFIG_API_KEY); request.replyTo.tell(new GetFieldsConfigurationResponse(fields)); } catch (Exception e) { LOGGER.error("getFieldsConfigurationHandler failed with error: {}", e.getMessage()); @@ -525,7 +525,7 @@ private Behavior getFieldsConfigurationHandler(final GetFieldsConfigurati private Behavior postConfigurationHandler(final PostConfigurationRequest request) { try { - postgresClientDao.saveConfiguration(request.configuration); + postgresClientDao.saveConfiguration(request.configuration, GlobalConstants.CONFIGURATION_CONFIG_KEY); request.replyTo.tell(new PostConfigurationResponse("ok")); } catch (Exception e) { LOGGER.error("postConfigurationHandler failed with error: {}", e.getMessage()); diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java index 12583875c..c78aa504b 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDao.java @@ -7,7 +7,7 @@ public interface PostgresClientDao { void connect(); void disconnect(); - Configuration getConfiguration(); - List getFieldsConfiguration(); - void saveConfiguration(Configuration configuration); + Configuration getConfiguration(String configKey); + List getFieldsConfiguration(String configKey); + void saveConfiguration(Configuration configuration, String configKey); } diff --git a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java index 2958ac61d..3529e06e4 100644 --- a/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java +++ b/JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/PostgresClientDaoImpl.java @@ -93,10 +93,10 @@ public void disconnect() { * @throws SQLException if a database access error occurs or the retrieved JSON is invalid */ @Override - public Configuration getConfiguration() { + public Configuration getConfiguration(final String configKey) { this.connect(); LOGGER.info("Retrieving configuration from database"); - String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1"; + String sql = String.format("SELECT json FROM CONFIGURATION WHERE key = '%s' ORDER BY id DESC LIMIT 1", configKey); try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); ResultSet rs = preparedStatement.executeQuery()) { @@ -125,10 +125,10 @@ public Configuration getConfiguration() { * @throws SQLException if a database access error occurs or the retrieved JSON is invalid */ @Override - public List getFieldsConfiguration() { + public List getFieldsConfiguration(final String configKey) { this.connect(); LOGGER.info("Retrieving fields configuration from database"); - String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1"; + String sql = String.format("SELECT json FROM CONFIGURATION WHERE key = '%s' ORDER BY id DESC LIMIT 1", configKey); try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql); ResultSet rs = preparedStatement.executeQuery()) { if (rs.next()) { @@ -160,14 +160,14 @@ public List getFieldsConfiguration() { * @throws SQLException if a database access error occurs or the configuration cannot be converted to JSON */ @Override - public void saveConfiguration(final Configuration configuration) { + public void saveConfiguration(final Configuration configuration, final String configKey) { LOGGER.info("Saving configuration to database"); this.connect(); - String sql = "INSERT INTO CONFIGURATION (key, json) VALUES (?, ?::json)"; + String sql = "UPDATE CONFIGURATION SET json = ?::jsonb WHERE key = ?"; try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql)) { String jsonConfig = AppUtils.OBJECT_MAPPER.writeValueAsString(configuration); - preparedStatement.setString(1, "config-api"); - preparedStatement.setString(2, jsonConfig); + preparedStatement.setString(1, jsonConfig); + preparedStatement.setString(2, configKey); int rowsAffected = preparedStatement.executeUpdate(); LOGGER.info("Successfully saved configuration to database. Rows affected: {}", rowsAffected); } catch (Exception e) { diff --git a/JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/GlobalConstants.java b/JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/GlobalConstants.java index cc21f9e30..e68aed962 100644 --- a/JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/GlobalConstants.java +++ b/JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/GlobalConstants.java @@ -71,6 +71,10 @@ public final class GlobalConstants { public static final int TIMEOUT_GENERAL_SECS = 60; public static final int TIMEOUT_TEA_TIME_SECS = 30; + //Configuration Key + public static final String CONFIGURATION_CONFIG_KEY = "config"; + public static final String CONFIGURATION_CONFIG_API_KEY = "config-api"; + private GlobalConstants() { } diff --git a/devops/linux/docker/conf/postgres/config-configuration.sql b/devops/linux/docker/conf/postgres/config-configuration.sql index 48fc4e6ae..3f7627f3b 100644 --- a/devops/linux/docker/conf/postgres/config-configuration.sql +++ b/devops/linux/docker/conf/postgres/config-configuration.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS configuration ( id SERIAL PRIMARY KEY, - key VARCHAR(255) NOT NULL, + key VARCHAR(255) NOT NULL UNIQUE, json JSON NOT NULL, dateCreated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, dateUpdated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP diff --git a/devops/linux/docker/conf/stack/docker-stack-high-0.yml b/devops/linux/docker/conf/stack/docker-stack-high-0.yml index 4eb43621c..8ee793413 100644 --- a/devops/linux/docker/conf/stack/docker-stack-high-0.yml +++ b/devops/linux/docker/conf/stack/docker-stack-high-0.yml @@ -836,6 +836,9 @@ services: KAFKA_APPLICATION_ID: app-id-bootstrapper DGRAPH_HOSTS: ${DGRAPH_HOSTS} DGRAPH_PORTS: ${DGRAPH_PORTS} + API_CONFIG_REFERENCE_FILENAME: ${API_CONFIG_REFERENCE_FILENAME} + API_FIELDS_CONFIG_FILENAME: ${API_FIELDS_CONFIG_FILENAME} + SYSTEM_CONFIG_DIR: /app/conf_system deploy: mode: global diff --git a/devops/linux/docker/conf/stack/docker-stack-high-1.yml b/devops/linux/docker/conf/stack/docker-stack-high-1.yml index 24bf927d0..e261f1bdd 100644 --- a/devops/linux/docker/conf/stack/docker-stack-high-1.yml +++ b/devops/linux/docker/conf/stack/docker-stack-high-1.yml @@ -836,6 +836,9 @@ services: KAFKA_APPLICATION_ID: app-id-bootstrapper DGRAPH_HOSTS: ${DGRAPH_HOSTS} DGRAPH_PORTS: ${DGRAPH_PORTS} + API_CONFIG_REFERENCE_FILENAME: ${API_CONFIG_REFERENCE_FILENAME} + API_FIELDS_CONFIG_FILENAME: ${API_FIELDS_CONFIG_FILENAME} + SYSTEM_CONFIG_DIR: /app/conf_system deploy: mode: global diff --git a/devops/linux/docker/conf/stack/docker-stack-low-0.yml b/devops/linux/docker/conf/stack/docker-stack-low-0.yml index c33550f3b..a9096fc2b 100644 --- a/devops/linux/docker/conf/stack/docker-stack-low-0.yml +++ b/devops/linux/docker/conf/stack/docker-stack-low-0.yml @@ -625,6 +625,9 @@ services: KAFKA_APPLICATION_ID: app-id-bootstrapper DGRAPH_HOSTS: ${DGRAPH_HOSTS} DGRAPH_PORTS: ${DGRAPH_PORTS} + API_CONFIG_REFERENCE_FILENAME: ${API_CONFIG_REFERENCE_FILENAME} + API_FIELDS_CONFIG_FILENAME: ${API_FIELDS_CONFIG_FILENAME} + SYSTEM_CONFIG_DIR: /app/conf_system deploy: mode: global diff --git a/devops/linux/docker/conf/stack/docker-stack-low-1.yml b/devops/linux/docker/conf/stack/docker-stack-low-1.yml index 7f5563d18..de3a7c898 100644 --- a/devops/linux/docker/conf/stack/docker-stack-low-1.yml +++ b/devops/linux/docker/conf/stack/docker-stack-low-1.yml @@ -609,7 +609,7 @@ services: - type: bind source: $DATA_SYSTEM_CONFIG_DIR target: /app/conf_system - read_only: true + read_only: true environment: POSTGRESQL_IP: postgresql POSTGRESQL_PORT: 5432 @@ -625,6 +625,9 @@ services: KAFKA_APPLICATION_ID: app-id-bootstrapper DGRAPH_HOSTS: ${DGRAPH_HOSTS} DGRAPH_PORTS: ${DGRAPH_PORTS} + API_CONFIG_REFERENCE_FILENAME: ${API_CONFIG_REFERENCE_FILENAME} + API_FIELDS_CONFIG_FILENAME: ${API_FIELDS_CONFIG_FILENAME} + SYSTEM_CONFIG_DIR: /app/conf_system deploy: mode: global