Modifier and Type | Method and Description |
---|---|
Config |
toConfig()
Create a config instance from this builder.
|
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 |
withLogging(Logging logging)
Provide an alternative logging implementation for the driver to use.
|
Config.ConfigBuilder |
withMaxIdleSessions(int size)
The max number of idle sessions to keep open at once.
|
Config.ConfigBuilder |
withMaxSessions(int size)
Deprecated.
|
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 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)
size
- the max number of sessions to keep openpublic Config.ConfigBuilder withMaxIdleSessions(int size)
size
- the max number of idle sessions 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.
This feature is turned off 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 time in millisecondsunit
- the unit in which the duration is given@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.