X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_open.c;h=6b2d6ac00cec1f6abbdbc06ce2bce894af7e24e7;hp=86d608cc556a0838419882f55dafb36341d97523;hb=9e6dd6a7c7768d90a8f62d7379d3dfa361e3ad7f;hpb=607eea59c2ba85c63e2de1b665b37a6093e1575c diff --git a/src/rrd_open.c b/src/rrd_open.c index 86d608c..6b2d6ac 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 @@ -648,3 +652,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; +} +