fix #558: stabilize deployment and role rendering
This commit is contained in:
@@ -14,6 +14,8 @@ import java.util.Locale;
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -21,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class OrdsMetadataService {
|
||||
|
||||
private static final String VECTOR_SEARCH_OBJECT = "CB_VECTOR_SEARCH_DOCUMENTS";
|
||||
private static final Logger log = LoggerFactory.getLogger(OrdsMetadataService.class);
|
||||
|
||||
private final OrdsMetadataMapper mapper;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
@@ -40,6 +43,8 @@ public class OrdsMetadataService {
|
||||
this.mapper = mapper;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.protectedObjectService = protectedObjectService;
|
||||
HikariDataSource metadataDataSource = null;
|
||||
JdbcTemplate metadataJdbcTemplate = new JdbcTemplate(dataSource);
|
||||
if (hasText(ordsMetadataUrl) && hasText(ordsMetadataUsername)) {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("vpd-ords-metadata-pool");
|
||||
@@ -50,12 +55,24 @@ public class OrdsMetadataService {
|
||||
config.setMaximumPoolSize(2);
|
||||
config.setMinimumIdle(0);
|
||||
config.setConnectionTimeout(10000);
|
||||
this.ordsMetadataDataSource = new HikariDataSource(config);
|
||||
this.ordsMetadataJdbcTemplate = new JdbcTemplate(this.ordsMetadataDataSource);
|
||||
} else {
|
||||
this.ordsMetadataDataSource = null;
|
||||
this.ordsMetadataJdbcTemplate = new JdbcTemplate(dataSource);
|
||||
// ORDS metadata is an optional administrative connection. Do not fail
|
||||
// the whole backoffice startup when the remote TNS host is temporarily
|
||||
// unavailable; Handler create/update will report the connection error
|
||||
// at the point of use instead.
|
||||
config.setInitializationFailTimeout(-1);
|
||||
try {
|
||||
metadataDataSource = new HikariDataSource(config);
|
||||
metadataJdbcTemplate = new JdbcTemplate(metadataDataSource);
|
||||
} catch (RuntimeException exception) {
|
||||
log.warn("ORDS metadata DB is unavailable; using the main DB for read-only fallback: {}",
|
||||
exception.getMessage());
|
||||
if (metadataDataSource != null) {
|
||||
metadataDataSource.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ordsMetadataDataSource = metadataDataSource;
|
||||
this.ordsMetadataJdbcTemplate = metadataJdbcTemplate;
|
||||
}
|
||||
|
||||
public List<OrdsHandlerView> findHandlers() {
|
||||
|
||||
Reference in New Issue
Block a user