Skip to content

Commit 8b8b80a

Browse files
authored
Merge pull request #237 from pontusmelke/1.1-clustered-to-routing
Rename ClusteredX to RoutingX
2 parents 8be42f1 + 7d8039f commit 8b8b80a

12 files changed

+143
-143
lines changed

driver/src/main/java/org/neo4j/driver/internal/ClusterDriver.java renamed to driver/src/main/java/org/neo4j/driver/internal/RoutingDriver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
import static java.lang.String.format;
4949

50-
public class ClusterDriver extends BaseDriver
50+
public class RoutingDriver extends BaseDriver
5151
{
5252
private static final String GET_SERVERS = "dbms.cluster.routing.getServers";
5353
private static final long MAX_TTL = Long.MAX_VALUE / 1000L;
@@ -75,7 +75,7 @@ public int compare( BoltServerAddress o1, BoltServerAddress o2 )
7575
private final ConcurrentRoundRobinSet<BoltServerAddress> writeServers = new ConcurrentRoundRobinSet<>( COMPARATOR );
7676
private final AtomicLong expires = new AtomicLong( 0L );
7777

78-
public ClusterDriver( BoltServerAddress seedAddress,
78+
public RoutingDriver( BoltServerAddress seedAddress,
7979
ConnectionPool connections,
8080
SecurityPlan securityPlan,
8181
BiFunction<Connection,Logger,Session> sessionProvider,
@@ -286,8 +286,8 @@ public Session session()
286286
@Override
287287
public Session session( final AccessMode mode )
288288
{
289-
return new ClusteredNetworkSession( mode, acquireConnection( mode ),
290-
new ClusteredErrorHandler()
289+
return new RoutingNetworkSession( mode, acquireConnection( mode ),
290+
new RoutingErrorHandler()
291291
{
292292
@Override
293293
public void onConnectionFailure( BoltServerAddress address )

driver/src/main/java/org/neo4j/driver/internal/ClusteredErrorHandler.java renamed to driver/src/main/java/org/neo4j/driver/internal/RoutingErrorHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* Interface used for tracking errors when connected to a cluster.
2525
*/
26-
interface ClusteredErrorHandler
26+
interface RoutingErrorHandler
2727
{
2828
void onConnectionFailure( BoltServerAddress address );
2929

driver/src/main/java/org/neo4j/driver/internal/ClusteredNetworkSession.java renamed to driver/src/main/java/org/neo4j/driver/internal/RoutingNetworkSession.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232

3333
import static java.lang.String.format;
3434

35-
public class ClusteredNetworkSession extends NetworkSession
35+
public class RoutingNetworkSession extends NetworkSession
3636
{
3737
private final AccessMode mode;
38-
private final ClusteredErrorHandler onError;
38+
private final RoutingErrorHandler onError;
3939

40-
ClusteredNetworkSession( AccessMode mode, Connection connection,
41-
ClusteredErrorHandler onError, Logger logger )
40+
RoutingNetworkSession( AccessMode mode, Connection connection,
41+
RoutingErrorHandler onError, Logger logger )
4242
{
4343
super( connection, logger );
4444
this.mode = mode;
@@ -50,7 +50,7 @@ public StatementResult run( Statement statement )
5050
{
5151
try
5252
{
53-
return new ClusteredStatementResult( super.run( statement ), mode, connection.address(), onError );
53+
return new RoutingStatementResult( super.run( statement ), mode, connection.address(), onError );
5454
}
5555
catch ( ConnectionFailureException e )
5656
{
@@ -75,7 +75,7 @@ public void close()
7575
}
7676
}
7777

78-
static Neo4jException filterFailureToWrite( ClientException e, AccessMode mode, ClusteredErrorHandler onError,
78+
static Neo4jException filterFailureToWrite( ClientException e, AccessMode mode, RoutingErrorHandler onError,
7979
BoltServerAddress address )
8080
{
8181
if ( isFailedToWrite( e ) )
@@ -99,7 +99,7 @@ static Neo4jException filterFailureToWrite( ClientException e, AccessMode mode,
9999
}
100100
}
101101

102-
static SessionExpiredException sessionExpired( ConnectionFailureException e, ClusteredErrorHandler onError,
102+
static SessionExpiredException sessionExpired( ConnectionFailureException e, RoutingErrorHandler onError,
103103
BoltServerAddress address )
104104
{
105105
onError.onConnectionFailure( address );

driver/src/main/java/org/neo4j/driver/internal/ClusteredStatementResult.java renamed to driver/src/main/java/org/neo4j/driver/internal/RoutingStatementResult.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@
3030
import org.neo4j.driver.v1.summary.ResultSummary;
3131
import org.neo4j.driver.v1.util.Function;
3232

33-
import static java.lang.String.format;
33+
import static org.neo4j.driver.internal.RoutingNetworkSession.filterFailureToWrite;
34+
import static org.neo4j.driver.internal.RoutingNetworkSession.sessionExpired;
3435

35-
import static org.neo4j.driver.internal.ClusteredNetworkSession.filterFailureToWrite;
36-
import static org.neo4j.driver.internal.ClusteredNetworkSession.sessionExpired;
37-
38-
public class ClusteredStatementResult implements StatementResult
36+
public class RoutingStatementResult implements StatementResult
3937
{
4038
private final StatementResult delegate;
4139
private final AccessMode mode;
4240
private final BoltServerAddress address;
43-
private final ClusteredErrorHandler onError;
41+
private final RoutingErrorHandler onError;
4442

45-
ClusteredStatementResult( StatementResult delegate, AccessMode mode, BoltServerAddress address,
46-
ClusteredErrorHandler onError )
43+
RoutingStatementResult( StatementResult delegate, AccessMode mode, BoltServerAddress address,
44+
RoutingErrorHandler onError )
4745
{
4846
this.delegate = delegate;
4947
this.mode = mode;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import java.net.URI;
2323
import java.security.GeneralSecurityException;
2424

25-
import org.neo4j.driver.internal.ClusterDriver;
2625
import org.neo4j.driver.internal.ConnectionSettings;
2726
import org.neo4j.driver.internal.DirectDriver;
2827
import org.neo4j.driver.internal.NetworkSession;
28+
import org.neo4j.driver.internal.RoutingDriver;
2929
import org.neo4j.driver.internal.net.BoltServerAddress;
3030
import org.neo4j.driver.internal.net.pooling.PoolSettings;
3131
import org.neo4j.driver.internal.net.pooling.SocketConnectionPool;
@@ -190,7 +190,7 @@ public static Driver driver( URI uri, AuthToken authToken, Config config )
190190
case "bolt":
191191
return new DirectDriver( address, connectionPool, securityPlan, config.logging() );
192192
case "bolt+routing":
193-
return new ClusterDriver( address, connectionPool, securityPlan, SESSION_PROVIDER, Clock.SYSTEM, config.logging() );
193+
return new RoutingDriver( address, connectionPool, securityPlan, SESSION_PROVIDER, Clock.SYSTEM, config.logging() );
194194
default:
195195
throw new ClientException( format( "Unsupported URI scheme: %s", scheme ) );
196196
}

driver/src/test/java/org/neo4j/driver/internal/ClusterDriverStubTest.java renamed to driver/src/test/java/org/neo4j/driver/internal/RoutingDriverStubTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import static org.junit.Assert.fail;
6060

6161
@Ignore
62-
public class ClusterDriverStubTest
62+
public class RoutingDriverStubTest
6363
{
6464
@Rule
6565
public ExpectedException exception = ExpectedException.none();
@@ -74,7 +74,7 @@ public void shouldDiscoverServers() throws IOException, InterruptedException, St
7474
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
7575

7676
// When
77-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config ) )
77+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
7878
{
7979
// Then
8080
Set<BoltServerAddress> addresses = driver.routingServers();
@@ -94,7 +94,7 @@ public void shouldDiscoverNewServers() throws IOException, InterruptedException,
9494
BoltServerAddress seed = address( 9001 );
9595

9696
// When
97-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config ) )
97+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
9898
{
9999
// Then
100100
Set<BoltServerAddress> addresses = driver.routingServers();
@@ -112,7 +112,7 @@ public void shouldHandleEmptyResponse() throws IOException, InterruptedException
112112
// Given
113113
StubServer server = StubServer.start( resource( "handle_empty_response.script" ), 9001 );
114114
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
115-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config ) )
115+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
116116
{
117117
Set<BoltServerAddress> servers = driver.routingServers();
118118
assertThat( servers, hasSize( 0 ) );
@@ -132,7 +132,7 @@ public void shouldHandleAcquireReadSession() throws IOException, InterruptedExce
132132
//START a read server
133133
StubServer readServer = StubServer.start( resource( "read_server.script" ), 9005 );
134134
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
135-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
135+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
136136
Session session = driver.session( AccessMode.READ ) )
137137
{
138138
List<String> result = session.run( "MATCH (n) RETURN n.name" ).list( new Function<Record,String>()
@@ -162,7 +162,7 @@ public void shouldRoundRobinReadServers() throws IOException, InterruptedExcepti
162162
StubServer readServer1 = StubServer.start( resource( "read_server.script" ), 9005 );
163163
StubServer readServer2 = StubServer.start( resource( "read_server.script" ), 9006 );
164164
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
165-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config ) )
165+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
166166
{
167167
// Run twice, one on each read server
168168
for ( int i = 0; i < 2; i++ )
@@ -200,7 +200,7 @@ public void shouldThrowSessionExpiredIfReadServerDisappears()
200200
//START a read server
201201
StubServer.start( resource( "dead_server.script" ), 9005 );
202202
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
203-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
203+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
204204
Session session = driver.session( AccessMode.READ ) )
205205
{
206206
session.run( "MATCH (n) RETURN n.name" );
@@ -223,7 +223,7 @@ public void shouldThrowSessionExpiredIfWriteServerDisappears()
223223
//START a dead write servers
224224
StubServer.start( resource( "dead_server.script" ), 9007 );
225225
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
226-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
226+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
227227
Session session = driver.session( AccessMode.WRITE ) )
228228
{
229229
session.run( "MATCH (n) RETURN n.name" ).consume();
@@ -241,7 +241,7 @@ public void shouldHandleAcquireWriteSession() throws IOException, InterruptedExc
241241
//START a write server
242242
StubServer writeServer = StubServer.start( resource( "write_server.script" ), 9007 );
243243
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
244-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
244+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
245245
Session session = driver.session( AccessMode.WRITE ) )
246246
{
247247
session.run( "CREATE (n {name:'Bob'})" );
@@ -261,7 +261,7 @@ public void shouldRoundRobinWriteSessions() throws IOException, InterruptedExcep
261261
StubServer writeServer1 = StubServer.start( resource( "write_server.script" ), 9007 );
262262
StubServer writeServer2 = StubServer.start( resource( "write_server.script" ), 9008 );
263263
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
264-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config ) )
264+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config ) )
265265
{
266266
for ( int i = 0; i < 2; i++ )
267267
{
@@ -286,7 +286,7 @@ public void shouldRememberEndpoints() throws IOException, InterruptedException,
286286
//START a read server
287287
StubServer readServer = StubServer.start( resource( "read_server.script" ), 9005 );
288288
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
289-
try ( ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
289+
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
290290
Session session = driver.session( AccessMode.READ ) )
291291
{
292292
session.run( "MATCH (n) RETURN n.name" ).consume();
@@ -309,7 +309,7 @@ public void shouldForgetEndpointsOnFailure() throws IOException, InterruptedExce
309309
//START a read server
310310
StubServer.start( resource( "dead_server.script" ), 9005 );
311311
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
312-
ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
312+
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
313313
try
314314
{
315315
Session session = driver.session( AccessMode.READ );
@@ -343,7 +343,7 @@ public void shouldRediscoverIfNecessaryOnSessionAcquisition()
343343
StubServer read = StubServer.start( resource( "empty.script" ), 9005 );
344344

345345
//On creation we only find ourselves
346-
ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
346+
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
347347
assertThat( driver.routingServers(), containsInAnyOrder( address( 9001 ) ) );
348348
assertTrue( driver.connectionPool().hasAddress( address( 9001 ) ) );
349349

@@ -372,7 +372,7 @@ public void shouldOnlyGetServersOnce() throws IOException, InterruptedException,
372372
StubServer read = StubServer.start( resource( "empty.script" ), 9005 );
373373

374374
//On creation we only find ourselves
375-
final ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
375+
final RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
376376
assertThat( driver.routingServers(), containsInAnyOrder( address( 9001 ) ) );
377377

378378
ExecutorService runner = Executors.newFixedThreadPool( 10 );
@@ -441,7 +441,7 @@ public void shouldHandleLeaderSwitchWhenWriting()
441441
//START a write server that doesn't accept writes
442442
StubServer.start( resource( "not_able_to_write_server.script" ), 9007 );
443443
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
444-
ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
444+
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
445445
boolean failed = false;
446446
try ( Session session = driver.session( AccessMode.WRITE ) )
447447
{
@@ -473,7 +473,7 @@ public void shouldRediscoverOnExpiry() throws IOException, InterruptedException,
473473
//START a read server
474474
StubServer readServer = StubServer.start( resource( "empty.script" ), 9005 );
475475
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
476-
ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
476+
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
477477
assertThat(driver.routingServers(), contains(address( 9001 )));
478478
assertThat(driver.readServers(), contains(address( 9002 )));
479479
assertThat(driver.writeServers(), contains(address( 9003 )));
@@ -502,7 +502,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
502502
StubServer writeServer2 = StubServer.start( resource( "empty.script" ), 9006 );
503503
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
504504

505-
ClusterDriver driver = (ClusterDriver) GraphDatabase.driver( uri, config );
505+
RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
506506

507507

508508
//Open both a read and a write session
@@ -532,7 +532,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
532532

533533
// now we close the read session and the connection should not be put
534534
// back to the pool
535-
Connection connection = ((ClusteredNetworkSession) readSession).connection;
535+
Connection connection = ((RoutingNetworkSession) readSession).connection;
536536
assertTrue( connection.isOpen() );
537537
readSession.close();
538538
assertFalse( connection.isOpen() );
@@ -550,7 +550,7 @@ public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedEx
550550

551551
String resource( String fileName )
552552
{
553-
URL resource = ClusterDriverStubTest.class.getClassLoader().getResource( fileName );
553+
URL resource = RoutingDriverStubTest.class.getClassLoader().getResource( fileName );
554554
if ( resource == null )
555555
{
556556
fail( fileName + " does not exists" );

0 commit comments

Comments
 (0)