summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0866fbc)
raw | patch | inline | side by side (parent: 0866fbc)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 20 Oct 2008 11:46:08 +0000 (11:46 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 20 Oct 2008 11:46:08 +0000 (11:46 +0000) |
- Delegate choice of starting row for newly created RRD files to the rrd_open.c API.
- Introduce the rrd_notify_row() function so that an implementation can choose to align the rows of new RRDs with existing RRDs, if desirable.
- Maintain the existing behaviour (random starting row) by default.
-- Daniel.Pocock
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1622 a5681a0c-68f1-0310-ab6d-d61299d08faa
- Introduce the rrd_notify_row() function so that an implementation can choose to align the rows of new RRDs with existing RRDs, if desirable.
- Maintain the existing behaviour (random starting row) by default.
-- Daniel.Pocock
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1622 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/src/rrd.h | patch | blob | history | |
program/src/rrd_create.c | patch | blob | history | |
program/src/rrd_open.c | patch | blob | history | |
program/src/rrd_update.c | patch | blob | history |
diff --git a/program/src/rrd.h b/program/src/rrd.h
index 3e0c871a56459b7cdf9b169ddab0615679e7178e..b40251f5cadd78a60ab2090d146b049706a401e6 100644 (file)
--- a/program/src/rrd.h
+++ b/program/src/rrd.h
int rrd_lock(
rrd_file_t *file)
RRD_DEPRECATED;
+ void rrd_notify_row(
+ rrd_file_t *rrd_file,
+ int rra_idx,
+ unsigned long rra_row,
+ time_t rra_time)
+ RRD_DEPRECATED;
+ unsigned long rrd_select_initial_row(
+ rrd_file_t *rrd_file,
+ int rra_idx,
+ rra_def_t *rra
+ )
+ RRD_DEPRECATED;
#endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
#endif /* _RRDLIB_H */
index c48900f30f37d50fd5a5d67318464827b8a639da..48a4d8ff6650bbca3427f31f65ffac90d514d551 100644 (file)
--- a/program/src/rrd_create.c
+++ b/program/src/rrd_create.c
const char *def,
rrd_t *rrd,
int ds_idx);
-long int rra_random_row(
- rra_def_t *);
static void rrd_free2(
rrd_t *rrd); /* our onwn copy, immmune to mmap */
* would occur for cur_row = 1 because rrd_update increments
* the pointer a priori. */
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
- rrd->rra_ptr->cur_row = rra_random_row(&rrd->rra_def[i]);
+ rrd->rra_ptr->cur_row = rrd_select_initial_row(rrd_file_dn, i, &rrd->rra_def[i]);
rrd_write(rrd_file_dn, rrd->rra_ptr, sizeof(rra_ptr_t));
}
free(rrd->rrd_value);
}
-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;
-}
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index a83031a99cf40694129157fcee55400594e74202..654005fac248cf786bf87d79a64bd7e82cce91fe 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
#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
{
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;
+}
+
index 62c8c3b4c50a91c776f10a2e676d76a8db2a5ca2..1d9d5150d325f90a65af55ade48702c7ddce02b5 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
(rrd_file, rrd, rra_idx, scratch_idx,
pcdp_summary, rra_time) == -1)
return -1;
+
+ rrd_notify_row(rrd_file, rra_idx, rra_pos_new, rra_time);
}
rra_start += rra_def->row_cnt * ds_cnt * sizeof(rrd_value_t);