Package io.grpc.internal
Class ManagedChannelOrphanWrapper
- java.lang.Object
-
- io.grpc.Channel
-
- io.grpc.ManagedChannel
-
- io.grpc.internal.ForwardingManagedChannel
-
- io.grpc.internal.ManagedChannelOrphanWrapper
-
final class ManagedChannelOrphanWrapper extends ForwardingManagedChannel
Best effort detecting channels that has not been properly cleaned up. UseWeakReferenceto avoid keeping the channel alive and retaining too much memory. Check lost references only on new channel creation and log message to indicate the previous channel (id and target) that has not been shutdown. This is done to avoid Object finalizers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classManagedChannelOrphanWrapper.ManagedChannelReference
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerprivate ManagedChannelOrphanWrapper.ManagedChannelReferencephantomprivate static java.lang.ref.ReferenceQueue<ManagedChannelOrphanWrapper>refqueueprivate static java.util.concurrent.ConcurrentMap<ManagedChannelOrphanWrapper.ManagedChannelReference,ManagedChannelOrphanWrapper.ManagedChannelReference>refs
-
Constructor Summary
Constructors Constructor Description ManagedChannelOrphanWrapper(ManagedChannel delegate)ManagedChannelOrphanWrapper(ManagedChannel delegate, java.lang.ref.ReferenceQueue<ManagedChannelOrphanWrapper> refqueue, java.util.concurrent.ConcurrentMap<ManagedChannelOrphanWrapper.ManagedChannelReference,ManagedChannelOrphanWrapper.ManagedChannelReference> refs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ManagedChannelshutdown()Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.ManagedChannelshutdownNow()Initiates a forceful shutdown in which preexisting and new calls are cancelled.-
Methods inherited from class io.grpc.internal.ForwardingManagedChannel
authority, awaitTermination, enterIdle, getState, isShutdown, isTerminated, newCall, notifyWhenStateChanged, resetConnectBackoff, toString
-
-
-
-
Field Detail
-
refqueue
private static final java.lang.ref.ReferenceQueue<ManagedChannelOrphanWrapper> refqueue
-
refs
private static final java.util.concurrent.ConcurrentMap<ManagedChannelOrphanWrapper.ManagedChannelReference,ManagedChannelOrphanWrapper.ManagedChannelReference> refs
-
logger
private static final java.util.logging.Logger logger
-
phantom
private final ManagedChannelOrphanWrapper.ManagedChannelReference phantom
-
-
Constructor Detail
-
ManagedChannelOrphanWrapper
ManagedChannelOrphanWrapper(ManagedChannel delegate)
-
ManagedChannelOrphanWrapper
ManagedChannelOrphanWrapper(ManagedChannel delegate, java.lang.ref.ReferenceQueue<ManagedChannelOrphanWrapper> refqueue, java.util.concurrent.ConcurrentMap<ManagedChannelOrphanWrapper.ManagedChannelReference,ManagedChannelOrphanWrapper.ManagedChannelReference> refs)
-
-
Method Detail
-
shutdown
public ManagedChannel shutdown()
Description copied from class:ManagedChannelInitiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.- Overrides:
shutdownin classForwardingManagedChannel- Returns:
- this
-
shutdownNow
public ManagedChannel shutdownNow()
Description copied from class:ManagedChannelInitiates a forceful shutdown in which preexisting and new calls are cancelled. Although forceful, the shutdown process is still not instantaneous;ManagedChannel.isTerminated()will likely returnfalseimmediately after this method returns.- Overrides:
shutdownNowin classForwardingManagedChannel- Returns:
- this
-
-