3838import org .neo4j .driver .internal .cluster .loadbalancing .LoadBalancingStrategy ;
3939import org .neo4j .driver .internal .cluster .loadbalancing .RoundRobinLoadBalancingStrategy ;
4040import org .neo4j .driver .internal .logging .NettyLogging ;
41- import org .neo4j .driver .internal .metrics .DriverMetricsListener ;
42- import org .neo4j .driver .internal .metrics .InternalAbstractDriverMetrics ;
43- import org .neo4j .driver .internal .metrics .InternalDriverMetrics ;
41+ import org .neo4j .driver .internal .metrics .MetricsListener ;
42+ import org .neo4j .driver .internal .metrics .InternalAbstractMetrics ;
43+ import org .neo4j .driver .internal .metrics .InternalMetrics ;
44+ import org .neo4j .driver .internal .metrics .spi .Metrics ;
4445import org .neo4j .driver .internal .retry .ExponentialBackoffRetryLogic ;
4546import org .neo4j .driver .internal .retry .RetryLogic ;
4647import org .neo4j .driver .internal .retry .RetrySettings ;
5960import org .neo4j .driver .v1 .exceptions .ServiceUnavailableException ;
6061
6162import static java .lang .String .format ;
62- import static org .neo4j .driver .internal .metrics .InternalAbstractDriverMetrics .DEV_NULL_METRICS ;
63- import static org .neo4j .driver .internal .metrics .spi .DriverMetrics . isDriverMetricsEnabled ;
63+ import static org .neo4j .driver .internal .metrics .InternalAbstractMetrics .DEV_NULL_METRICS ;
64+ import static org .neo4j .driver .internal .metrics .spi .Metrics . isMetricsEnabled ;
6465import static org .neo4j .driver .internal .security .SecurityPlan .insecure ;
6566
6667public class DriverFactory
@@ -82,19 +83,17 @@ public final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings r
8283 EventExecutorGroup eventExecutorGroup = bootstrap .config ().group ();
8384 RetryLogic retryLogic = createRetryLogic ( retrySettings , eventExecutorGroup , config .logging () );
8485
85- InternalAbstractDriverMetrics metrics = createDriverMetrics ( config );
86+ InternalAbstractMetrics metrics = createDriverMetrics ( config );
8687 ConnectionPool connectionPool = createConnectionPool ( authToken , securityPlan , bootstrap , metrics , config );
8788
88- InternalDriver driver = createDriver ( uri , address , connectionPool , config , newRoutingSettings ,
89- eventExecutorGroup , securityPlan , retryLogic );
89+ InternalDriver driver = createDriver ( uri , securityPlan , address , connectionPool , eventExecutorGroup , newRoutingSettings , retryLogic , metrics , config );
9090
91- driver .driverMetrics ( metrics );
9291 verifyConnectivity ( driver , connectionPool , config );
9392
9493 return driver ;
9594 }
9695
97- protected ConnectionPool createConnectionPool ( AuthToken authToken , SecurityPlan securityPlan , Bootstrap bootstrap , DriverMetricsListener metrics , Config config )
96+ protected ConnectionPool createConnectionPool ( AuthToken authToken , SecurityPlan securityPlan , Bootstrap bootstrap , MetricsListener metrics , Config config )
9897 {
9998 Clock clock = createClock ();
10099 ConnectionSettings settings = new ConnectionSettings ( authToken , config .connectionTimeoutMillis () );
@@ -106,11 +105,11 @@ protected ConnectionPool createConnectionPool( AuthToken authToken, SecurityPlan
106105 return new ConnectionPoolImpl ( connector , bootstrap , poolSettings , metrics , config .logging (), clock );
107106 }
108107
109- protected static InternalAbstractDriverMetrics createDriverMetrics ( Config config )
108+ protected static InternalAbstractMetrics createDriverMetrics ( Config config )
110109 {
111- if ( isDriverMetricsEnabled () )
110+ if ( isMetricsEnabled () )
112111 {
113- return new InternalDriverMetrics ( config );
112+ return new InternalMetrics ( config );
114113 }
115114 else
116115 {
@@ -124,9 +123,8 @@ protected ChannelConnector createConnector( ConnectionSettings settings, Securit
124123 return new ChannelConnectorImpl ( settings , securityPlan , config .logging (), clock );
125124 }
126125
127- private InternalDriver createDriver ( URI uri , BoltServerAddress address ,
128- ConnectionPool connectionPool , Config config , RoutingSettings routingSettings ,
129- EventExecutorGroup eventExecutorGroup , SecurityPlan securityPlan , RetryLogic retryLogic )
126+ private InternalDriver createDriver ( URI uri , SecurityPlan securityPlan , BoltServerAddress address , ConnectionPool connectionPool ,
127+ EventExecutorGroup eventExecutorGroup , RoutingSettings routingSettings , RetryLogic retryLogic , Metrics metrics , Config config )
130128 {
131129 try
132130 {
@@ -135,10 +133,9 @@ private InternalDriver createDriver( URI uri, BoltServerAddress address,
135133 {
136134 case BOLT_URI_SCHEME :
137135 assertNoRoutingContext ( uri , routingSettings );
138- return createDirectDriver ( address , config , securityPlan , retryLogic , connectionPool );
136+ return createDirectDriver ( securityPlan , address , connectionPool , retryLogic , metrics , config );
139137 case BOLT_ROUTING_URI_SCHEME :
140- return createRoutingDriver ( address , connectionPool , config , routingSettings , securityPlan , retryLogic ,
141- eventExecutorGroup );
138+ return createRoutingDriver ( securityPlan , address , connectionPool , eventExecutorGroup , routingSettings , retryLogic , metrics , config );
142139 default :
143140 throw new ClientException ( format ( "Unsupported URI scheme: %s" , scheme ) );
144141 }
@@ -156,22 +153,21 @@ private InternalDriver createDriver( URI uri, BoltServerAddress address,
156153 * <p>
157154 * <b>This method is protected only for testing</b>
158155 */
159- protected InternalDriver createDirectDriver ( BoltServerAddress address , Config config ,
160- SecurityPlan securityPlan , RetryLogic retryLogic , ConnectionPool connectionPool )
156+ protected InternalDriver createDirectDriver ( SecurityPlan securityPlan , BoltServerAddress address , ConnectionPool connectionPool , RetryLogic retryLogic ,
157+ Metrics metrics , Config config )
161158 {
162159 ConnectionProvider connectionProvider = new DirectConnectionProvider ( address , connectionPool );
163160 SessionFactory sessionFactory = createSessionFactory ( connectionProvider , retryLogic , config );
164- return createDriver ( sessionFactory , securityPlan , config );
161+ return createDriver ( securityPlan , sessionFactory , metrics , config );
165162 }
166163
167164 /**
168165 * Creates new a new driver for "bolt+routing" scheme.
169166 * <p>
170167 * <b>This method is protected only for testing</b>
171168 */
172- protected InternalDriver createRoutingDriver ( BoltServerAddress address , ConnectionPool connectionPool ,
173- Config config , RoutingSettings routingSettings , SecurityPlan securityPlan , RetryLogic retryLogic ,
174- EventExecutorGroup eventExecutorGroup )
169+ protected InternalDriver createRoutingDriver ( SecurityPlan securityPlan , BoltServerAddress address , ConnectionPool connectionPool ,
170+ EventExecutorGroup eventExecutorGroup , RoutingSettings routingSettings , RetryLogic retryLogic , Metrics metrics , Config config )
175171 {
176172 if ( !securityPlan .isRoutingCompatible () )
177173 {
@@ -180,17 +176,17 @@ protected InternalDriver createRoutingDriver( BoltServerAddress address, Connect
180176 ConnectionProvider connectionProvider = createLoadBalancer ( address , connectionPool , eventExecutorGroup ,
181177 config , routingSettings );
182178 SessionFactory sessionFactory = createSessionFactory ( connectionProvider , retryLogic , config );
183- return createDriver ( sessionFactory , securityPlan , config );
179+ return createDriver ( securityPlan , sessionFactory , metrics , config );
184180 }
185181
186182 /**
187183 * Creates new {@link Driver}.
188184 * <p>
189185 * <b>This method is protected only for testing</b>
190186 */
191- protected InternalDriver createDriver ( SessionFactory sessionFactory , SecurityPlan securityPlan , Config config )
187+ protected InternalDriver createDriver ( SecurityPlan securityPlan , SessionFactory sessionFactory , Metrics metrics , Config config )
192188 {
193- return new InternalDriver ( securityPlan , sessionFactory , config .logging () );
189+ return new InternalDriver ( securityPlan , sessionFactory , metrics , config .logging () );
194190 }
195191
196192 /**
0 commit comments