Skip to content

v3.5 Concurrency Model

Andrey Kurilov edited this page Aug 21, 2017 · 13 revisions

Unlimited Concurrency

Optional Locking

Allows to avoid the thread blocking due to necessary synchronization. Use Java's Lock.tryLock() method to perform an effort to obtain the exclusive lock immediately. Skip all the subsequent actions if this particular required lock is held by another thread. The class OptLockArrayBuffer is designed to support the optional locking.

Buffer Range Removing

Publishing the ArrayList.removeRange(from, to) method allows to recycle the buffer after it partially consumed w/o redundant instantiation. The interface OptLockBuffer is designed to support the range removing method.

Reentrant Service Tasks

Concept

A service task is such Closeable and Runnable task which executes for some very short time avoiding any blocks. It should be designed to be reentrant (similar to coroutines). A service task may be run by the different threads at the different time so its fields should be thread safe.

The service tasks are used by daemons. Daemons have shared/global service tasks registry which is implemented as a map where the particular daemon is a key and list of its service tasks is a value.

The common service tasks executors iterates the service tasks registry and executes the service tasks sequentially. As far as the service tasks executor is multithreaded the service tasks are executed concurrently also.

Types

BlockingQueueTransferTask

Transfers the entities from the blocking queue to the output in the batch mode. Very similar to IoTaskDispatchTask

Uses the OptLockBuffer

RoundRobinInputsTransferSvcTask

Used to get the completed I/O tasks from the selected storage driver and invoke the load monitor's processing method.

RoundRobinOutputsTransferSvcTask

Designed to scatter the entities uniformly among the several wrapped outputs. Selects the output buffer on the put operation using round-robin approach. Performs the actual transfer from the buffers to the outputs. Supports batch put and transfer operations.

Uses the OptLockBuffer

IoTaskDispatchTask

  1. Get any pending child I/O tasks into the buffer if capacity is enough.
  2. Get any pending incoming I/O tasks into the buffer if capacity is enough.
  3. Try to submit as much as possible I/O tasks from the buffer.
  4. Leave the I/O tasks have not submitted in the buffer.

Uses the OptLockBuffer

BasicLoadGenerator

The concurrent load generator. Recycles the shared OptLockBuffer.

MetricsSvcTasks

Service task performing the snapshots refreshing and periodic output.

Clone this wiki locally