package io.grpc.internal; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import com.google.common.base.Supplier; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import io.grpc.Attributes; import io.grpc.CallOptions; import io.grpc.ChannelLogger; import io.grpc.ClientStreamTracer; import io.grpc.ConnectivityState; import io.grpc.ConnectivityStateInfo; import io.grpc.EquivalentAddressGroup; import io.grpc.HttpConnectProxiedSocketAddress; import io.grpc.InternalChannelz; import io.grpc.InternalInstrumented; import io.grpc.InternalLogId; import io.grpc.Metadata; import io.grpc.MethodDescriptor; import io.grpc.Status; import io.grpc.SynchronizationContext; import io.grpc.internal.BackoffPolicy; import io.grpc.internal.ClientStreamListener; import io.grpc.internal.ClientTransportFactory; import io.grpc.internal.ManagedClientTransport; import java.net.SocketAddress; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public final class InternalSubchannel implements InternalInstrumented, TransportProvider { private volatile ManagedClientTransport activeTransport; private volatile List addressGroups; private final Index addressIndex; private final String authority; private final BackoffPolicy.Provider backoffPolicyProvider; private final Callback callback; private final CallTracer callsTracer; private final ChannelLogger channelLogger; private final ChannelTracer channelTracer; private final InternalChannelz channelz; private final Stopwatch connectingTimer; private final InternalLogId logId; private ConnectionClientTransport pendingTransport; private BackoffPolicy reconnectPolicy; private SynchronizationContext.ScheduledHandle reconnectTask; private final ScheduledExecutorService scheduledExecutor; private SynchronizationContext.ScheduledHandle shutdownDueToUpdateTask; private ManagedClientTransport shutdownDueToUpdateTransport; private Status shutdownReason; private final SynchronizationContext syncContext; private final ClientTransportFactory transportFactory; private final String userAgent; private final Collection transports = new ArrayList(); private final InUseStateAggregator inUseStateAggregator = new InUseStateAggregator(this) { // from class: io.grpc.internal.InternalSubchannel.1 final InternalSubchannel this$0; { this.this$0 = this; } @Override // io.grpc.internal.InUseStateAggregator protected void handleInUse() { this.this$0.callback.onInUse(this.this$0); } @Override // io.grpc.internal.InUseStateAggregator protected void handleNotInUse() { this.this$0.callback.onNotInUse(this.this$0); } }; private volatile ConnectivityStateInfo state = ConnectivityStateInfo.forNonError(ConnectivityState.IDLE); /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static abstract class Callback { void onInUse(InternalSubchannel internalSubchannel) { } void onNotInUse(InternalSubchannel internalSubchannel) { } void onStateChange(InternalSubchannel internalSubchannel, ConnectivityStateInfo connectivityStateInfo) { } void onTerminated(InternalSubchannel internalSubchannel) { } } /* JADX INFO: Access modifiers changed from: package-private */ public InternalSubchannel(List list, String str, String str2, BackoffPolicy.Provider provider, ClientTransportFactory clientTransportFactory, ScheduledExecutorService scheduledExecutorService, Supplier supplier, SynchronizationContext synchronizationContext, Callback callback, InternalChannelz internalChannelz, CallTracer callTracer, ChannelTracer channelTracer, InternalLogId internalLogId, ChannelLogger channelLogger) { Preconditions.checkNotNull(list, "addressGroups"); Preconditions.checkArgument(!list.isEmpty(), "addressGroups is empty"); checkListHasNoNulls(list, "addressGroups contains null entry"); List unmodifiableList = Collections.unmodifiableList(new ArrayList(list)); this.addressGroups = unmodifiableList; this.addressIndex = new Index(unmodifiableList); this.authority = str; this.userAgent = str2; this.backoffPolicyProvider = provider; this.transportFactory = clientTransportFactory; this.scheduledExecutor = scheduledExecutorService; this.connectingTimer = supplier.get(); this.syncContext = synchronizationContext; this.callback = callback; this.channelz = internalChannelz; this.callsTracer = callTracer; this.channelTracer = (ChannelTracer) Preconditions.checkNotNull(channelTracer, "channelTracer"); this.logId = (InternalLogId) Preconditions.checkNotNull(internalLogId, "logId"); this.channelLogger = (ChannelLogger) Preconditions.checkNotNull(channelLogger, "channelLogger"); } @Override // io.grpc.internal.TransportProvider public final ClientTransport obtainActiveTransport() { ManagedClientTransport managedClientTransport = this.activeTransport; if (managedClientTransport != null) { return managedClientTransport; } this.syncContext.execute(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.2 final InternalSubchannel this$0; { this.this$0 = this; } @Override // java.lang.Runnable public void run() { if (this.this$0.state.getState() == ConnectivityState.IDLE) { this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "CONNECTING as requested"); this.this$0.gotoNonErrorState(ConnectivityState.CONNECTING); this.this$0.startNewTransport(); } } }); return null; } /* JADX INFO: Access modifiers changed from: private */ public void startNewTransport() { HttpConnectProxiedSocketAddress httpConnectProxiedSocketAddress; this.syncContext.throwIfNotInThisSynchronizationContext(); Preconditions.checkState(this.reconnectTask == null, "Should have no reconnectTask scheduled"); if (this.addressIndex.isAtBeginning()) { this.connectingTimer.reset().start(); } SocketAddress currentAddress = this.addressIndex.getCurrentAddress(); if (currentAddress instanceof HttpConnectProxiedSocketAddress) { HttpConnectProxiedSocketAddress httpConnectProxiedSocketAddress2 = (HttpConnectProxiedSocketAddress) currentAddress; httpConnectProxiedSocketAddress = httpConnectProxiedSocketAddress2; currentAddress = httpConnectProxiedSocketAddress2.getTargetAddress(); } else { httpConnectProxiedSocketAddress = null; } Attributes currentEagAttributes = this.addressIndex.getCurrentEagAttributes(); String str = (String) currentEagAttributes.get(EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE); ClientTransportFactory.ClientTransportOptions clientTransportOptions = new ClientTransportFactory.ClientTransportOptions(); if (str == null) { str = this.authority; } ClientTransportFactory.ClientTransportOptions httpConnectProxiedSocketAddress3 = clientTransportOptions.setAuthority(str).setEagAttributes(currentEagAttributes).setUserAgent(this.userAgent).setHttpConnectProxiedSocketAddress(httpConnectProxiedSocketAddress); TransportLogger transportLogger = new TransportLogger(); transportLogger.logId = getLogId(); CallTracingTransport callTracingTransport = new CallTracingTransport(this.transportFactory.newClientTransport(currentAddress, httpConnectProxiedSocketAddress3, transportLogger), this.callsTracer); transportLogger.logId = callTracingTransport.getLogId(); this.channelz.addClientSocket(callTracingTransport); this.pendingTransport = callTracingTransport; this.transports.add(callTracingTransport); Runnable start = callTracingTransport.start(new TransportListener(this, callTracingTransport, currentAddress)); if (start != null) { this.syncContext.executeLater(start); } this.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "Started transport {0}", transportLogger.logId); } /* JADX INFO: Access modifiers changed from: private */ public void scheduleBackoff(Status status) { this.syncContext.throwIfNotInThisSynchronizationContext(); gotoState(ConnectivityStateInfo.forTransientFailure(status)); if (this.reconnectPolicy == null) { this.reconnectPolicy = this.backoffPolicyProvider.get(); } long nextBackoffNanos = this.reconnectPolicy.nextBackoffNanos() - this.connectingTimer.elapsed(TimeUnit.NANOSECONDS); this.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "TRANSIENT_FAILURE ({0}). Will reconnect after {1} ns", printShortStatus(status), Long.valueOf(nextBackoffNanos)); Preconditions.checkState(this.reconnectTask == null, "previous reconnectTask is not done"); this.reconnectTask = this.syncContext.schedule(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.1EndOfCurrentBackoff final InternalSubchannel this$0; { this.this$0 = this; } @Override // java.lang.Runnable public void run() { this.this$0.reconnectTask = null; this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "CONNECTING after backoff"); this.this$0.gotoNonErrorState(ConnectivityState.CONNECTING); this.this$0.startNewTransport(); } }, nextBackoffNanos, TimeUnit.NANOSECONDS, this.scheduledExecutor); } /* JADX INFO: Access modifiers changed from: package-private */ public final void resetConnectBackoff() { this.syncContext.execute(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.3 final InternalSubchannel this$0; { this.this$0 = this; } @Override // java.lang.Runnable public void run() { if (this.this$0.state.getState() != ConnectivityState.TRANSIENT_FAILURE) { return; } this.this$0.cancelReconnectTask(); this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "CONNECTING; backoff interrupted"); this.this$0.gotoNonErrorState(ConnectivityState.CONNECTING); this.this$0.startNewTransport(); } }); } /* JADX INFO: Access modifiers changed from: private */ public void gotoNonErrorState(ConnectivityState connectivityState) { this.syncContext.throwIfNotInThisSynchronizationContext(); gotoState(ConnectivityStateInfo.forNonError(connectivityState)); } private void gotoState(ConnectivityStateInfo connectivityStateInfo) { this.syncContext.throwIfNotInThisSynchronizationContext(); if (this.state.getState() != connectivityStateInfo.getState()) { Preconditions.checkState(this.state.getState() != ConnectivityState.SHUTDOWN, "Cannot transition out of SHUTDOWN to ".concat(String.valueOf(connectivityStateInfo))); this.state = connectivityStateInfo; this.callback.onStateChange(this, connectivityStateInfo); } } public final void updateAddresses(List list) { Preconditions.checkNotNull(list, "newAddressGroups"); checkListHasNoNulls(list, "newAddressGroups contains null entry"); Preconditions.checkArgument(!list.isEmpty(), "newAddressGroups is empty"); this.syncContext.execute(new AnonymousClass4(this, Collections.unmodifiableList(new ArrayList(list)))); } /* renamed from: io.grpc.internal.InternalSubchannel$4, reason: invalid class name */ /* loaded from: classes6.dex */ class AnonymousClass4 implements Runnable { final InternalSubchannel this$0; final List val$newImmutableAddressGroups; AnonymousClass4(InternalSubchannel internalSubchannel, List list) { this.this$0 = internalSubchannel; this.val$newImmutableAddressGroups = list; } /* JADX WARN: Removed duplicated region for block: B:13:? A[RETURN, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:7:0x0096 */ @Override // java.lang.Runnable /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public void run() { /* r7 = this; io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.InternalSubchannel$Index r0 = io.grpc.internal.InternalSubchannel.access$800(r0) java.net.SocketAddress r0 = r0.getCurrentAddress() io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel$Index r1 = io.grpc.internal.InternalSubchannel.access$800(r1) java.util.List r2 = r7.val$newImmutableAddressGroups r1.updateGroups(r2) io.grpc.internal.InternalSubchannel r1 = r7.this$0 java.util.List r2 = r7.val$newImmutableAddressGroups io.grpc.internal.InternalSubchannel.access$902(r1, r2) io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.ConnectivityStateInfo r1 = io.grpc.internal.InternalSubchannel.access$100(r1) io.grpc.ConnectivityState r1 = r1.getState() io.grpc.ConnectivityState r2 = io.grpc.ConnectivityState.READY r3 = 0 if (r1 == r2) goto L39 io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.ConnectivityStateInfo r1 = io.grpc.internal.InternalSubchannel.access$100(r1) io.grpc.ConnectivityState r1 = r1.getState() io.grpc.ConnectivityState r2 = io.grpc.ConnectivityState.CONNECTING if (r1 != r2) goto L93 L39: io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel$Index r1 = io.grpc.internal.InternalSubchannel.access$800(r1) boolean r0 = r1.seekTo(r0) if (r0 != 0) goto L93 io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.ConnectivityStateInfo r0 = io.grpc.internal.InternalSubchannel.access$100(r0) io.grpc.ConnectivityState r0 = r0.getState() io.grpc.ConnectivityState r1 = io.grpc.ConnectivityState.READY if (r0 != r1) goto L6f io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.ManagedClientTransport r0 = io.grpc.internal.InternalSubchannel.access$1000(r0) io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel.access$1002(r1, r3) io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel$Index r1 = io.grpc.internal.InternalSubchannel.access$800(r1) r1.reset() io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.ConnectivityState r2 = io.grpc.ConnectivityState.IDLE io.grpc.internal.InternalSubchannel.access$300(r1, r2) goto L94 L6f: io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.ConnectionClientTransport r0 = io.grpc.internal.InternalSubchannel.access$1100(r0) io.grpc.Status r1 = io.grpc.Status.UNAVAILABLE java.lang.String r2 = "InternalSubchannel closed pending transport due to address change" io.grpc.Status r1 = r1.withDescription(r2) r0.shutdown(r1) io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.InternalSubchannel.access$1102(r0, r3) io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.InternalSubchannel$Index r0 = io.grpc.internal.InternalSubchannel.access$800(r0) r0.reset() io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.internal.InternalSubchannel.access$400(r0) L93: r0 = r3 L94: if (r0 == 0) goto Le3 io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.SynchronizationContext$ScheduledHandle r1 = io.grpc.internal.InternalSubchannel.access$1200(r1) if (r1 == 0) goto Lc2 io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.ManagedClientTransport r1 = io.grpc.internal.InternalSubchannel.access$1300(r1) io.grpc.Status r2 = io.grpc.Status.UNAVAILABLE java.lang.String r4 = "InternalSubchannel closed transport early due to address change" io.grpc.Status r2 = r2.withDescription(r4) r1.shutdown(r2) io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.SynchronizationContext$ScheduledHandle r1 = io.grpc.internal.InternalSubchannel.access$1200(r1) r1.cancel() io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel.access$1202(r1, r3) io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel.access$1302(r1, r3) Lc2: io.grpc.internal.InternalSubchannel r1 = r7.this$0 io.grpc.internal.InternalSubchannel.access$1302(r1, r0) io.grpc.internal.InternalSubchannel r0 = r7.this$0 io.grpc.SynchronizationContext r1 = io.grpc.internal.InternalSubchannel.access$1500(r0) io.grpc.internal.InternalSubchannel$4$1 r2 = new io.grpc.internal.InternalSubchannel$4$1 r2.(r7) java.util.concurrent.TimeUnit r5 = java.util.concurrent.TimeUnit.SECONDS io.grpc.internal.InternalSubchannel r3 = r7.this$0 java.util.concurrent.ScheduledExecutorService r6 = io.grpc.internal.InternalSubchannel.access$1400(r3) r3 = 5 io.grpc.SynchronizationContext$ScheduledHandle r1 = r1.schedule(r2, r3, r5, r6) io.grpc.internal.InternalSubchannel.access$1202(r0, r1) Le3: return */ throw new UnsupportedOperationException("Method not decompiled: io.grpc.internal.InternalSubchannel.AnonymousClass4.run():void"); } } public final void shutdown(Status status) { this.syncContext.execute(new Runnable(this, status) { // from class: io.grpc.internal.InternalSubchannel.5 final InternalSubchannel this$0; final Status val$reason; { this.this$0 = this; this.val$reason = status; } @Override // java.lang.Runnable public void run() { if (this.this$0.state.getState() == ConnectivityState.SHUTDOWN) { return; } this.this$0.shutdownReason = this.val$reason; ManagedClientTransport managedClientTransport = this.this$0.activeTransport; ConnectionClientTransport connectionClientTransport = this.this$0.pendingTransport; this.this$0.activeTransport = null; this.this$0.pendingTransport = null; this.this$0.gotoNonErrorState(ConnectivityState.SHUTDOWN); this.this$0.addressIndex.reset(); if (this.this$0.transports.isEmpty()) { this.this$0.handleTermination(); } this.this$0.cancelReconnectTask(); if (this.this$0.shutdownDueToUpdateTask != null) { this.this$0.shutdownDueToUpdateTask.cancel(); this.this$0.shutdownDueToUpdateTransport.shutdown(this.val$reason); this.this$0.shutdownDueToUpdateTask = null; this.this$0.shutdownDueToUpdateTransport = null; } if (managedClientTransport != null) { managedClientTransport.shutdown(this.val$reason); } if (connectionClientTransport != null) { connectionClientTransport.shutdown(this.val$reason); } } }); } public final String toString() { return MoreObjects.toStringHelper(this).add("logId", this.logId.getId()).add("addressGroups", this.addressGroups).toString(); } /* JADX INFO: Access modifiers changed from: private */ public void handleTermination() { this.syncContext.execute(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.6 final InternalSubchannel this$0; { this.this$0 = this; } @Override // java.lang.Runnable public void run() { this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "Terminated"); this.this$0.callback.onTerminated(this.this$0); } }); } /* JADX INFO: Access modifiers changed from: private */ public void handleTransportInUseState(ConnectionClientTransport connectionClientTransport, boolean z) { this.syncContext.execute(new Runnable(this, connectionClientTransport, z) { // from class: io.grpc.internal.InternalSubchannel.7 final InternalSubchannel this$0; final boolean val$inUse; final ConnectionClientTransport val$transport; { this.this$0 = this; this.val$transport = connectionClientTransport; this.val$inUse = z; } @Override // java.lang.Runnable public void run() { this.this$0.inUseStateAggregator.updateObjectInUse(this.val$transport, this.val$inUse); } }); } /* JADX INFO: Access modifiers changed from: package-private */ public final void shutdownNow(Status status) { shutdown(status); this.syncContext.execute(new Runnable(this, status) { // from class: io.grpc.internal.InternalSubchannel.8 final InternalSubchannel this$0; final Status val$reason; { this.this$0 = this; this.val$reason = status; } @Override // java.lang.Runnable public void run() { Iterator it = new ArrayList(this.this$0.transports).iterator(); while (it.hasNext()) { ((ManagedClientTransport) it.next()).shutdownNow(this.val$reason); } } }); } /* JADX INFO: Access modifiers changed from: private */ public void cancelReconnectTask() { this.syncContext.throwIfNotInThisSynchronizationContext(); SynchronizationContext.ScheduledHandle scheduledHandle = this.reconnectTask; if (scheduledHandle != null) { scheduledHandle.cancel(); this.reconnectTask = null; this.reconnectPolicy = null; } } @Override // io.grpc.InternalInstrumented public final ListenableFuture getStats() { SettableFuture create = SettableFuture.create(); this.syncContext.execute(new Runnable(this, create) { // from class: io.grpc.internal.InternalSubchannel.9 final InternalSubchannel this$0; final SettableFuture val$channelStatsFuture; { this.this$0 = this; this.val$channelStatsFuture = create; } @Override // java.lang.Runnable public void run() { InternalChannelz.ChannelStats.Builder builder = new InternalChannelz.ChannelStats.Builder(); List groups = this.this$0.addressIndex.getGroups(); ArrayList arrayList = new ArrayList(this.this$0.transports); builder.setTarget(groups.toString()).setState(this.this$0.getState()); builder.setSockets(arrayList); this.this$0.callsTracer.updateBuilder(builder); this.this$0.channelTracer.updateBuilder(builder); this.val$channelStatsFuture.set(builder.build()); } }); return create; } /* JADX INFO: Access modifiers changed from: package-private */ public final ConnectivityState getState() { return this.state.getState(); } private static void checkListHasNoNulls(List list, String str) { Iterator it = list.iterator(); while (it.hasNext()) { Preconditions.checkNotNull(it.next(), str); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public class TransportListener implements ManagedClientTransport.Listener { final SocketAddress address; boolean shutdownInitiated = false; final InternalSubchannel this$0; final ConnectionClientTransport transport; TransportListener(InternalSubchannel internalSubchannel, ConnectionClientTransport connectionClientTransport, SocketAddress socketAddress) { this.this$0 = internalSubchannel; this.transport = connectionClientTransport; this.address = socketAddress; } @Override // io.grpc.internal.ManagedClientTransport.Listener public void transportReady() { this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "READY"); this.this$0.syncContext.execute(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.TransportListener.1 final TransportListener this$1; { this.this$1 = this; } @Override // java.lang.Runnable public void run() { this.this$1.this$0.reconnectPolicy = null; if (this.this$1.this$0.shutdownReason != null) { Preconditions.checkState(this.this$1.this$0.activeTransport == null, "Unexpected non-null activeTransport"); this.this$1.transport.shutdown(this.this$1.this$0.shutdownReason); } else if (this.this$1.this$0.pendingTransport == this.this$1.transport) { this.this$1.this$0.activeTransport = this.this$1.transport; this.this$1.this$0.pendingTransport = null; this.this$1.this$0.gotoNonErrorState(ConnectivityState.READY); } } }); } @Override // io.grpc.internal.ManagedClientTransport.Listener public void transportInUse(boolean z) { this.this$0.handleTransportInUseState(this.transport, z); } @Override // io.grpc.internal.ManagedClientTransport.Listener public void transportShutdown(Status status) { this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "{0} SHUTDOWN with {1}", this.transport.getLogId(), this.this$0.printShortStatus(status)); this.shutdownInitiated = true; this.this$0.syncContext.execute(new Runnable(this, status) { // from class: io.grpc.internal.InternalSubchannel.TransportListener.2 final TransportListener this$1; final Status val$s; { this.this$1 = this; this.val$s = status; } @Override // java.lang.Runnable public void run() { if (this.this$1.this$0.state.getState() == ConnectivityState.SHUTDOWN) { return; } if (this.this$1.this$0.activeTransport == this.this$1.transport) { this.this$1.this$0.activeTransport = null; this.this$1.this$0.addressIndex.reset(); this.this$1.this$0.gotoNonErrorState(ConnectivityState.IDLE); } else if (this.this$1.this$0.pendingTransport == this.this$1.transport) { Preconditions.checkState(this.this$1.this$0.state.getState() == ConnectivityState.CONNECTING, "Expected state is CONNECTING, actual state is %s", this.this$1.this$0.state.getState()); this.this$1.this$0.addressIndex.increment(); if (!this.this$1.this$0.addressIndex.isValid()) { this.this$1.this$0.pendingTransport = null; this.this$1.this$0.addressIndex.reset(); this.this$1.this$0.scheduleBackoff(this.val$s); return; } this.this$1.this$0.startNewTransport(); } } }); } @Override // io.grpc.internal.ManagedClientTransport.Listener public void transportTerminated() { Preconditions.checkState(this.shutdownInitiated, "transportShutdown() must be called before transportTerminated()."); this.this$0.channelLogger.log(ChannelLogger.ChannelLogLevel.INFO, "{0} Terminated", this.transport.getLogId()); this.this$0.channelz.removeClientSocket(this.transport); this.this$0.handleTransportInUseState(this.transport, false); this.this$0.syncContext.execute(new Runnable(this) { // from class: io.grpc.internal.InternalSubchannel.TransportListener.3 final TransportListener this$1; { this.this$1 = this; } @Override // java.lang.Runnable public void run() { this.this$1.this$0.transports.remove(this.this$1.transport); if (this.this$1.this$0.state.getState() == ConnectivityState.SHUTDOWN && this.this$1.this$0.transports.isEmpty()) { this.this$1.this$0.handleTermination(); } } }); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class CallTracingTransport extends ForwardingConnectionClientTransport { private final CallTracer callTracer; private final ConnectionClientTransport delegate; private CallTracingTransport(ConnectionClientTransport connectionClientTransport, CallTracer callTracer) { this.delegate = connectionClientTransport; this.callTracer = callTracer; } /* renamed from: io.grpc.internal.InternalSubchannel$CallTracingTransport$1, reason: invalid class name */ /* loaded from: classes6.dex */ class AnonymousClass1 extends ForwardingClientStream { final CallTracingTransport this$0; final ClientStream val$streamDelegate; AnonymousClass1(CallTracingTransport callTracingTransport, ClientStream clientStream) { this.this$0 = callTracingTransport; this.val$streamDelegate = clientStream; } @Override // io.grpc.internal.ForwardingClientStream, io.grpc.internal.ClientStream public void start(ClientStreamListener clientStreamListener) { this.this$0.callTracer.reportCallStarted(); super.start(new ForwardingClientStreamListener(this, clientStreamListener) { // from class: io.grpc.internal.InternalSubchannel.CallTracingTransport.1.1 final AnonymousClass1 this$1; final ClientStreamListener val$listener; { this.this$1 = this; this.val$listener = clientStreamListener; } @Override // io.grpc.internal.ForwardingClientStreamListener, io.grpc.internal.ClientStreamListener public void closed(Status status, ClientStreamListener.RpcProgress rpcProgress, Metadata metadata) { this.this$1.this$0.callTracer.reportCallEnded(status.isOk()); super.closed(status, rpcProgress, metadata); } @Override // io.grpc.internal.ForwardingClientStreamListener protected ClientStreamListener delegate() { return this.val$listener; } }); } @Override // io.grpc.internal.ForwardingClientStream protected ClientStream delegate() { return this.val$streamDelegate; } } @Override // io.grpc.internal.ForwardingConnectionClientTransport, io.grpc.internal.ClientTransport public final ClientStream newStream(MethodDescriptor methodDescriptor, Metadata metadata, CallOptions callOptions, ClientStreamTracer[] clientStreamTracerArr) { return new AnonymousClass1(this, super.newStream(methodDescriptor, metadata, callOptions, clientStreamTracerArr)); } @Override // io.grpc.internal.ForwardingConnectionClientTransport protected final ConnectionClientTransport delegate() { return this.delegate; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class Index { private List addressGroups; private int addressIndex; private int groupIndex; public Index(List list) { this.addressGroups = list; } public final boolean isValid() { return this.groupIndex < this.addressGroups.size(); } public final void increment() { EquivalentAddressGroup equivalentAddressGroup = this.addressGroups.get(this.groupIndex); int i = this.addressIndex + 1; this.addressIndex = i; if (i >= equivalentAddressGroup.getAddresses().size()) { this.groupIndex++; this.addressIndex = 0; } } public final SocketAddress getCurrentAddress() { return this.addressGroups.get(this.groupIndex).getAddresses().get(this.addressIndex); } public final Attributes getCurrentEagAttributes() { return this.addressGroups.get(this.groupIndex).getAttributes(); } public final void updateGroups(List list) { this.addressGroups = list; reset(); } public final boolean seekTo(SocketAddress socketAddress) { for (int i = 0; i < this.addressGroups.size(); i++) { int indexOf = this.addressGroups.get(i).getAddresses().indexOf(socketAddress); if (indexOf != -1) { this.groupIndex = i; this.addressIndex = indexOf; return true; } } return false; } public final void reset() { this.groupIndex = 0; this.addressIndex = 0; } public final boolean isAtBeginning() { return this.groupIndex == 0 && this.addressIndex == 0; } public final List getGroups() { return this.addressGroups; } } /* JADX INFO: Access modifiers changed from: private */ public String printShortStatus(Status status) { StringBuilder sb = new StringBuilder(); sb.append(status.getCode()); if (status.getDescription() != null) { sb.append("("); sb.append(status.getDescription()); sb.append(")"); } return sb.toString(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class TransportLogger extends ChannelLogger { InternalLogId logId; TransportLogger() { } @Override // io.grpc.ChannelLogger public final void log(ChannelLogger.ChannelLogLevel channelLogLevel, String str) { ChannelLoggerImpl.logOnly(this.logId, channelLogLevel, str); } @Override // io.grpc.ChannelLogger public final void log(ChannelLogger.ChannelLogLevel channelLogLevel, String str, Object... objArr) { ChannelLoggerImpl.logOnly(this.logId, channelLogLevel, str, objArr); } } /* JADX INFO: Access modifiers changed from: package-private */ public final ClientTransport getTransport() { return this.activeTransport; } @Override // io.grpc.InternalWithLogId public final InternalLogId getLogId() { return this.logId; } final ChannelLogger getChannelLogger() { return this.channelLogger; } /* JADX INFO: Access modifiers changed from: package-private */ public final String getAuthority() { return this.authority; } /* JADX INFO: Access modifiers changed from: package-private */ public final List getAddressGroups() { return this.addressGroups; } }