Class ObjectPool<KeyT extends @NonNull java.lang.Object,ObjectT extends @NonNull java.lang.Object>
- java.lang.Object
-
- org.apache.beam.sdk.io.aws2.common.ObjectPool<KeyT,ObjectT>
-
- Type Parameters:
KeyT- > Key to share objects byObjectT- > Shared object
- Direct Known Subclasses:
ObjectPool.ClientPool
@Internal @Experimental public class ObjectPool<KeyT extends @NonNull java.lang.Object,ObjectT extends @NonNull java.lang.Object> extends java.lang.ObjectReference counting object pool to easily share & destroy objects.Internal only, subject to incompatible changes or removal at any time!
NOTE: This relies heavily on the implementation of
Object.equals(Object)forObjectPool. If not implemented properly, clients can't be shared between instances ofDoFn.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjectPool.ClientPool<ClientT extends software.amazon.awssdk.core.SdkClient>Client pool to easily share AWS clients per configuration.
-
Constructor Summary
Constructors Constructor Description ObjectPool(java.util.function.Function<KeyT,ObjectT> builder)ObjectPool(java.util.function.Function<KeyT,ObjectT> builder, @Nullable org.apache.beam.sdk.function.ThrowingConsumer<java.lang.Exception,ObjectT> finalizer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <ClientT extends software.amazon.awssdk.core.SdkClient,BuilderT extends software.amazon.awssdk.awscore.client.builder.AwsClientBuilder<BuilderT,ClientT>>
ObjectPool.ClientPool<ClientT>pooledClientFactory(BuilderT builder)voidrelease(ObjectT object)Release a reference to a shared client instance.voidreleaseByKey(KeyT key)Release a reference to a shared object instance usingObjectPool.ObjectTretain(KeyT key)Retain a reference to a shared client instance.
-
-
-
Method Detail
-
retain
public ObjectT retain(KeyT key)
Retain a reference to a shared client instance. If not available, an instance is created.
-
releaseByKey
public void releaseByKey(KeyT key)
Release a reference to a shared object instance usingObjectPool. If that instance is not used anymore, it will be removed and destroyed.
-
release
public void release(ObjectT object)
Release a reference to a shared client instance. If that instance is not used anymore, it will be removed and destroyed.
-
pooledClientFactory
public static <ClientT extends software.amazon.awssdk.core.SdkClient,BuilderT extends software.amazon.awssdk.awscore.client.builder.AwsClientBuilder<BuilderT,ClientT>> ObjectPool.ClientPool<ClientT> pooledClientFactory(BuilderT builder)
-
-