Package org.apache.flink.core.fs
Interface ICloseableRegistry
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
CloseableRegistry
@Internal public interface ICloseableRegistry extends 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 Modifier and Type Field Description static ICloseableRegistryNO_OPNo-op implementation ofICloseableRegistry.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisClosed()voidregisterCloseable(Closeable closeable)Registers aCloseablewith the registry.default CloseableregisterCloseableTemporarily(Closeable closeable)Same asregisterCloseable(Closeable)but allows tounregisterthe passed closeable by closing the returned closeable.booleanunregisterCloseable(Closeable closeable)Removes aCloseablefrom the registry.
-
-
-
Field Detail
-
NO_OP
static final ICloseableRegistry NO_OP
No-op implementation ofICloseableRegistry.
-
-
Method Detail
-
registerCloseable
void registerCloseable(Closeable closeable) throws IOException
Registers aCloseablewith the registry. In case the registry is already closed, this method throws anIllegalStateExceptionand closes the passedCloseable.- Parameters:
closeable- Closeable to register.- Throws:
IOException- exception when the registry was closed before.
-
registerCloseableTemporarily
default Closeable registerCloseableTemporarily(Closeable closeable) throws IOException
Same asregisterCloseable(Closeable)but allows tounregisterthe passed closeable by closing the returned closeable.- Parameters:
closeable- Closeable to register.- Returns:
- another Closeable that unregisters the passed closeable.
- Throws:
IOException- exception when the registry was closed before.
-
unregisterCloseable
boolean unregisterCloseable(Closeable closeable)
Removes aCloseablefrom the registry.- Parameters:
closeable- instance to remove from the registry.- Returns:
- true if the closeable was previously registered and became unregistered through this call.
-
isClosed
boolean isClosed()
- Returns:
- true if this registry was closed.
-
-