Package org.apache.flink.runtime.memory
Class SharedResources
- java.lang.Object
-
- org.apache.flink.runtime.memory.SharedResources
-
public final class SharedResources extends Object
A map that keeps track of acquired shared resources and handles their allocation disposal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SharedResources.ResourceAndSize<T extends AutoCloseable>
A resource handle with size.
-
Constructor Summary
Constructors Constructor Description SharedResources()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends AutoCloseable>
SharedResources.ResourceAndSize<T>getOrAllocateSharedResource(String type, Object leaseHolder, org.apache.flink.util.function.LongFunctionWithException<T,Exception> initializer, long sizeForInitialization)
Gets the shared memory resource for the given owner and registers a lease.void
release(String type, Object leaseHolder, LongConsumer releaser)
Releases a lease (identified by the lease holder object) for the given type.
-
-
-
Method Detail
-
getOrAllocateSharedResource
public <T extends AutoCloseable> SharedResources.ResourceAndSize<T> getOrAllocateSharedResource(String type, Object leaseHolder, org.apache.flink.util.function.LongFunctionWithException<T,Exception> initializer, long sizeForInitialization) throws Exception
Gets the shared memory resource for the given owner and registers a lease. If the resource does not yet exist, it will be created via the given initializer function.The resource must be released when no longer used. That releases the lease. When all leases are released, the resource is disposed.
- Throws:
Exception
-
release
public void release(String type, Object leaseHolder, LongConsumer releaser) throws Exception
Releases a lease (identified by the lease holder object) for the given type. If no further leases exist, the resource is disposed.This method takes an additional hook that is called when the resource is disposed.
- Throws:
Exception
-
-