@Internal public class SafetyNetCloseableRegistry extends AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
AbstractCloseableRegistry registers WrappingProxyCloseable. When
the proxy becomes subject to GC, this registry takes care of closing unclosed Closeables.
Phantom references are used to track when WrappingProxys of Closeable got
GC'ed. We ensure that the wrapped Closeable is properly closed to avoid resource leaks.
Other than that, it works like a normal CloseableRegistry.
All methods in this class are thread-safe.
closeableToRef| Constructor and Description |
|---|
SafetyNetCloseableRegistry() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
doRegister(WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable,
Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap) |
protected void |
doUnRegister(WrappingProxyCloseable<? extends Closeable> closeable,
Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap) |
static boolean |
isReaperThreadRunning() |
getSynchronizationLock, isClosed, registerClosable, unregisterClosableprotected void doRegister(WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable, Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap) throws IOException
doRegister in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>IOExceptionprotected void doUnRegister(WrappingProxyCloseable<? extends Closeable> closeable, Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
doUnRegister in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>IOException@VisibleForTesting public static boolean isReaperThreadRunning()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.