Only create version 4 rrd files if the new holtwinters MHW.. CF is used.
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 22 Jul 2007 09:47:53 +0000 (09:47 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 22 Jul 2007 09:47:53 +0000 (09:47 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1167 a5681a0c-68f1-0310-ab6d-d61299d08faa

NEWS
src/rrd_create.c
src/rrd_dump.c
src/rrd_format.h
src/rrd_restore.c

diff --git a/NEWS b/NEWS
index 542783b..6054e35 100644 (file)
--- 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
 ------------------------
index 0e2f82c..4e442d2 100644 (file)
@@ -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;
index eb9b469..be000f9 100644 (file)
@@ -100,7 +100,11 @@ int rrd_dump_r(
 
     fputs("<!-- Round Robin Database Dump -->", out_file);
     fputs("<rrd>", out_file);
-    fprintf(out_file, "\t<version> %s </version>\n", RRD_VERSION);
+    if ( atoi(rrd.stat_head->version) <= 3) {
+        fprintf(out_file, "\t<version> %s </version>\n", RRD_VERSION3);
+    } else {
+        fprintf(out_file, "\t<version> %s </version>\n", RRD_VERSION);
+    }
     fprintf(out_file, "\t<step> %lu </step> <!-- Seconds -->\n",
             rrd.stat_head->pdp_step);
 #if HAVE_STRFTIME
index 7dbc8ed..d95ea4a 100644 (file)
@@ -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"
index 65bbb10..1164adb 100644 (file)
@@ -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;