Remove implicit requestConnection() on IDLE from MultiChildLB · grpc/grpc-java@a6f8ebf

@@ -229,7 +229,7 @@ protected void updateOverallBalancingState() {

229229

@Override

230230

protected ChildLbState createChildLbState(Object key, Object policyConfig,

231231

SubchannelPicker initialPicker, ResolvedAddresses resolvedAddresses) {

232-

return new RingHashChildLbState((Endpoint)key);

232+

return new ChildLbState(key, lazyLbFactory, null, EMPTY_PICKER);

233233

}

234234235235

private Status validateAddrList(List<EquivalentAddressGroup> addrList) {

@@ -358,7 +358,7 @@ private RingHashPicker(

358358

this.ring = ring;

359359

pickableSubchannels = new HashMap<>(subchannels.size());

360360

for (Map.Entry<Object, ChildLbState> entry : subchannels.entrySet()) {

361-

RingHashChildLbState childLbState = (RingHashChildLbState) entry.getValue();

361+

ChildLbState childLbState = entry.getValue();

362362

pickableSubchannels.put((Endpoint)entry.getKey(),

363363

new SubchannelView(childLbState, childLbState.getCurrentState()));

364364

}

@@ -405,7 +405,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {

405405

for (int i = 0; i < ring.size(); i++) {

406406

int index = (targetIndex + i) % ring.size();

407407

SubchannelView subchannelView = pickableSubchannels.get(ring.get(index).addrKey);

408-

RingHashChildLbState childLbState = subchannelView.childLbState;

408+

ChildLbState childLbState = subchannelView.childLbState;

409409410410

if (subchannelView.connectivityState == READY) {

411411

return childLbState.getCurrentPicker().pickSubchannel(args);

@@ -427,7 +427,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {

427427

}

428428429429

// return the pick from the original subchannel hit by hash, which is probably an error

430-

RingHashChildLbState originalSubchannel =

430+

ChildLbState originalSubchannel =

431431

pickableSubchannels.get(ring.get(targetIndex).addrKey).childLbState;

432432

return originalSubchannel.getCurrentPicker().pickSubchannel(args);

433433

}

@@ -439,10 +439,10 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {

439439

* state changes.

440440

*/

441441

private static final class SubchannelView {

442-

private final RingHashChildLbState childLbState;

442+

private final ChildLbState childLbState;

443443

private final ConnectivityState connectivityState;

444444445-

private SubchannelView(RingHashChildLbState childLbState, ConnectivityState state) {

445+

private SubchannelView(ChildLbState childLbState, ConnectivityState state) {

446446

this.childLbState = childLbState;

447447

this.connectivityState = state;

448448

}

@@ -487,41 +487,4 @@ public String toString() {

487487

.toString();

488488

}

489489

}

490-491-

class RingHashChildLbState extends MultiChildLoadBalancer.ChildLbState {

492-493-

public RingHashChildLbState(Endpoint key) {

494-

super(key, lazyLbFactory, null, EMPTY_PICKER);

495-

}

496-497-

@Override

498-

protected ChildLbStateHelper createChildHelper() {

499-

return new RingHashChildHelper();

500-

}

501-502-

// Need to expose this to the LB class

503-

@Override

504-

protected void shutdown() {

505-

super.shutdown();

506-

}

507-508-

private class RingHashChildHelper extends ChildLbStateHelper {

509-

@Override

510-

public void updateBalancingState(final ConnectivityState newState,

511-

final SubchannelPicker newPicker) {

512-

setCurrentState(newState);

513-

setCurrentPicker(newPicker);

514-515-

if (getChildLbState(getKey()) == null) {

516-

return;

517-

}

518-519-

// If we are already in the process of resolving addresses, the overall balancing state

520-

// will be updated at the end of it, and we don't need to trigger that update here.

521-

if (!resolvingAddresses) {

522-

updateOverallBalancingState();

523-

}

524-

}

525-

}

526-

}

527490

}