X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_open.c;h=654005fac248cf786bf87d79a64bd7e82cce91fe;hb=2fd3455de8e25630bb6c533314806ed70ba41344;hp=a83031a99cf40694129157fcee55400594e74202;hpb=59525f3de81d5f6a9c5e5fc3a6662fa7e074163f;p=rrdtool.git diff --git a/src/rrd_open.c b/src/rrd_open.c index a83031a..654005f 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -54,6 +54,10 @@ #endif #endif +long int rra_random_row( + rra_def_t *); + + /* Open a database file, return its header and an open filehandle, * positioned to the first cdp in the first rra. * In the error path of rrd_open, only rrd_free(&rrd) has to be called @@ -707,3 +711,46 @@ void rrd_freemem( { free(mem); } + +/* + * rra_update informs us about the RRAs being updated + * The low level storage API may use this information for + * aligning RRAs within stripes, or other performance enhancements + */ +void rrd_notify_row( + rrd_file_t *rrd_file, + int rra_idx, + unsigned long rra_row, + time_t rra_time) +{ +} + +/* + * This function is called when creating a new RRD + * The storage implementation can use this opportunity to select + * a sensible starting row within the file. + * The default implementation is random, to ensure that all RRAs + * don't change to a new disk block at the same time + */ +unsigned long rrd_select_initial_row( + rrd_file_t *rrd_file, + int rra_idx, + rra_def_t *rra + ) +{ + return rra_random_row(rra); +} + +static int rand_init = 0; + +long int rra_random_row( + rra_def_t *rra) +{ + if (!rand_init) { + srandom((unsigned int) time(NULL) + (unsigned int) getpid()); + rand_init++; + } + + return random() % rra->row_cnt; +} +