Package org.apache.flink.core.fs
Class CloseableRegistry
- java.lang.Object
-
- org.apache.flink.util.AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException>
-
- org.apache.flink.core.fs.CloseableRegistry
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@Internal public class CloseableRegistry extends AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException> implements Closeable
This class allows to register instances ofCloseable, which are all closed if this registry is closed.Registering to an already closed registry will throw an exception and close the provided
CloseableAll methods in this class are thread-safe.
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 CloseableRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoClose(List<Closeable> toClose)This implementation doesn't imply any exception during closing due to backward compatibility.protected voiddoRegister(Closeable closeable, Map<Closeable,Object> closeableMap)Does the actual registration of the closeable with the registry map.protected booleandoUnRegister(Closeable closeable, Map<Closeable,Object> closeableMap)Does the actual un-registration of the closeable from the registry map.voidunregisterAndCloseAll(Closeable... toUnregisterAndClose)Unregisters all givenCloseableobjects from this registry and closes all objects that are were actually registered.-
Methods inherited from class org.apache.flink.util.AbstractAutoCloseableRegistry
close, getNumberOfRegisteredCloseables, getSynchronizationLock, isCloseableRegistered, isClosed, registerCloseable, removeCloseableInternal, unregisterCloseable
-
-
-
-
Method Detail
-
doRegister
protected void doRegister(@Nonnull Closeable closeable, @Nonnull Map<Closeable,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<Closeable,Closeable,Object,IOException>
-
doUnRegister
protected boolean doUnRegister(@Nonnull Closeable closeable, @Nonnull Map<Closeable,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<Closeable,Closeable,Object,IOException>
-
doClose
public 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,Closeable,Object,IOException>- Throws:
IOException
-
unregisterAndCloseAll
public void unregisterAndCloseAll(Closeable... toUnregisterAndClose) throws IOException
Unregisters all givenCloseableobjects from this registry and closes all objects that are were actually registered. Suppressed (and collects) all exceptions that happen during closing and throws only when the allCloseableobjects have been processed.- Parameters:
toUnregisterAndClose- closables to unregister and close.- Throws:
IOException- collects all exceptions encountered during closing of the given objects.
-
-