Skip to content

Ensured the driver config is used consistently in cluster stress IT #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions driver/src/main/java/org/neo4j/driver/GraphDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.neo4j.driver.exceptions.ServiceUnavailableException;
import org.neo4j.driver.internal.DriverFactory;
import org.neo4j.driver.internal.Scheme;
import org.neo4j.driver.internal.SecuritySettings;
import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.retry.RetrySettings;
Expand Down Expand Up @@ -136,7 +135,6 @@ public static Driver driver( URI uri, AuthToken authToken, Config config )
RoutingSettings routingSettings = config.routingSettings();
RetrySettings retrySettings = config.retrySettings();
SecuritySettings securitySettings = config.securitySettings();
Scheme.validateScheme( uri.getScheme() );
SecurityPlan securityPlan = securitySettings.createSecurityPlan( uri.getScheme() );
return new DriverFactory().newInstance( uri, authToken, routingSettings, retrySettings, config, securityPlan );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.neo4j.driver.Driver;
import org.neo4j.driver.Logger;
import org.neo4j.driver.Logging;
import org.neo4j.driver.exceptions.ClientException;
import org.neo4j.driver.internal.async.connection.BootstrapFactory;
import org.neo4j.driver.internal.async.connection.ChannelConnector;
import org.neo4j.driver.internal.async.connection.ChannelConnectorImpl;
Expand All @@ -55,15 +54,13 @@
import org.neo4j.driver.internal.util.Futures;
import org.neo4j.driver.net.ServerAddressResolver;

import static java.lang.String.format;
import static org.neo4j.driver.internal.Scheme.isRoutingScheme;
import static org.neo4j.driver.internal.cluster.IdentityResolver.IDENTITY_RESOLVER;
import static org.neo4j.driver.internal.metrics.MetricsProvider.METRICS_DISABLED_PROVIDER;
import static org.neo4j.driver.internal.util.ErrorUtil.addSuppressed;

public class DriverFactory
{

public final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings routingSettings,
RetrySettings retrySettings, Config config, SecurityPlan securityPlan )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private boolean isCustomized()

public SecurityPlan createSecurityPlan( String uriScheme )
{
Scheme.validateScheme( uriScheme );
try
{
if ( isSecurityScheme( uriScheme ) )
Expand Down Expand Up @@ -160,4 +161,4 @@ public SecuritySettings build()
return isCustomized ? new SecuritySettings( encrypted, trustStrategy ) : SecuritySettings.DEFAULT;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.security.SecurityPlanImpl;
import org.neo4j.driver.internal.util.io.ChannelTrackingDriverFactory;
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.internal.util.FakeClock;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Session;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.Transaction;
import org.neo4j.driver.exceptions.ClientException;
import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.security.SecurityPlanImpl;
import org.neo4j.driver.internal.util.FakeClock;
import org.neo4j.driver.internal.util.io.ChannelTrackingDriverFactory;
import org.neo4j.driver.util.DatabaseExtension;
import org.neo4j.driver.util.ParallelizableIT;

Expand Down Expand Up @@ -142,9 +141,10 @@ void shouldRespectMaxConnectionPoolSize()
Config config = Config.builder()
.withMaxConnectionPoolSize( maxPoolSize )
.withConnectionAcquisitionTimeout( 542, TimeUnit.MILLISECONDS )
.withEventLoopThreads( 1 )
.build();

driver = new DriverFactoryWithOneEventLoopThread().newInstance( neo4j.uri(), neo4j.authToken(), config );
driver = GraphDatabase.driver( neo4j.uri(), neo4j.authToken(), config );

ClientException e = assertThrows( ClientException.class, () -> startAndCloseTransactions( driver, maxPoolSize + 1 ) );
assertThat( e, is( connectionAcquisitionTimeoutError( 542 ) ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.neo4j.driver.internal.security.SecurityPlanImpl;
import org.neo4j.driver.internal.util.DisabledOnNeo4jWith;
import org.neo4j.driver.internal.util.DriverFactoryWithFixedRetryLogic;
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxSession;
Expand Down Expand Up @@ -880,9 +879,10 @@ void shouldNotRetryOnConnectionAcquisitionTimeout()
.withMaxConnectionPoolSize( maxPoolSize )
.withConnectionAcquisitionTimeout( 0, TimeUnit.SECONDS )
.withMaxTransactionRetryTime( 42, TimeUnit.DAYS ) // retry for a really long time
.withEventLoopThreads( 1 )
.build();

driver = new DriverFactoryWithOneEventLoopThread().newInstance( neo4j.uri(), neo4j.authToken(), config );
driver = GraphDatabase.driver( neo4j.uri(), neo4j.authToken(), config );

for ( int i = 0; i < maxPoolSize; i++ )
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.util.cc.ClusterMemberRoleDiscoveryFactory.ClusterMemberRoleDiscovery;

import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
Expand Down Expand Up @@ -71,8 +71,7 @@ public void close()

private Driver createDriver( ClusterMember member )
{
DriverFactoryWithOneEventLoopThread factory = new DriverFactoryWithOneEventLoopThread();
return factory.newInstance( member.getBoltUri(), AuthTokens.basic( user, password ), driverConfig() );
return GraphDatabase.driver( member.getBoltUri(), AuthTokens.basic( user, password ), driverConfig() );
}

private static Config driverConfig()
Expand All @@ -82,6 +81,7 @@ private static Config driverConfig()
.withoutEncryption()
.withMaxConnectionPoolSize( 1 )
.withConnectionLivenessCheckTimeout( 0, TimeUnit.MILLISECONDS )
.withEventLoopThreads( 1 )
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.util.TestUtil;

import static org.neo4j.driver.Config.defaultConfig;
import static org.neo4j.driver.internal.Scheme.NEO4J_URI_SCHEME;

public class LocalOrRemoteClusterExtension implements BeforeAllCallback, AfterEachCallback, AfterAllCallback
Expand Down Expand Up @@ -124,8 +123,10 @@ public void dumpClusterLogs()

private void deleteDataInRemoteCluster()
{
DriverFactoryWithOneEventLoopThread driverFactory = new DriverFactoryWithOneEventLoopThread();
try ( Driver driver = driverFactory.newInstance( getClusterUri(), getAuthToken(), defaultConfig() ) )
Config.ConfigBuilder builder = Config.builder();
builder.withEventLoopThreads( 1 );

try ( Driver driver = GraphDatabase.driver( getClusterUri(), getAuthToken(), config( builder ).build() ) )
{
TestUtil.cleanDb( driver );
}
Expand Down