@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 Closeable
s.
Phantom references are used to track when WrappingProxy
s 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, unregisterClosable
protected 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>
IOException
protected 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 Closeable
close
in interface AutoCloseable
close
in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
IOException
@VisibleForTesting public static boolean isReaperThreadRunning()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.