Class RateLimiterClientCache
- java.lang.Object
-
- org.apache.beam.sdk.io.components.ratelimiter.RateLimiterClientCache
-
public class RateLimiterClientCache extends java.lang.ObjectA static cache forManagedChannels to Rate Limit Service.This class ensures that multiple DoFn instances (threads) in the same Worker sharing the same RLS address will share a single
ManagedChannel.It uses reference counting to close the channel when it is no longer in use by any RateLimiter instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.grpc.ManagedChannelgetChannel()static RateLimiterClientCachegetOrCreate(java.lang.String address)Gets or creates a cached client for the given address.voidrelease()Releases the client.
-
-
-
Method Detail
-
getOrCreate
public static RateLimiterClientCache getOrCreate(java.lang.String address)
Gets or creates a cached client for the given address. Increments the reference count. Synchronized on the class to prevent race conditions when multiple instances call getOrCreate() simultaneously
-
getChannel
public io.grpc.ManagedChannel getChannel()
-
release
public void release()
Releases the client. Decrements the reference count. If reference count reaches 0, the channel is shut down and removed from the cache. Synchronized on the class to prevent race conditions when multiple threads call release() simultaneously and to prevent race conditions between getOrCreate() and release() calls.
-
-