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 anAbstractAutoCloseableRegistryregistersWrappingProxyCloseable. When the proxy becomes subject to GC, this registry takes care of closing unclosedCloseables.Phantom references are used to track when
WrappingProxys ofCloseablegot GC'ed. We ensure that the wrappedCloseableis 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 voiddoClose(List<Closeable> toClose)This implementation doesn't imply any exception during closing due to backward compatibility.protected voiddoRegister(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 booleandoUnRegister(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:AbstractAutoCloseableRegistryDoes 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:
doRegisterin 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:AbstractAutoCloseableRegistryDoes 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:
doUnRegisterin 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:
doClosein classAbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>- Throws:
IOException
-
-