mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-17 13:13:15 +00:00
Fix 2592 neo4j connection options (#2632)
This commit is contained in:
parent
5eee818a61
commit
2cb06188ce
@ -27,20 +27,38 @@ public class Neo4jDriverFactory {
|
|||||||
@Value("${NEO4J_MAX_CONNECTION_ACQUISITION_TIMEOUT_IN_SECONDS:60}")
|
@Value("${NEO4J_MAX_CONNECTION_ACQUISITION_TIMEOUT_IN_SECONDS:60}")
|
||||||
private Long neo4jMaxConnectionAcquisitionTimeout;
|
private Long neo4jMaxConnectionAcquisitionTimeout;
|
||||||
|
|
||||||
@Value("${NEO4j_MAX_CONNECTION_LIFETIME_IN_HOURS:1}")
|
// Kept for sake of backwards compatibility. Instead use NEO4j_MAX_CONNECTION_LIFETIME_IN_SECONDS
|
||||||
private Long neo4jMaxConnectionLifetime;
|
@Value("${NEO4j_MAX_CONNECTION_LIFETIME_IN_HOURS:#{null}}")
|
||||||
|
private Long neo4jMaxConnectionLifetimeInHours;
|
||||||
|
|
||||||
|
@Value("${NEO4j_MAX_CONNECTION_LIFETIME_IN_SECONDS:3600}")
|
||||||
|
private Long neo4jMaxConnectionLifetimeInSeconds;
|
||||||
|
|
||||||
@Value("${NEO4J_MAX_TRANSACTION_RETRY_TIME_IN_SECONDS:30}")
|
@Value("${NEO4J_MAX_TRANSACTION_RETRY_TIME_IN_SECONDS:30}")
|
||||||
private Long neo4jMaxTransactionRetryTime;
|
private Long neo4jMaxTransactionRetryTime;
|
||||||
|
|
||||||
|
@Value("${NEO4J_CONNECTION_LIVENESS_CHECK_TIMEOUT_IN_SECONDS:-1}")
|
||||||
|
private Long neo4jConnectionLivenessCheckTimeout;
|
||||||
|
|
||||||
@Bean(name = "neo4jDriver")
|
@Bean(name = "neo4jDriver")
|
||||||
protected Driver createInstance() {
|
protected Driver createInstance() {
|
||||||
|
|
||||||
Config.ConfigBuilder builder = Config.builder();
|
Config.ConfigBuilder builder = Config.builder();
|
||||||
builder.withMaxConnectionPoolSize(neo4jMaxConnectionPoolSize);
|
builder.withMaxConnectionPoolSize(neo4jMaxConnectionPoolSize);
|
||||||
builder.withConnectionAcquisitionTimeout(neo4jMaxConnectionAcquisitionTimeout, TimeUnit.SECONDS);
|
builder.withConnectionAcquisitionTimeout(neo4jMaxConnectionAcquisitionTimeout, TimeUnit.SECONDS);
|
||||||
builder.withMaxConnectionLifetime(neo4jMaxConnectionLifetime, TimeUnit.HOURS);
|
builder.withMaxConnectionLifetime(neo4jMaxConnectionLifetime(), TimeUnit.SECONDS);
|
||||||
builder.withMaxTransactionRetryTime(neo4jMaxTransactionRetryTime, TimeUnit.SECONDS);
|
builder.withMaxTransactionRetryTime(neo4jMaxTransactionRetryTime, TimeUnit.SECONDS);
|
||||||
|
builder.withConnectionLivenessCheckTimeout(neo4jConnectionLivenessCheckTimeout, TimeUnit.SECONDS);
|
||||||
|
|
||||||
return GraphDatabase.driver(uri, AuthTokens.basic(username, password), builder.build());
|
return GraphDatabase.driver(uri, AuthTokens.basic(username, password), builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Long neo4jMaxConnectionLifetime() {
|
||||||
|
|
||||||
|
// neo4jMaxConnectionLifetimeInHours has precedence over neo4jMaxConnectionLifetimeInSeconds
|
||||||
|
if (neo4jMaxConnectionLifetimeInHours != null) {
|
||||||
|
return neo4jMaxConnectionLifetimeInHours * 3600;
|
||||||
|
}
|
||||||
|
return neo4jMaxConnectionLifetimeInSeconds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user