Package org.apache.flink.core.fs
Class SafetyNetCloseableRegistry
- java.lang.Object
-
- org.apache.flink.util.AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
-
- org.apache.flink.core.fs.SafetyNetCloseableRegistry
-
- All Implemented Interfaces:
AutoCloseable
@Internal public class SafetyNetCloseableRegistry extends AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
This implementation of anAbstractAutoCloseableRegistry
registersWrappingProxyCloseable
. When the proxy becomes subject to GC, this registry takes care of closing unclosedCloseable
s.Phantom references are used to track when
WrappingProxy
s ofCloseable
got GC'ed. We ensure that the wrappedCloseable
is properly closed to avoid resource leaks.Other than that, it works like a normal
CloseableRegistry
.All methods in this class are thread-safe.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.util.AbstractAutoCloseableRegistry
closeableToRef
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doClose(List<Closeable> toClose)
This implementation doesn't imply any exception during closing due to backward compatibility.protected void
doRegister(WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable, Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Does the actual registration of the closeable with the registry map.protected boolean
doUnRegister(WrappingProxyCloseable<? extends Closeable> closeable, Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Does the actual un-registration of the closeable from the registry map.-
Methods inherited from class org.apache.flink.util.AbstractAutoCloseableRegistry
close, getNumberOfRegisteredCloseables, getSynchronizationLock, isCloseableRegistered, isClosed, registerCloseable, removeCloseableInternal, unregisterCloseable
-
-
-
-
Method Detail
-
doRegister
protected void doRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Description copied from class:AbstractAutoCloseableRegistry
Does the actual registration of the closeable with the registry map. This should not do any long running or potentially blocking operations as is is executed under the registry's lock.- Specified by:
doRegister
in classAbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
-
doUnRegister
protected boolean doUnRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> closeable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Description copied from class:AbstractAutoCloseableRegistry
Does the actual un-registration of the closeable from the registry map. This should not do any long running or potentially blocking operations as is is executed under the registry's lock.- Specified by:
doUnRegister
in classAbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
-
doClose
protected void doClose(List<Closeable> toClose) throws IOException
This implementation doesn't imply any exception during closing due to backward compatibility.- Specified by:
doClose
in classAbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
- Throws:
IOException
-
-