Skip to content

Commit

Permalink
api: delete LoadBalancer.Helper APIs that had been deprecated for a l…
Browse files Browse the repository at this point in the history
…ong time (grpc#7793)
  • Loading branch information
voidzcy authored and dfawley committed Jan 15, 2021
1 parent 0b4cf33 commit b6dbe3e
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 390 deletions.
100 changes: 0 additions & 100 deletions api/src/main/java/io/grpc/LoadBalancer.java
Expand Up @@ -904,45 +904,6 @@ public String toString() {
@ThreadSafe
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
public abstract static class Helper {
/**
* Equivalent to {@link #createSubchannel(List, Attributes)} with the given single {@code
* EquivalentAddressGroup}.
*
* @since 1.2.0
* @deprecated Use {@link #createSubchannel(io.grpc.LoadBalancer.CreateSubchannelArgs)}
* instead. Note the new API must be called from {@link #getSynchronizationContext
* the Synchronization Context}.
*/
@Deprecated
public final Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs) {
checkNotNull(addrs, "addrs");
return createSubchannel(Collections.singletonList(addrs), attrs);
}

/**
* Creates a Subchannel, which is a logical connection to the given group of addresses which are
* considered equivalent. The {@code attrs} are custom attributes associated with this
* Subchannel, and can be accessed later through {@link Subchannel#getAttributes
* Subchannel.getAttributes()}.
*
* <p>It is recommended you call this method from the Synchronization Context, otherwise your
* logic around the creation may race with {@link #handleSubchannelState}. See
* <a href="https://github.com/grpc/grpc-java/issues/5015">#5015</a> for more discussions.
*
* <p>The LoadBalancer is responsible for closing unused Subchannels, and closing all
* Subchannels within {@link #shutdown}.
*
* @throws IllegalArgumentException if {@code addrs} is empty
* @since 1.14.0
* @deprecated Use {@link #createSubchannel(io.grpc.LoadBalancer.CreateSubchannelArgs)}
* instead. Note the new API must be called from {@link #getSynchronizationContext
* the Synchronization Context}.
*/
@Deprecated
public Subchannel createSubchannel(List<EquivalentAddressGroup> addrs, Attributes attrs) {
throw new UnsupportedOperationException();
}

/**
* Creates a Subchannel, which is a logical connection to the given group of addresses which are
* considered equivalent. The {@code attrs} are custom attributes associated with this
Expand All @@ -960,44 +921,6 @@ public Subchannel createSubchannel(CreateSubchannelArgs args) {
throw new UnsupportedOperationException();
}

/**
* Equivalent to {@link #updateSubchannelAddresses(io.grpc.LoadBalancer.Subchannel, List)} with
* the given single {@code EquivalentAddressGroup}.
*
* <p>It should be called from the Synchronization Context. Currently will log a warning if
* violated. It will become an exception eventually. See <a
* href="https://github.com/grpc/grpc-java/issues/5015">#5015</a> for the background.
*
* @since 1.4.0
* @deprecated use {@link Subchannel#updateAddresses} instead
*/
@Deprecated
public final void updateSubchannelAddresses(
Subchannel subchannel, EquivalentAddressGroup addrs) {
checkNotNull(addrs, "addrs");
updateSubchannelAddresses(subchannel, Collections.singletonList(addrs));
}

/**
* Replaces the existing addresses used with {@code subchannel}. This method is superior to
* {@link #createSubchannel} when the new and old addresses overlap, since the subchannel can
* continue using an existing connection.
*
* <p>It should be called from the Synchronization Context. Currently will log a warning if
* violated. It will become an exception eventually. See <a
* href="https://github.com/grpc/grpc-java/issues/5015">#5015</a> for the background.
*
* @throws IllegalArgumentException if {@code subchannel} was not returned from {@link
* #createSubchannel} or {@code addrs} is empty
* @since 1.14.0
* @deprecated use {@link Subchannel#updateAddresses} instead
*/
@Deprecated
public void updateSubchannelAddresses(
Subchannel subchannel, List<EquivalentAddressGroup> addrs) {
throw new UnsupportedOperationException();
}

/**
* Out-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external
* load-balancer service.
Expand Down Expand Up @@ -1115,18 +1038,6 @@ public void refreshNameResolution() {
throw new UnsupportedOperationException();
}

/**
* Schedule a task to be run in the Synchronization Context, which serializes the task with the
* callback methods on the {@link LoadBalancer} interface.
*
* @since 1.2.0
* @deprecated use/implement {@code getSynchronizationContext()} instead
*/
@Deprecated
public void runSerialized(Runnable task) {
getSynchronizationContext().execute(task);
}

/**
* Returns a {@link SynchronizationContext} that runs tasks in the same Synchronization Context
* as that the callback methods on the {@link LoadBalancer} interface are run in.
Expand Down Expand Up @@ -1157,17 +1068,6 @@ public ScheduledExecutorService getScheduledExecutorService() {
throw new UnsupportedOperationException();
}

/**
* Returns the NameResolver of the channel.
*
* @since 1.2.0
*
* @deprecated this method will be deleted in a future release. If you think it shouldn't be
* deleted, please file an issue on <a href="https://github.com/grpc/grpc-java">github</a>.
*/
@Deprecated
public abstract NameResolver.Factory getNameResolverFactory();

/**
* Returns the authority string of the channel, which is derived from the DNS-style target name.
* If overridden by a load balancer, {@link #getUnsafeChannelCredentials} must also be
Expand Down
66 changes: 0 additions & 66 deletions api/src/test/java/io/grpc/LoadBalancerTest.java
Expand Up @@ -45,7 +45,6 @@ public class LoadBalancerTest {
private final Attributes attrs = Attributes.newBuilder()
.set(Attributes.Key.create("trash"), new Object())
.build();
private final Subchannel emptySubchannel = new EmptySubchannel();

@Test
public void pickResult_withSubchannel() {
Expand Down Expand Up @@ -123,38 +122,6 @@ public void pickResult_equals() {
assertThat(error1).isNotEqualTo(drop1);
}

@Deprecated
@Test
public void helper_createSubchannel_old_delegates() {
class OverrideCreateSubchannel extends NoopHelper {
boolean ran;

@Override
public Subchannel createSubchannel(List<EquivalentAddressGroup> addrsIn, Attributes attrsIn) {
assertThat(addrsIn).hasSize(1);
assertThat(addrsIn.get(0)).isSameInstanceAs(eag);
assertThat(attrsIn).isSameInstanceAs(attrs);
ran = true;
return subchannel;
}
}

OverrideCreateSubchannel helper = new OverrideCreateSubchannel();
assertThat(helper.createSubchannel(eag, attrs)).isSameInstanceAs(subchannel);
assertThat(helper.ran).isTrue();
}

@Test
@SuppressWarnings("deprecation")
public void helper_createSubchannelList_oldApi_throws() {
try {
new NoopHelper().createSubchannel(Arrays.asList(eag), attrs);
fail("Should throw");
} catch (UnsupportedOperationException e) {
// expected
}
}

@Test
public void helper_createSubchannelList_throws() {
try {
Expand All @@ -168,33 +135,6 @@ public void helper_createSubchannelList_throws() {
}
}

@Deprecated
@Test
public void helper_updateSubchannelAddresses_delegates() {
class OverrideUpdateSubchannel extends NoopHelper {
boolean ran;

@Override
public void updateSubchannelAddresses(
Subchannel subchannelIn, List<EquivalentAddressGroup> addrsIn) {
assertThat(subchannelIn).isSameInstanceAs(emptySubchannel);
assertThat(addrsIn).hasSize(1);
assertThat(addrsIn.get(0)).isSameInstanceAs(eag);
ran = true;
}
}

OverrideUpdateSubchannel helper = new OverrideUpdateSubchannel();
helper.updateSubchannelAddresses(emptySubchannel, eag);
assertThat(helper.ran).isTrue();
}

@Deprecated
@Test(expected = UnsupportedOperationException.class)
public void helper_updateSubchannelAddressesList_throws() {
new NoopHelper().updateSubchannelAddresses(null, Arrays.asList(eag));
}

@Test
public void subchannel_getAddresses_delegates() {
class OverrideGetAllAddresses extends EmptySubchannel {
Expand Down Expand Up @@ -410,12 +350,6 @@ public void updateBalancingState(
return null;
}

@Deprecated
@Override
public NameResolver.Factory getNameResolverFactory() {
return null;
}

@Override public String getAuthority() {
return null;
}
Expand Down
46 changes: 0 additions & 46 deletions core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
Expand Up @@ -1388,36 +1388,6 @@ void remove(RetriableStream<?> retriableStream) {
private class LbHelperImpl extends LoadBalancer.Helper {
AutoConfiguredLoadBalancer lb;

@Deprecated
@Override
public AbstractSubchannel createSubchannel(
List<EquivalentAddressGroup> addressGroups, Attributes attrs) {
logWarningIfNotInSyncContext("createSubchannel()");
// TODO(ejona): can we be even stricter? Like loadBalancer == null?
checkNotNull(addressGroups, "addressGroups");
checkNotNull(attrs, "attrs");
final SubchannelImpl subchannel = createSubchannelInternal(
CreateSubchannelArgs.newBuilder()
.setAddresses(addressGroups)
.setAttributes(attrs)
.build());

final SubchannelStateListener listener =
new LoadBalancer.SubchannelStateListener() {
@Override
public void onSubchannelState(ConnectivityStateInfo newState) {
// Call LB only if it's not shutdown. If LB is shutdown, lbHelper won't match.
if (LbHelperImpl.this != ManagedChannelImpl.this.lbHelper) {
return;
}
lb.handleSubchannelState(subchannel, newState);
}
};

subchannel.internalStart(listener);
return subchannel;
}

@Override
public AbstractSubchannel createSubchannel(CreateSubchannelArgs args) {
syncContext.throwIfNotInThisSynchronizationContext();
Expand Down Expand Up @@ -1469,16 +1439,6 @@ public void run() {
syncContext.execute(new LoadBalancerRefreshNameResolution());
}

@Deprecated
@Override
public void updateSubchannelAddresses(
LoadBalancer.Subchannel subchannel, List<EquivalentAddressGroup> addrs) {
checkArgument(subchannel instanceof SubchannelImpl,
"subchannel must have been returned from createSubchannel");
logWarningIfNotInSyncContext("updateSubchannelAddresses()");
((InternalSubchannel) subchannel.getInternalSubchannel()).updateAddresses(addrs);
}

@Override
public ManagedChannel createOobChannel(EquivalentAddressGroup addressGroup, String authority) {
// TODO(ejona): can we be even stricter? Like terminating?
Expand Down Expand Up @@ -1616,12 +1576,6 @@ public String getAuthority() {
return ManagedChannelImpl.this.authority();
}

@Deprecated
@Override
public NameResolver.Factory getNameResolverFactory() {
return nameResolverFactory;
}

@Override
public SynchronizationContext getSynchronizationContext() {
return syncContext;
Expand Down
27 changes: 0 additions & 27 deletions core/src/main/java/io/grpc/util/ForwardingLoadBalancerHelper.java
Expand Up @@ -17,7 +17,6 @@
package io.grpc.util;

import com.google.common.base.MoreObjects;
import io.grpc.Attributes;
import io.grpc.ChannelCredentials;
import io.grpc.ChannelLogger;
import io.grpc.ConnectivityState;
Expand All @@ -32,7 +31,6 @@
import io.grpc.NameResolver;
import io.grpc.NameResolverRegistry;
import io.grpc.SynchronizationContext;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;

@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
Expand All @@ -42,24 +40,11 @@ public abstract class ForwardingLoadBalancerHelper extends LoadBalancer.Helper {
*/
protected abstract LoadBalancer.Helper delegate();

@Deprecated
@Override
public Subchannel createSubchannel(List<EquivalentAddressGroup> addrs, Attributes attrs) {
return delegate().createSubchannel(addrs, attrs);
}

@Override
public Subchannel createSubchannel(CreateSubchannelArgs args) {
return delegate().createSubchannel(args);
}

@Deprecated
@Override
public void updateSubchannelAddresses(
Subchannel subchannel, List<EquivalentAddressGroup> addrs) {
delegate().updateSubchannelAddresses(subchannel, addrs);
}

@Override
public ManagedChannel createOobChannel(EquivalentAddressGroup eag, String authority) {
return delegate().createOobChannel(eag, authority);
Expand Down Expand Up @@ -97,18 +82,6 @@ public void refreshNameResolution() {
delegate().refreshNameResolution();
}

@Override
@Deprecated
public void runSerialized(Runnable task) {
delegate().runSerialized(task);
}

@Deprecated
@Override
public NameResolver.Factory getNameResolverFactory() {
return delegate().getNameResolverFactory();
}

@Override
public String getAuthority() {
return delegate().getAuthority();
Expand Down

0 comments on commit b6dbe3e

Please sign in to comment.