Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-catalano committed Feb 16, 2024
1 parent 1cb7201 commit ec3e8c8
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 205 deletions.
20 changes: 13 additions & 7 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ microservice-chart:
APP_LOGGING_LEVEL: 'DEBUG'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
DB_NEXI_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_NEXI_POSTGRE_USER: "cfg"
DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_NEXI_POSTGRES_USER: "cfg"
DB_NEXI_POSTGRES_ENABLED: "true"
DB_NEXI_POSTGRE_SERVICE_IDENTIFIER: "NDP004DEV"
DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))"
DB_NEXI_ORACLE_USER: "NODO4_CFG"
DB_PAGOPA_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_PAGOPA_POSTGRE_USER: "cfg"
DB_NEXI_ORACLE_ENABLED: "true"
DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV"
DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_PAGOPA_POSTGRES_USER: "cfg"
DB_PAGOPA_POSTGRES_ENABLED: "true"
DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER: "NDP001DEV"
OTEL_SERVICE_NAME: "pagopa-node-cfg-sync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
Expand All @@ -83,9 +89,9 @@ microservice-chart:
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string'
DB_PAGOPA_POSTGRE_PASSWORD: "db-cfg-password"
DB_NEXI_POSTGRE_URL: "postgresql-db-cfg-password"
DB_NEXI_ORACLE_URL: "oracle-db-cfg-password"
DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password"
DB_NEXI_POSTGRES_PASSWORD: "postgresql-db-cfg-password"
DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password"
API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key"
API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key"
STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import javax.sql.DataSource;

