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. UseWeakReference
to 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 class
ManagedChannelOrphanWrapper.ManagedChannelReference
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
private ManagedChannelOrphanWrapper.ManagedChannelReference
phantom
private static java.lang.ref.ReferenceQueue<ManagedChannelOrphanWrapper>
refqueue
private 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 ManagedChannel
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.ManagedChannel
shutdownNow()
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:ManagedChannel
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.- Overrides:
shutdown
in classForwardingManagedChannel
- Returns:
- this
-
shutdownNow
public ManagedChannel shutdownNow()
Description copied from class:ManagedChannel
Initiates a forceful shutdown in which preexisting and new calls are cancelled. Although forceful, the shutdown process is still not instantaneous;ManagedChannel.isTerminated()
will likely returnfalse
immediately after this method returns.- Overrides:
shutdownNow
in classForwardingManagedChannel
- Returns:
- this
-
-