Workload parameters

These declarations used to provide module description to server
and simply parse workload parameters in JSON format.

Each parameter declaration has:
- type @see wlp_type_t
- limitations (like string max length, number range, possible values, etc.) @see wlp_range_t and macroses
- name and description (text)
- offset in control structure which is used during parsing

Parameter declaration are saved as array of wlp_descr_t structures with "NULL-terminator" with type WLP_NULL.

Workload parameter generators

Some of workload parameters may be set on per-request basis. For example,
disk i/o generator with random or sequental access to blocks needs number
of block per each request. Thus, it would be generated in this module.

There are two main generators:

Constants

WLPF_OUTPUT, WLPF_REQUEST, WLPF_NO_FLAGS, WLPF_OPTIONAL

Workload parameter flags

#define WLPF_NO_FLAGS   0x00
#define WLPF_OPTIONAL   0x01
#define WLPF_REQUEST    0x02
#define WLPF_OUTPUT (WLPF_REQUEST | 0x04)

Functions

WLP_NO_RANGE, WLP_STRING_SET_RANGE, WLP_FLOAT_RANGE, WLP_INT_RANGE, WLP_STRING_LENGTH

Range declaration

#define WLP_NO_RANGE()
#define WLP_STRING_LENGTH(length)
#define WLP_INT_RANGE(min, max)
#define WLP_FLOAT_RANGE(min, max)
#define WLP_STRING_SET_RANGE(set)

WLP_FLOAT_DEFAULT, WLP_STRING_SET_DEFAULT, WLP_NO_DEFAULT, WLP_INT_DEFAULT, WLP_STRING_DEFAULT, WLP_BOOLEAN_DEFAULT

Default wl parameter value

#define WLP_NO_DEFAULT()
#define WLP_BOOLEAN_DEFAULT(b)
#define WLP_INT_DEFAULT(i)
#define WLP_FLOAT_DEFAULT(f)
#define WLP_STRING_DEFAULT(s)
#define WLP_STRING_SET_DEFAULT(ssi)

wlp_get_base_type

public

LIBEXPORT wlp_type_t wlp_get_base_type(wlp_descr_t* wlp)

wlpgen_generate


Generate request parameter structure for workload wl

ARGUMENTS

RETURN VALUES
pointer to that structure or NULL if no request params exist for this workload type

NOTES
structure is freed on wl_request_destroy()

void* wlpgen_generate(struct workload* wl)

Types

Workload parameter type definitions

typedef int64_t     wlp_integer_t;

typedef double      wlp_float_t;

typedef char        wlp_string_t;

typedef boolean_t   wlp_bool_t;

typedef int         wlp_strset_t;

typedef void*       wlp_hiobject_t;

wlp_type_t

Workload parameter type hint.

When TSLoad generates a value that is passed to a module as a workload or a request
parameter, it relies on that hint to correctly handle incoming value and write it to
memory.

There are "base" types which define that factors but doesn't know nature of a
value and a "meta" types that add meaning to a value. Meta-types rely on a corresponding
base value in how they handled but add some meaning to values.

I.e. there is WLP_INTEGER that is used for keeping integers (base type) that expect
"integer" number from config and wlp_integer_t residing in data structure. But if it
represent a size (i.e. size of disk block) it is reasonable to use WLP_SIZE - metatype
that has same constraints as WLP_INTEGER but may provide nice formatting (i.e. "8 kb")
in some cases.

VALUES

typedef enum {
    WLP_NULL,

    WLP_BOOL,
    WLP_INTEGER,
    WLP_FLOAT,
    WLP_RAW_STRING,     /*Any string*/

    WLP_STRING_SET,      /*string - one of possible values*/

    /* metatypes - using primitive types in serialization
     * but have different meanings */
    WLP_SIZE,
    WLP_TIME,

    WLP_FILE_PATH,
    WLP_CPU_OBJECT,
    WLP_DISK,

    WLP_TYPE_MAX,

    WLP_HI_OBJECT        /* Base type - not really used */
} wlp_type_t;

wlp_range_t

typedef struct {
    boolean_t range;        /*enabled flag*/

    /* Here should be union, but because of some smart people, who decided that
     * | ISO C++03 8.5.1[dcl.init.aggr]/15:
     * | When a union is initialized with a brace-enclosed initializer,
     * | the braces shall only contain an initializer for the first member of the union.
     * and another smart people from Microsoft who ignoring C99 compliance
     * we will waste memory to provide nice macros like WLP_STRING_LENGTH
     *  */
    struct {
        /*WLP_RAW_STRING*/
        struct {
            unsigned str_length;
        };
        /*WLP_INTEGER*/
        struct {
            wlp_integer_t i_min;
            wlp_integer_t i_max;
        };
        /*WLP_FLOAT*/
        struct {
            wlp_float_t d_min;
            wlp_float_t d_max;
        };
        /*WLP_STRING_SET*/
        struct {
            int ss_num;
            const char** ss_strings;
        };
    };
} wlp_range_t;

wlp_default_t

typedef struct {
    boolean_t enabled;

    wlp_bool_t b;
    wlp_integer_t i;
    wlp_float_t f;
    const char* s;
    wlp_strset_t ssi;
} wlp_default_t;

wlp_descr_t


Workload parameter descriptor

MEMBERS

typedef struct {
    wlp_type_t type;
    unsigned long flags;

    wlp_range_t range;
    wlp_default_t defval;

    const char* name;
    const char* description;

    size_t off;
} wlp_descr_t;

typedef enum wlpgen_type

typedef enum wlpgen_type {
    WLPG_VALUE,
    WLPG_RANDOM
} wlpgen_type_t;

typedef union wlpgen_value

typedef union wlpgen_value {
    char value[16];
    char* string;
} wlpgen_value_t;

wlpgen_probability_t

typedef struct {
    wlpgen_value_t  value;

    wlpgen_value_t* valarray;
    int                length;

    double probability;
} wlpgen_probability_t;

typedef struct wlpgen_randgen

typedef struct wlpgen_randgen {
    randgen_t*    rg;
    randvar_t*     rv;

    /* For boolean/stringset - probability map */
    int pcount;
    wlpgen_probability_t* pmap;
} wlpgen_randgen_t;

typedef struct wlp_generator

typedef struct wlp_generator {
    wlpgen_type_t type;
    wlp_descr_t* wlp;
    struct workload* wl;

    union {
        wlpgen_value_t value;
        wlpgen_randgen_t randgen;
    } generator;

    list_node_t    node;
} wlp_generator_t;