Skip to content

Commit 9cc9df4

Browse files
committed
Use 'Session' instead of 'Connection' in config referring to pooling.
1 parent d1b4737 commit 9cc9df4

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

driver/src/main/java/org/neo4j/driver/v1/Config.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,45 @@ public ConfigBuilder withLogging( Logging logging )
161161
}
162162

163163
/**
164-
* The max number of connections to open at any given time per Neo4j instance.
165-
* @param size the size of the connection pool
164+
* The max number of sessions to keep open at once. Configure this
165+
* higher if you want more concurrent sessions, or lower if you want
166+
* to lower the pressure on the database instance.
167+
*
168+
* If the driver is asked to provide more sessions than this, it will
169+
* block waiting for another session to be closed, with a timeout.
170+
*
171+
* @param size the max number of sessions to keep open
166172
* @return this builder
167173
*/
168-
public ConfigBuilder withConnectionPoolSize( int size )
174+
public ConfigBuilder withMaxSessions( int size )
169175
{
170176
this.connectionPoolSize = size;
171177
return this;
172178
}
173179

174180
/**
175-
* Pooled connections that have been unused for longer than this timeout will be tested before they are
176-
* used again, to ensure they are still live.
177-
* @param milliSecond minimum idle time in milliseconds
181+
* Pooled sessions that have been unused for longer than this timeout
182+
* will be tested before they are used again, to ensure they are still live.
183+
*
184+
* If this option is set too low, an additional network call will be
185+
* incurred when acquiring a session, which causes a performance hit.
186+
*
187+
* If this is set high, you may receive sessions that are no longer live,
188+
* which will lead to exceptions in your application. Assuming the
189+
* database is running, these exceptions will go away if you retry acquiring
190+
* sessions.
191+
*
192+
* Hence, this parameter tunes a balance between the likelihood of your
193+
* application seeing connection problems, and performance.
194+
*
195+
* You normally should not need to tune this parameter.
196+
*
197+
* @param timeout minimum idle time in milliseconds
178198
* @return this builder
179199
*/
180-
public ConfigBuilder withMinIdleTimeBeforeConnectionTest( long milliSecond )
200+
public ConfigBuilder withSessionLivenessCheckTimeout( long timeout )
181201
{
182-
this.idleTimeBeforeConnectionTest = milliSecond;
202+
this.idleTimeBeforeConnectionTest = timeout;
183203
return this;
184204
}
185205

driver/src/test/java/org/neo4j/driver/internal/ConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void shouldChangeToTrustedCert()
8282
public void shouldConfigureMinIdleTime() throws Throwable
8383
{
8484
// when
85-
Config config = Config.build().withMinIdleTimeBeforeConnectionTest( 1337 ).toConfig();
85+
Config config = Config.build().withSessionLivenessCheckTimeout( 1337 ).toConfig();
8686

8787
// then
8888
assertThat( config.idleTimeBeforeConnectionTest(), equalTo( 1337l ));

driver/src/test/java/org/neo4j/driver/internal/pool/InternalConnectionPoolTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void shouldThrowExceptionWhenConnectionPoolIsFull() throws Throwable
5151
// Given
5252
URI uri = URI.create( "bolt://asd" );
5353
Connector connector = connector( "bolt" );
54-
Config config = Config.build().withConnectionPoolSize( 1 ).toConfig();
54+
Config config = Config.build().withMaxSessions( 1 ).toConfig();
5555
InternalConnectionPool pool = new InternalConnectionPool( singletonList( connector ),
5656
Clock.SYSTEM, config );
5757

examples/src/main/java/org/neo4j/docs/driver/Examples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static Driver configuration() throws Exception
5252
{
5353
// tag::configuration[]
5454
Driver driver =
55-
GraphDatabase.driver( "bolt://localhost", Config.build().withConnectionPoolSize( 10 ).toConfig() );
55+
GraphDatabase.driver( "bolt://localhost", Config.build().withMaxSessions( 10 ).toConfig() );
5656
// end::configuration[]
5757

5858
return driver;

0 commit comments

Comments
 (0)