Class PartitionStripedExecutor
java.lang.Object
com.linkedin.venice.utils.concurrent.PartitionStripedExecutor
A minimal, producer-agnostic, bounded partition-striped executor. Each stripe is one FIFO worker thread with a
bounded queue; a partition is mapped by
stripeFor(int) and always lands on the same stripe, so same-stripe
tasks run in submission order while different stripes run in parallel and never stall one another. Admission is
bounded and blocking (never caller-runs, never drops); it carries no producer concepts (writers, callbacks,
futures, flush, retries), only opaque Runnables.-
Constructor Summary
ConstructorsConstructorDescriptionPartitionStripedExecutor(int stripeCount, int queueCapacity, String threadNamePrefix) PartitionStripedExecutor(int stripeCount, int queueCapacity, String threadNamePrefix, ObjIntConsumer<ThreadPoolExecutor> stripeObserver) -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) Awaits termination of every stripe against a single shared deadline derived fromtimeout.voidexecuteOnStripe(int stripe, Runnable task) Routes a task to an exact stripe (used for per-stripe fence markers), blocking if its queue is full.intintgetStripeQueueSize(int stripe) intvoidshutdown()intstripeFor(int partition) Maps a partition to a stripe in[0, stripeCount); masks the sign bit soInteger.MIN_VALUEstays in range.voidRoutes a task to the stripe owningpartition, blocking if that stripe's queue is full.
-
Constructor Details
-
PartitionStripedExecutor
-
PartitionStripedExecutor
public PartitionStripedExecutor(int stripeCount, int queueCapacity, String threadNamePrefix, ObjIntConsumer<ThreadPoolExecutor> stripeObserver) - Parameters:
threadNamePrefix- per-stripe thread names are<threadNamePrefix>-<stripe>-t<n>stripeObserver- optional construction-time observer invoked once per stripe with itsThreadPoolExecutorand index (e.g. to register metrics); may be null
-
-
Method Details
-
getStripeCount
public int getStripeCount() -
stripeFor
public int stripeFor(int partition) Maps a partition to a stripe in[0, stripeCount); masks the sign bit soInteger.MIN_VALUEstays in range. -
submit
Routes a task to the stripe owningpartition, blocking if that stripe's queue is full.- Throws:
RejectedExecutionException- if the executor is shut down or the caller is interrupted while waiting
-
executeOnStripe
Routes a task to an exact stripe (used for per-stripe fence markers), blocking if its queue is full. -
getStripeQueueSize
public int getStripeQueueSize(int stripe) -
getTotalQueueSize
public int getTotalQueueSize() -
shutdown
public void shutdown() -
shutdownNow
-
awaitTermination
Awaits termination of every stripe against a single shared deadline derived fromtimeout.- Throws:
InterruptedException
-