38
38
import org .neo4j .driver .internal .cluster .loadbalancing .LoadBalancingStrategy ;
39
39
import org .neo4j .driver .internal .cluster .loadbalancing .RoundRobinLoadBalancingStrategy ;
40
40
import 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 ;
44
45
import org .neo4j .driver .internal .retry .ExponentialBackoffRetryLogic ;
45
46
import org .neo4j .driver .internal .retry .RetryLogic ;
46
47
import org .neo4j .driver .internal .retry .RetrySettings ;
59
60
import org .neo4j .driver .v1 .exceptions .ServiceUnavailableException ;
60
61
61
62
import 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 ;
64
65
import static org .neo4j .driver .internal .security .SecurityPlan .insecure ;
65
66
66
67
public class DriverFactory
@@ -82,19 +83,17 @@ public final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings r
82
83
EventExecutorGroup eventExecutorGroup = bootstrap .config ().group ();
83
84
RetryLogic retryLogic = createRetryLogic ( retrySettings , eventExecutorGroup , config .logging () );
84
85
85
- InternalAbstractDriverMetrics metrics = createDriverMetrics ( config );
86
+ InternalAbstractMetrics metrics = createDriverMetrics ( config );
86
87
ConnectionPool connectionPool = createConnectionPool ( authToken , securityPlan , bootstrap , metrics , config );
87
88
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 );
90
90
91
- driver .driverMetrics ( metrics );
92
91
verifyConnectivity ( driver , connectionPool , config );
93
92
94
93
return driver ;
95
94
}
96
95
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 )
98
97
{
99
98
Clock clock = createClock ();
100
99
ConnectionSettings settings = new ConnectionSettings ( authToken , config .connectionTimeoutMillis () );
@@ -106,11 +105,11 @@ protected ConnectionPool createConnectionPool( AuthToken authToken, SecurityPlan
106
105
return new ConnectionPoolImpl ( connector , bootstrap , poolSettings , metrics , config .logging (), clock );
107
106
}
108
107
109
- protected static InternalAbstractDriverMetrics createDriverMetrics ( Config config )
108
+ protected static InternalAbstractMetrics createDriverMetrics ( Config config )
110
109
{
111
- if ( isDriverMetricsEnabled () )
110
+ if ( isMetricsEnabled () )
112
111
{
113
- return new InternalDriverMetrics ( config );
112
+ return new InternalMetrics ( config );
114
113
}
115
114
else
116
115
{
@@ -124,9 +123,8 @@ protected ChannelConnector createConnector( ConnectionSettings settings, Securit
124
123
return new ChannelConnectorImpl ( settings , securityPlan , config .logging (), clock );
125
124
}
126
125
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 )
130
128
{
131
129
try
132
130
{
@@ -135,10 +133,9 @@ private InternalDriver createDriver( URI uri, BoltServerAddress address,
135
133
{
136
134
case BOLT_URI_SCHEME :
137
135
assertNoRoutingContext ( uri , routingSettings );
138
- return createDirectDriver ( address , config , securityPlan , retryLogic , connectionPool );
136
+ return createDirectDriver ( securityPlan , address , connectionPool , retryLogic , metrics , config );
139
137
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 );
142
139
default :
143
140
throw new ClientException ( format ( "Unsupported URI scheme: %s" , scheme ) );
144
141
}
@@ -156,22 +153,21 @@ private InternalDriver createDriver( URI uri, BoltServerAddress address,
156
153
* <p>
157
154
* <b>This method is protected only for testing</b>
158
155
*/
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 )
161
158
{
162
159
ConnectionProvider connectionProvider = new DirectConnectionProvider ( address , connectionPool );
163
160
SessionFactory sessionFactory = createSessionFactory ( connectionProvider , retryLogic , config );
164
- return createDriver ( sessionFactory , securityPlan , config );
161
+ return createDriver ( securityPlan , sessionFactory , metrics , config );
165
162
}
166
163
167
164
/**
168
165
* Creates new a new driver for "bolt+routing" scheme.
169
166
* <p>
170
167
* <b>This method is protected only for testing</b>
171
168
*/
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 )
175
171
{
176
172
if ( !securityPlan .isRoutingCompatible () )
177
173
{
@@ -180,17 +176,17 @@ protected InternalDriver createRoutingDriver( BoltServerAddress address, Connect
180
176
ConnectionProvider connectionProvider = createLoadBalancer ( address , connectionPool , eventExecutorGroup ,
181
177
config , routingSettings );
182
178
SessionFactory sessionFactory = createSessionFactory ( connectionProvider , retryLogic , config );
183
- return createDriver ( sessionFactory , securityPlan , config );
179
+ return createDriver ( securityPlan , sessionFactory , metrics , config );
184
180
}
185
181
186
182
/**
187
183
* Creates new {@link Driver}.
188
184
* <p>
189
185
* <b>This method is protected only for testing</b>
190
186
*/
191
- protected InternalDriver createDriver ( SessionFactory sessionFactory , SecurityPlan securityPlan , Config config )
187
+ protected InternalDriver createDriver ( SecurityPlan securityPlan , SessionFactory sessionFactory , Metrics metrics , Config config )
192
188
{
193
- return new InternalDriver ( securityPlan , sessionFactory , config .logging () );
189
+ return new InternalDriver ( securityPlan , sessionFactory , metrics , config .logging () );
194
190
}
195
191
196
192
/**
0 commit comments