Skip to content

Commit d2fcb14

Browse files
committed
1
1 parent be5f5f8 commit d2fcb14

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/control/ControlConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ private void init(
300300
.withOwnerLogPrefix(logPrefix + "|control")
301301
.build();
302302

303-
Queue<Node> nodes = context.getLoadBalancingPolicyWrapper().newQueryPlan();
303+
Queue<Node> nodes =
304+
context.getLoadBalancingPolicyWrapper().newControlReconnectionQueryPlan();
304305

305306
connect(
306307
nodes,

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/LoadBalancingPolicyWrapper.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ public Queue<Node> newQueryPlan(
161161
}
162162
}
163163

164-
@NonNull
165-
public Queue<Node> newQueryPlan() {
166-
return newQueryPlan(null, DriverExecutionProfile.DEFAULT_NAME, null);
167-
}
168-
169164
@NonNull
170165
public Queue<Node> newControlReconnectionQueryPlan() {
171166
// First try the original way

core/src/test/java/com/datastax/oss/driver/internal/core/control/ControlConnectionTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void setup() {
141141
}
142142

143143
protected void mockQueryPlan(Node... nodes) {
144-
when(loadBalancingPolicyWrapper.newQueryPlan())
144+
when(loadBalancingPolicyWrapper.newControlReconnectionQueryPlan())
145145
.thenAnswer(
146146
i -> {
147147
ConcurrentLinkedQueue<Node> queryPlan = new ConcurrentLinkedQueue<>();

core/src/test/java/com/datastax/oss/driver/internal/core/metadata/LoadBalancingPolicyWrapperTest.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,22 @@ public void setup() {
118118
policy3));
119119
}
120120

121+
@Test
122+
public void should_build_control_connection_query_plan_from_contact_points_before_init() {
123+
// When
124+
Queue<Node> queryPlan = wrapper.newControlReconnectionQueryPlan();
125+
126+
// Then
127+
for (LoadBalancingPolicy policy : ImmutableList.of(policy1, policy2, policy3)) {
128+
verify(policy, never()).newQueryPlan(null, null);
129+
}
130+
assertThat(queryPlan).hasSameElementsAs(contactPoints);
131+
}
132+
121133
@Test
122134
public void should_build_query_plan_from_contact_points_before_init() {
123135
// When
124-
Queue<Node> queryPlan = wrapper.newQueryPlan();
136+
Queue<Node> queryPlan = wrapper.newQueryPlan(null, DriverExecutionProfile.DEFAULT_NAME, null);
125137

126138
// Then
127139
for (LoadBalancingPolicy policy : ImmutableList.of(policy1, policy2, policy3)) {
@@ -139,7 +151,24 @@ public void should_fetch_query_plan_from_policy_after_init() {
139151
}
140152

141153
// When
142-
Queue<Node> queryPlan = wrapper.newQueryPlan();
154+
Queue<Node> queryPlan = wrapper.newControlReconnectionQueryPlan();
155+
156+
// Then
157+
// no-arg newQueryPlan() uses the default profile
158+
verify(policy1).newQueryPlan(null, null);
159+
assertThat(queryPlan).isEqualTo(defaultPolicyQueryPlan);
160+
}
161+
162+
@Test
163+
public void should_fetch_control_connection_query_plan_from_policy_after_init() {
164+
// Given
165+
wrapper.init();
166+
for (LoadBalancingPolicy policy : ImmutableList.of(policy1, policy2, policy3)) {
167+
verify(policy).init(anyMap(), any(DistanceReporter.class));
168+
}
169+
170+
// When
171+
Queue<Node> queryPlan = wrapper.newQueryPlan(null, DriverExecutionProfile.DEFAULT_NAME, null);
143172

144173
// Then
145174
// no-arg newQueryPlan() uses the default profile

0 commit comments

Comments
 (0)