@Configuration
@PropertySources({
@PropertySource("classpath:/application.properties"),
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
//@PropertySources({
// @PropertySource("classpath:/application.properties"),
// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
//})
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
import javax.sql.DataSource;

@Configuration
@PropertySources({
@PropertySource("classpath:/application.properties"),
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
//@PropertySources({
// @PropertySource("classpath:/application.properties"),
// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
//})
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre",
basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgres",
entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory",
transactionManagerRef = "nexiCachePostgreTransactionManager"
)
@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre", name = "enabled")
@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgres", name = "enabled")
public class NexiPostgreConfiguration {

@Bean
@ConfigurationProperties("spring.datasource.nexi.postgre")
@ConfigurationProperties("spring.datasource.nexi.postgres")
public DataSourceProperties nexiPostgreDatasourceProperties() {
return new DataSourceProperties();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
import javax.sql.DataSource;

@Configuration
@PropertySources({
@PropertySource("classpath:/application.properties"),
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
//@PropertySources({
// @PropertySource("classpath:/application.properties"),
// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
//})
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa",
entityManagerFactoryRef = "pagoPAPostgreEntityManagerFactory",
transactionManagerRef = "pagoPAPostgreTransactionManager"
)
@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre", name = "enabled")
@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgres", name = "enabled")
public class PagoPAPostgreConfiguration {

@Primary
@Bean
@ConfigurationProperties("spring.datasource.pagopa.postgre")
@ConfigurationProperties("spring.datasource.pagopa.postgres")
public DataSourceProperties pagoPAPostgreDatasourceProperties() {
return new DataSourceProperties();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum;
import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum;
import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache;
import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiCacheOracleRepository;
import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiCachePostgreRepository;
import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;

import java.io.IOException;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Service
@Slf4j
Expand All @@ -43,24 +44,24 @@ public class ApiConfigCacheService extends CommonCacheService {

@Autowired
private PagoPACachePostgreRepository pagoPACachePostgreRepository;
// @Autowired
// private NexiCachePostgreRepository nexiCachePostgreRepository;
// @Autowired
// private NexiCacheOracleRepository nexiCacheOracleRepository;
@Autowired(required = false)
private Optional<NexiCachePostgreRepository> nexiCachePostgreRepository;
@Autowired(required = false)
private Optional<NexiCacheOracleRepository> nexiCacheOracleRepository;

@Value("${pagopa.postgre.cache.write.enabled}")
@Value("${app.write.cache.pagopa-postgres}")
private Boolean pagopaPostgreCacheEnabled;
@Value("${pagopa.postgre.serviceIdentifier}")
@Value("${app.identifiers.pagopa-postgres}")
private String pagopaPostgreServiceIdentifier;

@Value("${nexi.postgre.cache.write.enabled}")
@Value("${app.write.cache.nexi-postgres}")
private Boolean nexiPostgreCacheEnabled;
@Value("${nexi.postgre.serviceIdentifier}")
@Value("${app.identifiers.nexi-postgres}")
private String nexiPostgreServiceIdentifier;

@Value("${nexi.oracle.cache.write.enabled}")
@Value("${app.write.cache.nexi-oracle}")
private Boolean nexiOracleCacheEnabled;
@Value("${nexi.oracle.serviceIdentifier}")
@Value("${app.identifiers.nexi-oracle}")
private String nexiOracleServiceIdentifier;

public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum;
import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum;
import it.gov.pagopa.node.cfgsync.repository.model.StandInStations;
import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository;
import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiStandInPostgreRepository;
import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgreRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -23,6 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

@Service
Expand All @@ -36,26 +39,26 @@ public class StandInManagerService extends CommonCacheService {
private final StandInManagerClient standInManagerClient;
private final ObjectMapper objectMapper;

@Autowired
private PagoPAStandInPostgreRepository pagoPAStandInPostgreRepository;
// @Autowired
// private NexiStandInPostgreRepository nexiStandInPostgreRepository;
// @Autowired
// private NexiStandInOracleRepository nexiStandInOracleRepository;
@Autowired(required = false)
private Optional<PagoPAStandInPostgreRepository> pagoPAStandInPostgreRepository;
@Autowired(required = false)
private Optional<NexiStandInPostgreRepository> nexiStandInPostgreRepository;
@Autowired(required = false)
private Optional<NexiStandInOracleRepository> nexiStandInOracleRepository;

@Value("${pagopa.postgre.standin.write.enabled}")
@Value("${app.write.standin.pagopa-postgres}")
private Boolean pagopaPostgreStandInEnabled;
@Value("${pagopa.postgre.serviceIdentifier}")
@Value("${app.identifiers.pagopa-postgres}")
private String pagopaPostgreServiceIdentifier;

@Value("${nexi.postgre.standin.write.enabled}")
@Value("${app.write.standin.nexi-postgres}")
private Boolean nexiPostgreStandInEnabled;
@Value("${nexi.postgre.serviceIdentifier}")
@Value("${app.identifiers.nexi-postgres}")
private String nexiPostgreServiceIdentifier;

@Value("${nexi.oracle.standin.write.enabled}")
@Value("${app.write.standin.nexi-oracle}")
private Boolean nexiOracleStandInEnabled;
@Value("${nexi.oracle.serviceIdentifier}")
@Value("${app.identifiers.nexi-oracle}")
private String nexiOracleServiceIdentifier;

public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper) {
Expand Down Expand Up @@ -85,8 +88,8 @@ public Map<String, SyncStatusEnum> forceStandIn() {

try {
if (pagopaPostgreStandInEnabled) {
pagoPAStandInPostgreRepository.deleteAll();
pagoPAStandInPostgreRepository.saveAll(stationsEntities);
pagoPAStandInPostgreRepository.get().deleteAll();
pagoPAStandInPostgreRepository.get().saveAll(stationsEntities);
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done);
} else {
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled);
Expand Down
70 changes: 0 additions & 70 deletions src/main/resources/application-local.properties

This file was deleted.

78 changes: 78 additions & 0 deletions src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
info:
properties:
environment: local
cors:
configuration: '{"origins": ["*"], "methods": ["*"]}'

app:
trimCacheColumn: 'true'
identifiers:
pagopa-postgres: ${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER}
nexi-postgres: ${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER}
nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER}
write:
cache:
pagopa-postgres: 'true'
nexi-postgres: 'false'
nexi-oracle: 'false'
standin:
pagopa-postgres: 'true'
nexi-postgres: 'false'
nexi-oracle: 'false'

spring:
datasource:
pagopa:
postgres:
url: jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg
username: cfg
password: ${DB_PAGOPA_POSTGRE_PASSWORD}
enabled: 'true'
nexi:
oracle:
url: jdbc:oracle:thin:@//localhost:1521/cfg
username: cfg
password: ${DB_NEXI_ORACLE_PASSWORD}
enabled: 'false'
postgres:
url: jdbc:postgresql://localhost:5432/nodo?currentSchema=public
username: cfg
password: ${DB_NEXI_POSTGRE_PASSWORD}
enabled: 'false'
jpa:
show-sql: 'false'

stand-in-manager:
rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING}
rx-name: nodo-dei-pagamenti-stand-in
service:
subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY}
enabled: 'true'
host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1
consumer:
enabled: 'true'
sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING}
consumer-group: $Default
sa-name: synstandinreadevent

api-config-cache:
sa-name: synccachereadevent
service:
subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY}
host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1
enabled: 'true'
rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING}
sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING}
consumer:
enabled: 'true'
consumer-group: $Default
rx-name: nodo-dei-pagamenti-cache

logging:
level:
it:
gov:
pagopa: DEBUG
root: INFO


Loading

0 comments on commit ec3e8c8

Please sign in to comment.