General purpose threadpool for decision engine

Implements the singleton general purpose threadpool for the decision
engine and associated tests.

A threadpool is a collection of one or more threads typically called
'workers' to which tasks can be submitted. These submitted tasks will
be scheduled by the threadpool and subsequently executed. How many
tasks will be executed concurrently is managed by the underlying
threadpool and its configuration. In Python the submission of tasks
to a threadpool returns an object called a 'future'. Futures provide
a method to interface with the task being executed that allows to
retrieve information about its state. Such as if it currently is being
executed, if it is waiting on a condition and if it has completed
succesfully. Finally, futures allow to retrieve what has been returned
by the submitted task.

In the case of most OpenStack projects instead of interfacing with native
Python concurrency the futurist library is used. This library provides
very similar interfaces to native concurrency with some extras such as
the wait_for_any method.

For more information about futurist or Python concurrency the following
references can be consulted:
https://docs.python.org/3/library/concurrent.futures.html
https://docs.openstack.org/futurist/latest/reference/index.html#executors

Partially Implements: blueprint general-purpose-decision-engine-threadpool

Change-Id: I94bd9a17290967f011762f2b9c787ee7c46ff930
This commit is contained in:
Dantali0n
2019-10-11 14:23:34 +02:00
parent e835efaa3f
commit 2b6ee38327
4 changed files with 257 additions and 3 deletions

View File

@@ -40,11 +40,18 @@ WATCHER_DECISION_ENGINE_OPTS = [
default='watcher.decision.api',
help='The identifier used by the Watcher '
'module on the message broker'),
cfg.IntOpt('max_workers',
cfg.IntOpt('max_audit_workers',
default=2,
required=True,
help='The maximum number of threads that can be used to '
'execute strategies'),
'execute audits in parallel.'),
cfg.IntOpt('max_general_workers',
default=4,
required=True,
help='The maximum number of threads that can be used to '
'execute general tasks in parallel. The number of general '
'workers will not increase depending on the number of '
'audit workers!'),
cfg.IntOpt('action_plan_expiry',
default=24,
mutable=True,