core: ConnectivityStateManager is always enabled

There have been no callers of disable() since commit 1c7421be7.
This commit is contained in:
Eric Anderson 2018-02-09 15:01:24 -08:00
parent 35665af72c
commit 3480a08e70
3 changed files with 2 additions and 59 deletions

View File

@ -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;

View File

@ -369,10 +369,8 @@ public final class ManagedChannelImpl extends ManagedChannel implements Instrume
lbHelper.lb.shutdown();
lbHelper = null;
subchannelPicker = null;
if (!channelStateManager.isDisabled()) {
channelStateManager.gotoState(IDLE);
}
}
// Must be run from channelExecutor
private void cancelIdleTimer() {
@ -596,10 +594,8 @@ public final class ManagedChannelImpl extends ManagedChannel implements Instrume
channelExecutor.executeLater(new Runnable() {
@Override
public void run() {
if (!channelStateManager.isDisabled()) {
channelStateManager.gotoState(SHUTDOWN);
}
}
});
uncommittedRetriableStreamsRegistry.onShutdown(SHUTDOWN_STATUS);

View File

@ -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);