From 3480a08e70a06100cc99feff646d9666aefc1f32 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Fri, 9 Feb 2018 15:01:24 -0800 Subject: [PATCH] core: ConnectivityStateManager is always enabled There have been no callers of disable() since commit 1c7421be7. --- .../internal/ConnectivityStateManager.java | 22 ------------- .../io/grpc/internal/ManagedChannelImpl.java | 8 ++--- .../ConnectivityStateManagerTest.java | 31 ------------------- 3 files changed, 2 insertions(+), 59 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/ConnectivityStateManager.java b/core/src/main/java/io/grpc/internal/ConnectivityStateManager.java index 58afaff1bf..971d4dd74a 100644 --- a/core/src/main/java/io/grpc/internal/ConnectivityStateManager.java +++ b/core/src/main/java/io/grpc/internal/ConnectivityStateManager.java @@ -17,14 +17,12 @@ package io.grpc.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import io.grpc.ConnectivityState; import io.grpc.ManagedChannel; import java.util.ArrayList; import java.util.concurrent.Executor; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; /** @@ -63,11 +61,6 @@ final class ConnectivityStateManager { */ void gotoState(@Nonnull ConnectivityState newState) { checkNotNull(newState, "newState"); - checkState(!isDisabled(), "ConnectivityStateManager is already disabled"); - gotoNullableState(newState); - } - - private void gotoNullableState(@Nullable ConnectivityState newState) { if (state != newState && state != ConnectivityState.SHUTDOWN) { state = newState; if (listeners.isEmpty()) { @@ -94,21 +87,6 @@ final class ConnectivityStateManager { return stateCopy; } - /** - * Call this method when the channel learns from the load balancer that channel state API is not - * supported. - */ - void disable() { - gotoNullableState(null); - } - - /** - * This method is threadsafe. - */ - boolean isDisabled() { - return state == null; - } - private static final class Listener { final Runnable callback; final Executor executor; diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java index 3d3bdf3c63..d4053cd291 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java @@ -369,9 +369,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements Instrume lbHelper.lb.shutdown(); lbHelper = null; subchannelPicker = null; - if (!channelStateManager.isDisabled()) { - channelStateManager.gotoState(IDLE); - } + channelStateManager.gotoState(IDLE); } // Must be run from channelExecutor @@ -596,9 +594,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements Instrume channelExecutor.executeLater(new Runnable() { @Override public void run() { - if (!channelStateManager.isDisabled()) { - channelStateManager.gotoState(SHUTDOWN); - } + channelStateManager.gotoState(SHUTDOWN); } }); diff --git a/core/src/test/java/io/grpc/internal/ConnectivityStateManagerTest.java b/core/src/test/java/io/grpc/internal/ConnectivityStateManagerTest.java index 7bab9842cd..42c58b345f 100644 --- a/core/src/test/java/io/grpc/internal/ConnectivityStateManagerTest.java +++ b/core/src/test/java/io/grpc/internal/ConnectivityStateManagerTest.java @@ -22,7 +22,6 @@ import static io.grpc.ConnectivityState.READY; import static io.grpc.ConnectivityState.SHUTDOWN; import static io.grpc.ConnectivityState.TRANSIENT_FAILURE; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import com.google.common.util.concurrent.MoreExecutors; import io.grpc.ConnectivityState; @@ -234,36 +233,6 @@ public class ConnectivityStateManagerTest { assertEquals(READY, sink.poll()); } - @Test - public void disable() { - state.disable(); - assertTrue(state.isDisabled()); - - thrown.expect(UnsupportedOperationException.class); - thrown.expectMessage("Channel state API is not implemented"); - state.getState(); - } - - @Test - public void disableThenDisable() { - state.disable(); - state.disable(); - assertTrue(state.isDisabled()); - - thrown.expect(UnsupportedOperationException.class); - thrown.expectMessage("Channel state API is not implemented"); - state.getState(); - } - - @Test - public void disableThenGotoReady() { - state.disable(); - - thrown.expect(IllegalStateException.class); - thrown.expectMessage("ConnectivityStateManager is already disabled"); - state.gotoState(READY); - } - @Test public void shutdownThenReady() { state.gotoState(SHUTDOWN);