Class IntervalSequencer<T>

java.lang.Object
io.nosqlbench.engine.api.activityapi.planning.IntervalSequencer<T>
Type Parameters:
T - The element which is to be scheduled.
All Implemented Interfaces:
ElementSequencer<T>

public class IntervalSequencer<T> extends Object implements ElementSequencer<T>

Introduction

This class allows you to create a cyclic schedule that will maintain a mix of elements according to individual ratios. It is quite flexible and consistent in how the scheduling works. This scheme requires a whole-numbered ratio for each element, and produces a discrete schedule that indexes into the original elements. Given a set of elements and respective whole-numbered ratios of the frequency that they should occur, IntervalSequencer creates an execution sequence that honors each element's expected frequency within the cycle while interleaving the elements in a fair and stable way.

Explanation and Example

Given a set of three events A, B, and C, and a set of respective frequencies of these events 5, 5, and 1. In short form: A:5,B:5,C:1. This means that a total of 11 events will be scheduled. In order to support interleaving the events over the cycle, each event is scheduled independently according to an ideal schedule. For A, over the unit interval of (0,0,1.0), it would occur at 0.0, 0.2, 0.4, 0.6, and 0.8, restarting again at the next unit interval. B would have exactly the same ideal schedule. However, A occurs first in the list, and is given sequencing precedence at any point at which both events occur at exactly the same scheduled offset. Essentially, events are first scheduled in the unit interval according to their ideal equidistant schedule in the unit interval, and then by their order of appearance as presented. The unit interval does not actually determine when in time an event may occur, but is used for the major-minor sequencing rules above. The result is merely a stable sequence for execution planning separate from the specific timing of each event.

Further Examples

These examples simply show in symbolic terms how the ordering is affected by different ratios. It is important to keep in mind that the ratios have no primary influence on relative ordering when events overlap in time. In that case, order of presentation breaks the tie.

  • X:1,Y:1,Z:1 - X Y Z
  • O:4,I:3 - O I O I O I O
  • O:4,I:4 - O I O I O I O I
  • O:4,I:5 - O I I O I O I O I