From: oetiker Date: Sun, 22 Jul 2007 09:47:53 +0000 (+0000) Subject: Only create version 4 rrd files if the new holtwinters MHW.. CF is used. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a6cabd4d567fa0bfd8192ef99c804f1b2359e22d;p=rrdtool.git Only create version 4 rrd files if the new holtwinters MHW.. CF is used. git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1167 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/NEWS b/NEWS index 542783b..6054e35 100644 --- a/NEWS +++ b/NEWS @@ -35,8 +35,10 @@ Forecasting (Evan Miller) method. It is a drop-in replacement for HWPREDICT, and is better suited for data whose seasonal variations grow or shrink in proportion to the average. -* Due to the new aggregation function, we also get a new version of the - rrd file format. +Incompatibility +--------------- +* If you create an RRD with the new MHWPREDICT function, the resulting rrdfile will + be version 0004 and can only be used in rrdtool 1.3. Locale Independent Input ------------------------ diff --git a/src/rrd_create.c b/src/rrd_create.c index 0e2f82c..4e442d2 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -133,8 +133,8 @@ int rrd_create_r( } /* set some defaults */ - strcpy(rrd.stat_head->cookie, RRD_COOKIE); - strcpy(rrd.stat_head->version, RRD_VERSION); + strcpy(rrd.stat_head->cookie, RRD_COOKIE); + strcpy(rrd.stat_head->version, RRD_VERSION3); /* by default we are still version 3 */ rrd.stat_head->float_cookie = FLOAT_COOKIE; rrd.stat_head->ds_cnt = 0; /* this will be adjusted later */ rrd.stat_head->rra_cnt = 0; /* ditto */ @@ -247,8 +247,9 @@ int rrd_create_r( rrd_set_error("Failed to parse CF name"); switch (cf_conv (rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) { - case CF_HWPREDICT: case CF_MHWPREDICT: + strcpy(rrd.stat_head->version, RRD_VERSION); /* MHWPREDICT causes Version 4 */ + case CF_HWPREDICT: /* initialize some parameters */ rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha]. u_val = 0.1; diff --git a/src/rrd_dump.c b/src/rrd_dump.c index eb9b469..be000f9 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -100,7 +100,11 @@ int rrd_dump_r( fputs("", out_file); fputs("", out_file); - fprintf(out_file, "\t %s \n", RRD_VERSION); + if ( atoi(rrd.stat_head->version) <= 3) { + fprintf(out_file, "\t %s \n", RRD_VERSION3); + } else { + fprintf(out_file, "\t %s \n", RRD_VERSION); + } fprintf(out_file, "\t %lu \n", rrd.stat_head->pdp_step); #if HAVE_STRFTIME diff --git a/src/rrd_format.h b/src/rrd_format.h index 7dbc8ed..d95ea4a 100644 --- a/src/rrd_format.h +++ b/src/rrd_format.h @@ -22,6 +22,7 @@ /* #define RRD_VERSION "0002" */ /* changed because microsecond precision requires another field */ #define RRD_VERSION "0004" +#define RRD_VERSION3 "0003" #define FLOAT_COOKIE 8.642135E130 #include "rrd_nan_inf.h" diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 65bbb10..1164adb 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -223,14 +223,12 @@ int xml2rrd( rrd->stat_head = NULL; return -1; } - /* make sure we output the right version */ - strcpy(rrd->stat_head->version, RRD_VERSION); - - /* if (atoi(rrd -> stat_head -> version) < 2) - { - rrd_set_error("Can only restore version >= 2 (Not %s). Dump your old rrd using a current rrdtool dump.", rrd -> stat_head -> version ); - return -1; - } */ + /* make sure we output the right version only go over 3 if input is over 3 too */ + if (input_version > 3 ){ + strcpy(rrd->stat_head->version, RRD_VERSION); + } else { + strcpy(rrd->stat_head->version, RRD_VERSION3); + } rrd->stat_head->float_cookie = FLOAT_COOKIE; rrd->stat_head->ds_cnt = 0;