Modifier and Type | Method and Description |
---|---|
Config |
toConfig()
Create a config instance from this builder.
|
Config.ConfigBuilder |
withConnectionAcquisitionTimeout(long value,
TimeUnit unit)
Configure maximum amount of time connection acquisition will attempt to acquire a connection from the
connection pool.
|
Config.ConfigBuilder |
withConnectionLivenessCheckTimeout(long value,
TimeUnit unit)
Pooled connections that have been idle in the pool for longer than this timeout
will be tested before they are used again, to ensure they are still live.
|
Config.ConfigBuilder |
withConnectionTimeout(long value,
TimeUnit unit)
Specify socket connection timeout.
|
Config.ConfigBuilder |
withEncryption()
Set to use encrypted traffic.
|
Config.ConfigBuilder |
withEncryptionLevel(Config.EncryptionLevel level)
Deprecated.
|
Config.ConfigBuilder |
withLeakedSessionsLogging()
Enable logging of leaked sessions.
|
Config.ConfigBuilder |
withLoadBalancingStrategy(Config.LoadBalancingStrategy loadBalancingStrategy)
Provide an alternative load balancing strategy for the routing driver to use.
|
Config.ConfigBuilder |
withLogging(Logging logging)
Provide an alternative logging implementation for the driver to use.
|
Config.ConfigBuilder |
withMaxConnectionLifetime(long value,
TimeUnit unit)
Pooled connections older than this threshold will be closed and removed from the pool.
|
Config.ConfigBuilder |
withMaxConnectionPoolSize(int value)
Configure maximum amount of connections in the connection pool towards a single database.
|
Config.ConfigBuilder |
withMaxIdleConnections(int size)
Deprecated.
please use a combination of
withMaxConnectionPoolSize(int) and
withConnectionAcquisitionTimeout(long, TimeUnit) instead. |
Config.ConfigBuilder |
withMaxIdleSessions(int size)
Deprecated.
please use a combination of
withMaxConnectionPoolSize(int) and
withConnectionAcquisitionTimeout(long, TimeUnit) instead. |
Config.ConfigBuilder |
withMaxSessions(int size)
Deprecated.
please use a combination of
withMaxConnectionPoolSize(int) and
withConnectionAcquisitionTimeout(long, TimeUnit) instead. |
Config.ConfigBuilder |
withMaxTransactionRetryTime(long value,
TimeUnit unit)
Specify the maximum time transactions are allowed to retry via
Session.readTransaction(TransactionWork) and Session.writeTransaction(TransactionWork)
methods. |
Config.ConfigBuilder |
withoutEncryption()
Set to use unencrypted traffic.
|
Config.ConfigBuilder |
withRoutingFailureLimit(int routingFailureLimit)
Deprecated.
in 1.2 because driver memorizes seed URI used during construction and falls back to it at
runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
failure. Currently there exists a better way of doing retries via
Session.readTransaction(TransactionWork) and Session.writeTransaction(TransactionWork) .
Method will be removed in the next major release. |
Config.ConfigBuilder |
withRoutingRetryDelay(long delay,
TimeUnit unit)
Deprecated.
in 1.2 because driver memorizes seed URI used during construction and falls back to it at
runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
failure. Currently there exists a better way of doing retries via
Session.readTransaction(TransactionWork) and Session.writeTransaction(TransactionWork) .
Method will be removed in the next major release. |
Config.ConfigBuilder |
withSessionLivenessCheckTimeout(long timeout)
Deprecated.
please use
withConnectionLivenessCheckTimeout(long, TimeUnit) method. This method
will be removed in future release. |
Config.ConfigBuilder |
withTrustStrategy(Config.TrustStrategy trustStrategy)
Specify how to determine the authenticity of an encryption certificate provided by the Neo4j instance we are connecting to.
|
public Config.ConfigBuilder withLogging(Logging logging)
logging
- the logging instance to use@Experimental public Config.ConfigBuilder withLoadBalancingStrategy(Config.LoadBalancingStrategy loadBalancingStrategy)
Config.LoadBalancingStrategy.LEAST_CONNECTED
.
Note: We are experimenting with different strategies. This could be removed in the next minor version.
loadBalancingStrategy
- the strategy to usepublic Config.ConfigBuilder withLeakedSessionsLogging()
Each session
is associated with a network connection and thus is a
resource
that needs to be explicitly closed. Unclosed sessions will result in socket
leaks and could cause OutOfMemoryError
s.
Session is considered to be leaked when it is finalized via Object.finalize()
while not being
closed. This option turns on logging of such sessions and stacktraces of where they were created.
Note: this option should mostly be used in testing environments for session leak investigations. Enabling it will add object finalization overhead.
@Deprecated public Config.ConfigBuilder withMaxSessions(int size)
withMaxConnectionPoolSize(int)
and
withConnectionAcquisitionTimeout(long, TimeUnit)
instead.If the driver is asked to provide more sessions than this, it will block waiting for another session to be closed, with a timeout.
Method is deprecated and will forward the given argument to withMaxConnectionPoolSize(int)
.
size
- the max number of sessions to keep open@Deprecated public Config.ConfigBuilder withMaxIdleSessions(int size)
withMaxConnectionPoolSize(int)
and
withConnectionAcquisitionTimeout(long, TimeUnit)
instead.Method is deprecated and will not change the driver configuration.
size
- the max number of idle sessions to keep open@Deprecated public Config.ConfigBuilder withMaxIdleConnections(int size)
withMaxConnectionPoolSize(int)
and
withConnectionAcquisitionTimeout(long, TimeUnit)
instead.Method is deprecated and will not change the driver configuration.
size
- the max number of idle connections to keep open@Deprecated public Config.ConfigBuilder withSessionLivenessCheckTimeout(long timeout)
withConnectionLivenessCheckTimeout(long, TimeUnit)
method. This method
will be removed in future release.timeout
- minimum idle time in millisecondswithConnectionLivenessCheckTimeout(long, TimeUnit)
public Config.ConfigBuilder withConnectionLivenessCheckTimeout(long value, TimeUnit unit)
If this option is set too low, an additional network call will be incurred when acquiring a connection, which causes a performance hit.
If this is set high, you may receive sessions that are backed by no longer live connections, which will lead to exceptions in your application. Assuming the database is running, these exceptions will go away if you retry acquiring sessions.
Hence, this parameter tunes a balance between the likelihood of your application seeing connection problems, and performance.
You normally should not need to tune this parameter.
No connection liveliness check is done by default.
Value 0
means connections will always be tested for
validity and negative values mean connections will never be tested.
value
- the minimum idle timeunit
- the unit in which the duration is givenpublic Config.ConfigBuilder withMaxConnectionLifetime(long value, TimeUnit unit)
Setting this option to a low value will cause a high connection churn and might result in a performance hit.
It is recommended to set maximum lifetime to a slightly smaller value than the one configured in network equipment (load balancer, proxy, firewall, etc. can also limit maximum connection lifetime).
Setting can also be used in combination with withConnectionLivenessCheckTimeout(long, TimeUnit)
. In
this case, it is recommended to set liveness check to a value smaller than network equipment has and maximum
lifetime to a reasonably large value to "renew" connections once in a while.
Default maximum connection lifetime is 1 hour. Zero and negative values result in lifetime not being checked.
value
- the maximum connection lifetimeunit
- the unit in which the duration is givenpublic Config.ConfigBuilder withMaxConnectionPoolSize(int value)
Acquisition will be attempted for at most configured timeout
withConnectionAcquisitionTimeout(long, TimeUnit)
when limit is reached.
Default value is 100
. Negative values are allowed and result in unlimited pool. Value of 0
is not allowed.
value
- the maximum connection pool size.withConnectionAcquisitionTimeout(long, TimeUnit)
public Config.ConfigBuilder withConnectionAcquisitionTimeout(long value, TimeUnit unit)
Exception is raised when connection can't be acquired within configured time.
Default value is 60 seconds. Negative values are allowed and result in unlimited acquisition timeout. Value
of 0
is allowed and results in no timeout and immediate failure when connection is unavailable.
value
- the acquisition timeoutunit
- the unit in which the duration is givenwithMaxConnectionPoolSize(int)
@Deprecated public Config.ConfigBuilder withEncryptionLevel(Config.EncryptionLevel level)
Config.EncryptionLevel
to use, use this to control wether the driver uses TLS encryption or not.level
- the TLS level to usepublic Config.ConfigBuilder withEncryption()
public Config.ConfigBuilder withoutEncryption()
public Config.ConfigBuilder withTrustStrategy(Config.TrustStrategy trustStrategy)
Config.TrustStrategy.trustOnFirstUse(File)
.
See Config.TrustStrategy.trustCustomCertificateSignedBy(File)
for using certificate signatures instead to verify
trust.
This is an important setting to understand, because unless we know that the remote server we have an encrypted connection to is really Neo4j, there is no point to encrypt at all, since anyone could pretend to be the remote Neo4j instance.
For this reason, there is no option to disable trust verification, if you find this cumbersome you should disable encryption using
trustStrategy
- TLS authentication strategy@Deprecated public Config.ConfigBuilder withRoutingFailureLimit(int routingFailureLimit)
Session.readTransaction(TransactionWork)
and Session.writeTransaction(TransactionWork)
.
Method will be removed in the next major release.The routing servers are tried in order. If connecting any of them fails, they are all retried after a delay. This process of retrying all servers is then repeated for the number of times specified here before considering the cluster unavailable.
The default value of this parameter is 1
, which means that the the driver will not re-attempt to
connect to the cluster when connecting has failed to each individual server in the list of routers. This
default value is sensible under this assumption that if the attempt to connect fails for all servers, then
the entire cluster is down, or the client is disconnected from the network, and retrying to connect will
not bring it back up, in which case it is better to report the failure sooner.
routingFailureLimit
- the number of times to retry each server in the list of routing servers@Deprecated public Config.ConfigBuilder withRoutingRetryDelay(long delay, TimeUnit unit)
Session.readTransaction(TransactionWork)
and Session.writeTransaction(TransactionWork)
.
Method will be removed in the next major release.When connecting to all routing servers fail, connecting will be retried after the delay specified here. The delay is measured from when the first attempt to connect was made, so that the delay time specifies a retry interval.
For each retry attempt the delay time will be doubled. The time
specified here is the base time, i.e. the time to wait before the first retry. If that attempt (on all
servers) also fails, the delay before the next retry will be double the time specified here, and the next
attempt after that will be double that, et.c. So if, for example, the delay specified here is
5 SECONDS
, then after attempting to connect to each server fails reconnecting will be attempted
5 seconds after the first connection attempt to the first server. If that attempt also fails to connect to
all servers, the next attempt will start 10 seconds after the second attempt started.
The default value of this parameter is 5 SECONDS
.
delay
- the amount of time between attempts to reconnect to the same serverunit
- the unit in which the duration is givenpublic Config.ConfigBuilder withConnectionTimeout(long value, TimeUnit unit)
A timeout of zero is treated as an infinite timeout and will be bound by the timeout configured on the operating system level. The connection will block until established or an error occurs.
Timeout value should be greater or equal to zero and represent a valid int
value when converted to
milliseconds
.
The default value of this parameter is 5 SECONDS
.
value
- the timeout durationunit
- the unit in which duration is givenIllegalArgumentException
- when given value is negative or does not fit in int
when
converted to milliseconds.public Config.ConfigBuilder withMaxTransactionRetryTime(long value, TimeUnit unit)
Session.readTransaction(TransactionWork)
and Session.writeTransaction(TransactionWork)
methods. These methods will retry the given unit of work on ServiceUnavailableException
,
SessionExpiredException
and TransientException
with exponential backoff using initial
delay of 1 second.
Default value is 30 seconds.
value
- the timeout durationunit
- the unit in which duration is givenIllegalArgumentException
- when given value is negativeCopyright © 2017. All rights reserved.