Package org.apache.flink.core.fs
Class AutoCloseableRegistry
- java.lang.Object
-
- org.apache.flink.util.AbstractAutoCloseableRegistry<AutoCloseable,AutoCloseable,Object,Exception>
-
- org.apache.flink.core.fs.AutoCloseableRegistry
-
- All Implemented Interfaces:
AutoCloseable
@ThreadSafe @Internal public class AutoCloseableRegistry extends AbstractAutoCloseableRegistry<AutoCloseable,AutoCloseable,Object,Exception>
This class allows to register instances ofAutoCloseable, which are all closed if this registry is closed.Registering to an already closed registry will throw an exception and close the provided
AutoCloseable.Unlike
CloseableRegistrythis class can throw an exception during the close.This class closes all registered
Closeables in the reverse registration order.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.util.AbstractAutoCloseableRegistry
closeableToRef
-
-
Constructor Summary
Constructors Constructor Description AutoCloseableRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoClose(List<AutoCloseable> toClose)This implementation implies that any exception is possible during closing.protected voiddoRegister(AutoCloseable closeable, Map<AutoCloseable,Object> closeableMap)Does the actual registration of the closeable with the registry map.protected booleandoUnRegister(AutoCloseable closeable, Map<AutoCloseable,Object> 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 AutoCloseable closeable, @Nonnull Map<AutoCloseable,Object> 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<AutoCloseable,AutoCloseable,Object,Exception>
-
doUnRegister
protected boolean doUnRegister(@Nonnull AutoCloseable closeable, @Nonnull Map<AutoCloseable,Object> 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<AutoCloseable,AutoCloseable,Object,Exception>
-
doClose
protected void doClose(List<AutoCloseable> toClose) throws Exception
This implementation implies that any exception is possible during closing.- Specified by:
doClosein classAbstractAutoCloseableRegistry<AutoCloseable,AutoCloseable,Object,Exception>- Throws:
Exception
-
-