schedule: Introduce scheduling library

This moudule provides a Scheduler class scheduling execution of
callables on a background thread. This should be part of the new
scalable vm sampling implemntation.

See the module docstring and tests for usage examples.

Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
executor: introduce the executor library

Executor is a thread pool augmented with the
capability of discard blocked worker threads,
by replacing them with fresh ones.

This is needed to accomodate the needs of the sampling code.
The sampling needs to deal with possibly blocking libvirt
calls which needs to enter into the QEMU monitor,
thus can get stuck due to QEMU being in D state.

Change-Id: Ic06da1ba57868dc2c7db67a1868ad10087a1cff2
Signed-off-by: Francesco Romani <fromani@redhat.com>
sampling: extract SampleWindow class

The existing AdvancedStatsFunction does actually
two different things: wraps a client-provided
callable, and implements a sliding window for samples.

This patch splits the two responsabilities.
Other than cleanup for the sake of clarity and testability,
future sampling refactoring patches will still
need to store samples and handle a sliding window;
but samples will be given instead of grabbed
(inversion of control, think the new libvirt bulk stats API)
so this also improve code reuse.

Change-Id: I48fe9e7f8ed3f5ec677d8f91a82cb70d0bdbb2e7
Signed-off-by: Francesco Romani <fromani@redhat.com>
sampling: rename variables to make code nicer

Rename internal variables of SampleWindow
methods to make the code nicer and easier
to read.

No changes in behaviour.

Change-Id: I14caeb163552a659d1e7fcc103ac7fc9f1697bad
Signed-off-by: Francesco Romani <fromani@redhat.com>
tests: split SampleWindow tests

Reorganize and rationalize the unit tests after
the introduction of SampleWindow class.

Change-Id: I74f0005eae5466e083002f0d871bcf1fbec54fef
Signed-off-by: Francesco Romani <fromani@redhat.com>
spec: require libvirt 1.2.9

To make use of the bulk stats API, we need libvirt 1.2.9+,
which is found on Fedora 20 in the virt-preview repo and,
(to be confirmed) in RHEL/Centos 7.1.