From 03876599db932281bcdee6b96623ee5b601197f7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 23 Apr 2006 08:16:02 +0000 Subject: [PATCH] - Add 'Dir Status' button to the gnome console. - More work on migration. - Restore non-compatible base64 coding to permit compatibility. - Display heap stats in Storage daemon without debug level. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2959 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 32 +- bacula/kes-1.39 | 5 + bacula/scripts/.cvsignore | 3 + bacula/src/console2.glade | 608 +++++++++++++++++++++++++++++++++---- bacula/src/dird/migrate.c | 407 +++++++++++-------------- bacula/src/lib/base64.c | 2 +- bacula/src/stored/status.c | 15 +- bacula/src/version.h | 6 +- 8 files changed, 766 insertions(+), 312 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index b752edd3a1..b74009a813 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -49,6 +49,20 @@ pool specified. Here's how I'd define Migration Selection Types: +With Regexes: +Client -- Migrate data from selected client only. Migration Selection +Pattern regexp provides pattern to select client names, eg ^FS00* makes +all client names starting with FS00 eligible for migration. + +Jobname -- Migration all jobs matching name. Migration Selection Pattern +regexp provides pattern to select jobnames existing in pool. + +Volume -- Migrate all data on specified volumes. Migration Selection +Pattern regexp provides selection criteria for volumes to be migrated. +Volumes must exist in pool to be eligible for migration. + + +With Regex optional: LowestUtil -- Identify the volume in the pool with the least data on it and empty it. No Migration Selection Pattern required. @@ -60,25 +74,17 @@ PoolOccupancy -- if pool occupancy exceeds , migrate volumes . Pool highmig and lowmig values are in pool definition, no Migration Selection Pattern required. -Client -- Migrate data from selected client only. Migration Selection -Pattern regexp provides pattern to select client names, eg ^FS00* makes -all client names starting with FS00 eligible for migration. + +No regex: +SQLQuery -- Migrate all jobuids returned by the supplied SQL query. +Migration Selection Pattern contains SQL query to execute; should return +a list of 1 or more jobuids to migrate. PoolResidence -- Migrate data sitting in pool for longer than PoolResidence value in pool definition. Migration Selection Pattern optional; if specified, override value in pool definition (value in minutes). -Volume -- Migrate all data on specified volumes. Migration Selection -Pattern regexp provides selection criteria for volumes to be migrated. -Volumes must exist in pool to be eligible for migration. - -Jobname -- Migration all jobs matching name. Migration Selection Pattern -regexp provides pattern to select jobnames existing in pool. - -SQLQuery -- Migrate all jobuids returned by the supplied SQL query. -Migration Selection Pattern contains SQL query to execute; should return -a list of 1 or more jobuids to migrate. [ possibly a Python event -- kes ] === diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index 6e80941f73..0b204e2fab 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -2,6 +2,11 @@ Kern Sibbald General: +23Apr06 +- Add 'Dir Status' button to the gnome console. +- More work on migration. +- Restore non-compatible base64 coding to permit compatibility. +- Display heap stats in Storage daemon without debug level. 22Apr06 - Integrate most of the MinGW changes -- more to do. 21Apr06 diff --git a/bacula/scripts/.cvsignore b/bacula/scripts/.cvsignore index 38595022c1..588d20d72f 100644 --- a/bacula/scripts/.cvsignore +++ b/bacula/scripts/.cvsignore @@ -1,3 +1,6 @@ +wxconsole.console_apps +wxconsole.desktop.consolehelper +wxconsole.desktop.xsu disk-changer bacula-tray-monitor.desktop bacula-tray-monior.desktop diff --git a/bacula/src/console2.glade b/bacula/src/console2.glade index c915357c07..c843426e46 100644 --- a/bacula/src/console2.glade +++ b/bacula/src/console2.glade @@ -14,6 +14,12 @@ 600 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True @@ -254,58 +260,111 @@ GTK_ORIENTATION_HORIZONTAL GTK_TOOLBAR_BOTH True + True - + True Connect to Director Connect True - gtk-new + gtk-disconnect + True + True + False + + False + True + - + True Run a Job Run True - gtk-execute + gtk-execute + True + True + False + + False + True + - + True - Display Messages - Msgs + Dir Status True - gtk-find - + gnome-stock-text-bulleted-list + True + True + False + + + False + True + - + True Restore True - gtk-revert-to-saved + gtk-revert-to-saved + True + True + False + + False + True + - + True Label True - gtk-save-as + gtk-save-as + True + True + False + + False + True + + + + + + True + Display Messages + Msgs + True + gtk-find + True + True + False + + + + False + True + @@ -335,6 +394,8 @@ True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD True @@ -374,6 +435,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -395,7 +460,7 @@ 150 True - * + * False @@ -440,6 +505,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -470,6 +539,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -505,6 +578,12 @@ True True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -537,6 +616,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -556,6 +639,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True @@ -601,6 +685,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -629,10 +717,14 @@ GTK_JUSTIFY_LEFT False False - 0.1 + 0.10000000149 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -650,10 +742,14 @@ GTK_JUSTIFY_LEFT False False - 0.0400001 + 0.0400000996888 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -671,10 +767,14 @@ GTK_JUSTIFY_LEFT False False - 0.15 + 0.15000000596 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -708,6 +808,12 @@ True True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -734,6 +840,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True @@ -756,6 +863,10 @@ 0.5 2 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -771,6 +882,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True @@ -805,10 +917,14 @@ GTK_JUSTIFY_CENTER False False - 0.48 - 0.46 + 0.479999989271 + 0.460000008345 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -830,6 +946,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -857,7 +977,7 @@ 0 True - * + * False @@ -884,6 +1004,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -916,6 +1040,12 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -943,6 +1073,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True @@ -955,6 +1086,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True @@ -994,6 +1126,10 @@ 0.5 0 9 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 2 @@ -1009,6 +1145,10 @@ 0.5 1 1 + 0 + 0 + 0 + 0 @@ -1038,6 +1178,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1064,7 +1208,7 @@ 0 True - * + * False @@ -1092,6 +1236,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1119,6 +1267,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1147,7 +1299,7 @@ 0 True - * + * False @@ -1174,6 +1326,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1208,6 +1364,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 30 @@ -1247,6 +1407,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1273,7 +1437,7 @@ 0 True - * + * False @@ -1300,6 +1464,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1327,6 +1495,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 123 @@ -1366,6 +1538,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1392,7 +1568,7 @@ 0 True - * + * False @@ -1419,6 +1595,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1448,6 +1628,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1471,6 +1655,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1515,6 +1703,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1552,6 +1744,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1578,7 +1774,7 @@ 0 True - * + * False @@ -1605,6 +1801,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1627,6 +1827,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1654,6 +1858,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 100 @@ -1691,6 +1899,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1717,7 +1929,7 @@ 0 True - * + * False @@ -1744,6 +1956,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1766,6 +1982,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1793,6 +2013,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 120 @@ -1830,6 +2054,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1856,7 +2084,7 @@ 0 True - * + * False @@ -1883,6 +2111,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1905,6 +2137,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -1932,6 +2168,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 120 @@ -1969,6 +2209,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1995,7 +2239,7 @@ 0 True - * + * False @@ -2022,6 +2266,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -2049,6 +2297,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 120 @@ -2086,6 +2338,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2103,7 +2359,7 @@ 0 True - * + * False @@ -2126,6 +2382,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 120 @@ -2170,6 +2430,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2187,7 +2451,7 @@ 0 True - * + * False @@ -2210,6 +2474,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 120 @@ -2247,6 +2515,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2264,7 +2536,7 @@ 0 True - * + * False @@ -2287,6 +2559,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 36 @@ -2317,6 +2593,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2347,6 +2627,12 @@ 450 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True @@ -2552,32 +2838,51 @@ GTK_ORIENTATION_HORIZONTAL GTK_TOOLBAR_BOTH True + True - + True - gtk-go-up - True + gtk-go-up + True + True + False + + False + True + - + True - gtk-add - True + gtk-add + True + True + False + + False + True + - + True - gtk-remove - True + gtk-remove + True + True + False + + False + True + @@ -2616,6 +2921,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2633,7 +2942,7 @@ 0 True - * + * False @@ -2719,10 +3028,14 @@ GTK_JUSTIFY_LEFT False False - 0.02 + 0.019999999553 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2740,6 +3053,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True @@ -2764,6 +3078,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2779,6 +3097,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True @@ -2801,6 +3120,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 8 @@ -2827,6 +3150,12 @@ True True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -2854,6 +3183,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True @@ -2866,6 +3196,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True @@ -2899,6 +3230,10 @@ 0.5 0 9 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2923,10 +3258,14 @@ GTK_JUSTIFY_CENTER False False - 0.15 + 0.15000000596 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -2953,7 +3292,7 @@ 0 True - * + * False @@ -2980,6 +3319,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3002,6 +3345,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3043,10 +3390,14 @@ GTK_JUSTIFY_LEFT False False - 0.12 + 0.119999997318 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3073,7 +3424,7 @@ 0 True - * + * False @@ -3100,6 +3451,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3122,6 +3477,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3163,10 +3522,14 @@ GTK_JUSTIFY_LEFT False False - 0.17 + 0.170000001788 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3184,7 +3547,7 @@ 0 True - * + * False @@ -3221,10 +3584,14 @@ GTK_JUSTIFY_LEFT False False - 0.09 + 0.0900000035763 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3276,6 +3643,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3304,6 +3675,12 @@ 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -3325,6 +3702,7 @@ gtk-help True GTK_RELIEF_NORMAL + True -11 @@ -3335,6 +3713,7 @@ True True GTK_RELIEF_NORMAL + True 0 @@ -3345,6 +3724,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -3382,6 +3765,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3404,6 +3791,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -3442,6 +3830,10 @@ 0.5 0 9 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 2 @@ -3457,6 +3849,10 @@ 0.5 1 1 + 0 + 0 + 0 + 0 @@ -3485,6 +3881,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3511,7 +3911,7 @@ 0 True - * + * False @@ -3539,6 +3939,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3566,6 +3970,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 27 @@ -3611,6 +4019,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3637,7 +4049,7 @@ 0 True - * + * False @@ -3664,6 +4076,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3691,6 +4107,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 25 @@ -3727,6 +4147,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3753,7 +4177,7 @@ 0 True - * + * False @@ -3780,6 +4204,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3807,6 +4235,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 23 @@ -3843,6 +4275,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -3869,7 +4305,7 @@ 0 True - * + * False @@ -3896,6 +4332,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3918,6 +4358,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -3945,6 +4389,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 21 @@ -3981,6 +4429,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -4007,7 +4459,7 @@ 0 True - * + * False @@ -4034,6 +4486,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -4056,6 +4512,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -4083,6 +4543,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 21 @@ -4126,6 +4590,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -4143,7 +4611,7 @@ 0 True - * + * False @@ -4166,6 +4634,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 53 @@ -4194,6 +4666,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -4220,6 +4696,12 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True True @@ -4241,6 +4723,7 @@ gtk-close True GTK_RELIEF_NORMAL + True -7 @@ -4274,6 +4757,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -4297,6 +4784,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -4312,7 +4803,8 @@ True GTK_PROGRESS_LEFT_TO_RIGHT 0 - 0.1 + 0.10000000149 + PANGO_ELLIPSIZE_NONE 0 @@ -4336,6 +4828,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index ac8f8f0ac0..95e9441416 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -40,6 +40,9 @@ static char OKbootstrap[] = "3000 OK bootstrap\n"; static bool get_job_to_migrate(JCR *jcr); +struct jobitems; +static bool regex_find_jobids(JCR *jcr, jobitems *ji, const char *query1, + const char *query2, const char *type); /* * Called here before the job is run to do the job @@ -295,17 +298,25 @@ bool do_migration(JCR *jcr) return false; } +struct jobitems { + POOLMEM *JobIds; + uint32_t count; +}; + /* * Callback handler make list of JobIds */ static int jobid_handler(void *ctx, int num_fields, char **row) { - POOLMEM *JobIds = (POOLMEM *)ctx; + jobitems *ji = (jobitems *)ctx; - if (JobIds[0] != 0) { - pm_strcat(JobIds, ","); + if (ji->count == 0) { + ji->JobIds[0] = 0; + } else { + pm_strcat(ji->JobIds, ","); } - pm_strcat(JobIds, row[0]); + pm_strcat(ji->JobIds, row[0]); + ji->count++; return 0; } @@ -341,6 +352,47 @@ static int unique_name_handler(void *ctx, int num_fields, char **row) return 0; } +/* Get Job names in Pool */ +const char *sql_job = + "SELECT DISTINCT Job.Name from Job,Pool" + " WHERE Pool.Name='%s' AND Job.PoolId=Pool.PoolId"; + +/* Get JobIds from regex'ed Job names */ +const char *sql_jobids_from_job = + "SELECT DISTINCT Job.JobId FROM Job,Pool" + " WHERE Job.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId" + " ORDER by Job.StartTime"; + +/* Get Client names in Pool */ +const char *sql_client = + "SELECT DISTINCT Client.Name from Client,Pool,Job" + " WHERE Pool.Name='%s' AND Job.ClientId=Client.ClientId AND" + " Job.PoolId=Pool.PoolId"; + +/* Get JobIds from regex'ed Client names */ +const char *sql_jobids_from_client = + "SELECT DISTINCT Job.JobId FROM Job,Pool" + " WHERE Client.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId" + " AND Job.ClientId=Client.ClientId " + " ORDER by Job.StartTime"; + +/* Get Volume names in Pool */ +const char *sql_vol = + "SELECT DISTINCT VolumeName FROM Media,Pool WHERE" + " VolStatus in ('Full','Used','Error') AND" + " Media.PoolId=Pool.PoolId AND Pool.Name='%s'"; + +/* Get JobIds from regex'ed Volume names */ +const char *sql_jobids_from_vol = + "SELECT DISTINCT Job.JobId FROM Media,JobMedia,Job" + " WHERE Media.VolumeName='%s' AND Media.MediaId=JobMedia.MediaId" + " AND JobMedia.JobId=Job.JobId" + " ORDER by Job.StartTime"; + + + + + const char *sql_smallest_vol = "SELECT MediaId FROM Media,Pool WHERE" " VolStatus in ('Full','Used','Error') AND" @@ -369,31 +421,12 @@ const char *sql_vol_bytes = " Media.PoolId=Pool.PoolId AND Pool.Name='%s' AND" " VolBytes<%s ORDER BY LastWritten ASC LIMIT 1"; -const char *sql_client = - "SELECT DISTINCT Client.Name from Client,Pool,Media,Job,JobMedia " - " WHERE Media.PoolId=Pool.PoolId AND Pool.Name='%s' AND" - " JobMedia.JobId=Job.JobId AND Job.ClientId=Client.ClientId AND" - " Job.PoolId=Media.PoolId"; - -const char *sql_job = - "SELECT DISTINCT Job.Name from Job,Pool" - " WHERE Pool.Name='%s' AND Job.PoolId=Pool.PoolId"; - -const char *sql_jobids_from_job = - "SELECT DISTINCT Job.JobId FROM Job,Pool" - " WHERE Job.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId" - " ORDER by Job.StartTime"; - const char *sql_ujobid = "SELECT DISTINCT Job.Job from Client,Pool,Media,Job,JobMedia " " WHERE Media.PoolId=Pool.PoolId AND Pool.Name='%s' AND" " JobMedia.JobId=Job.JobId AND Job.PoolId=Media.PoolId"; -const char *sql_vol = - "SELECT DISTINCT VolumeName FROM Media,Pool WHERE" - " VolStatus in ('Full','Used','Error') AND" - " Media.PoolId=Pool.PoolId AND Pool.Name='%s'"; /* @@ -404,245 +437,76 @@ static bool get_job_to_migrate(JCR *jcr) { char ed1[30]; POOL_MEM query(PM_MESSAGE); - POOLMEM *JobIds = get_pool_memory(PM_MESSAGE); JobId_t JobId; - int stat, rc; + int stat; char *p; - dlist *item_chain; - uitem *item = NULL; - uitem *last_item = NULL; - char prbuf[500]; - regex_t preg; + jobitems ji; + + ji.JobIds = get_pool_memory(PM_MESSAGE); - JobIds[0] = 0; + ji.count = 0; if (jcr->MigrateJobId != 0) { jcr->previous_jr.JobId = jcr->MigrateJobId; Dmsg1(000, "previous jobid=%u\n", jcr->MigrateJobId); } else { switch (jcr->job->selection_type) { case MT_JOB: - if (!jcr->job->selection_pattern) { - Jmsg(jcr, M_FATAL, 0, _("No Migration Job selection pattern specified.\n")); + if (!regex_find_jobids(jcr, &ji, sql_job, sql_jobids_from_job, "Job")) { goto bail_out; - } - Dmsg1(000, "Job regex=%s\n", jcr->job->selection_pattern); - /* Complie regex expression */ - rc = regcomp(&preg, jcr->job->selection_pattern, REG_EXTENDED); - if (rc != 0) { - regerror(rc, &preg, prbuf, sizeof(prbuf)); - Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), - jcr->job->selection_pattern, prbuf); + } + break; + case MT_CLIENT: + if (!regex_find_jobids(jcr, &ji, sql_client, + sql_jobids_from_client, "Client")) { goto bail_out; - } - item_chain = New(dlist(item, &item->link)); - /* Basic query for Job names */ - Mmsg(query, sql_job, jcr->pool->hdr.name); - Dmsg1(000, "query=%s\n", query.c_str()); - if (!db_sql_query(jcr->db, query.c_str(), unique_name_handler, - (void *)item_chain)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Job failed. ERR=%s\n"), db_strerror(jcr->db)); + } + break; + case MT_VOLUME: + if (!regex_find_jobids(jcr, &ji, sql_vol, + sql_jobids_from_vol, "Volume")) { goto bail_out; - } - /* Now apply the regex to the job names and remove any item not matched */ - foreach_dlist(item, item_chain) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - if (last_item) { - Dmsg1(000, "Remove item %s\n", last_item->item); - free(last_item->item); - item_chain->remove(last_item); - } - Dmsg1(000, "Jobitem=%s\n", item->item); - rc = regexec(&preg, item->item, nmatch, pmatch, 0); - if (rc == 0) { - last_item = NULL; /* keep this one */ - } else { - last_item = item; - } - } - if (last_item) { - free(last_item->item); - Dmsg1(000, "Remove item %s\n", last_item->item); - item_chain->remove(last_item); - } - regfree(&preg); - /* - * At this point, we have a list of items in item_chain - * that have been matched by the regex, so now we need - * to look up their jobids. - */ - JobIds[0] = 0; - foreach_dlist(item, item_chain) { - Dmsg1(000, "Got Job: %s\n", item->item); - Mmsg(query, sql_jobids_from_job, item->item, jcr->pool->hdr.name); - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - } - if (JobIds[0] == 0) { - Jmsg(jcr, M_INFO, 0, _("No jobs found to migrate.\n")); - goto ok_out; - } - Dmsg1(000, "Job Jobids=%s\n", JobIds); - delete item_chain; + } break; - case MT_SMALLEST_VOL: - Mmsg(query, sql_smallest_vol, jcr->pool->hdr.name); - JobIds[0] = 0; - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); + case MT_SQLQUERY: + if (!jcr->job->selection_pattern) { + Jmsg(jcr, M_FATAL, 0, _("No Migration SQL selection pattern specified.\n")); goto bail_out; } - if (JobIds[0] == 0) { - Jmsg(jcr, M_INFO, 0, _("No Volumes found to migrate.\n")); - goto ok_out; - } - /* ***FIXME*** must loop over JobIds */ - Mmsg(query, sql_jobids_from_mediaid, JobIds); - JobIds[0] = 0; - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { + Dmsg1(000, "SQL=%s\n", jcr->job->selection_pattern); + if (!db_sql_query(jcr->db, jcr->job->selection_pattern, + jobid_handler, (void *)&ji)) { Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); + _("SQL failed. ERR=%s\n"), db_strerror(jcr->db)); goto bail_out; } - Dmsg1(000, "Smallest Vol Jobids=%s\n", JobIds); + break; + + +/***** Below not implemented yet *********/ + case MT_SMALLEST_VOL: + Mmsg(query, sql_smallest_vol, jcr->pool->hdr.name); +// Mmsg(query2, sql_jobids_from_mediaid, JobIds); +// Dmsg1(000, "Smallest Vol Jobids=%s\n", JobIds); break; case MT_OLDEST_VOL: Mmsg(query, sql_oldest_vol, jcr->pool->hdr.name); - JobIds[0] = 0; - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - if (JobIds[0] == 0) { - Jmsg(jcr, M_INFO, 0, _("No Volume found to migrate.\n")); - goto ok_out; - } - Mmsg(query, sql_jobids_from_mediaid, JobIds); - JobIds[0] = 0; - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - Dmsg1(000, "Oldest Vol Jobids=%s\n", JobIds); +// Mmsg(query2, sql_jobids_from_mediaid, JobIds); +// Dmsg1(000, "Oldest Vol Jobids=%s\n", JobIds); break; case MT_POOL_OCCUPANCY: Mmsg(query, sql_pool_bytes, jcr->pool->hdr.name); - JobIds[0] = 0; - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - if (JobIds[0] == 0) { - Jmsg(jcr, M_INFO, 0, _("No jobs found to migrate.\n")); - goto ok_out; - } - Dmsg1(000, "Pool Occupancy Jobids=%s\n", JobIds); +// Dmsg1(000, "Pool Occupancy Jobids=%s\n", JobIds); break; case MT_POOL_TIME: Dmsg0(000, "Pool time not implemented\n"); break; - case MT_CLIENT: - if (!jcr->job->selection_pattern) { - Jmsg(jcr, M_FATAL, 0, _("No Migration Client selection pattern specified.\n")); - goto bail_out; - } - Dmsg1(000, "Client regex=%s\n", jcr->job->selection_pattern); - rc = regcomp(&preg, jcr->job->selection_pattern, REG_EXTENDED); - if (rc != 0) { - regerror(rc, &preg, prbuf, sizeof(prbuf)); - Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), - jcr->job->selection_pattern, prbuf); - } - item_chain = New(dlist(item, &item->link)); - Mmsg(query, sql_client, jcr->pool->hdr.name); - Dmsg1(100, "query=%s\n", query.c_str()); - if (!db_sql_query(jcr->db, query.c_str(), unique_name_handler, - (void *)item_chain)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Client failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - /* Now apply the regex and create the jobs */ - foreach_dlist(item, item_chain) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - rc = regexec(&preg, item->item, nmatch, pmatch, 0); - if (rc == 0) { - Dmsg1(000, "Do Client=%s\n", item->item); - } - free(item->item); - } - regfree(&preg); - delete item_chain; - break; - case MT_VOLUME: - if (!jcr->job->selection_pattern) { - Jmsg(jcr, M_FATAL, 0, _("No Migration Volume selection pattern specified.\n")); - goto bail_out; - } - Dmsg1(000, "Volume regex=%s\n", jcr->job->selection_pattern); - rc = regcomp(&preg, jcr->job->selection_pattern, REG_EXTENDED); - if (rc != 0) { - regerror(rc, &preg, prbuf, sizeof(prbuf)); - Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), - jcr->job->selection_pattern, prbuf); - } - item_chain = New(dlist(item, &item->link)); - Mmsg(query, sql_vol, jcr->pool->hdr.name); - Dmsg1(100, "query=%s\n", query.c_str()); - if (!db_sql_query(jcr->db, query.c_str(), unique_name_handler, - (void *)item_chain)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Job failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - /* Now apply the regex and create the jobs */ - foreach_dlist(item, item_chain) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - rc = regexec(&preg, item->item, nmatch, pmatch, 0); - if (rc == 0) { - Dmsg1(000, "Do Vol=%s\n", item->item); - } - free(item->item); - } - regfree(&preg); - delete item_chain; - break; - case MT_SQLQUERY: - JobIds[0] = 0; - if (!jcr->job->selection_pattern) { - Jmsg(jcr, M_FATAL, 0, _("No Migration SQL selection pattern specified.\n")); - goto bail_out; - } - Dmsg1(000, "SQL=%s\n", jcr->job->selection_pattern); - if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) { - Jmsg(jcr, M_FATAL, 0, - _("SQL to get Volume failed. ERR=%s\n"), db_strerror(jcr->db)); - goto bail_out; - } - if (JobIds[0] == 0) { - Jmsg(jcr, M_INFO, 0, _("No jobs found to migrate.\n")); - goto ok_out; - } - Dmsg1(000, "Jobids=%s\n", JobIds); - goto bail_out; - break; default: Jmsg(jcr, M_FATAL, 0, _("Unknown Migration Selection Type.\n")); goto bail_out; } } - p = JobIds; + p = ji.JobIds; JobId = 0; stat = get_next_jobid_from_list(&p, &JobId); Dmsg2(000, "get_next_jobid stat=%d JobId=%u\n", stat, JobId); @@ -667,15 +531,98 @@ static bool get_job_to_migrate(JCR *jcr) jcr->previous_jr.JobId, jcr->previous_jr.Job); ok_out: - free_pool_memory(JobIds); + free_pool_memory(ji.JobIds); return true; bail_out: - free_pool_memory(JobIds); + free_pool_memory(ji.JobIds); return false; } +static bool regex_find_jobids(JCR *jcr, jobitems *ji, const char *query1, + const char *query2, const char *type) { + dlist *item_chain; + uitem *item = NULL; + uitem *last_item = NULL; + regex_t preg; + char prbuf[500]; + int rc; + bool ok = false; + POOL_MEM query(PM_MESSAGE); + + item_chain = New(dlist(item, &item->link)); + if (!jcr->job->selection_pattern) { + Jmsg(jcr, M_FATAL, 0, _("No Migration %s selection pattern specified.\n"), + type); + goto bail_out; + } + Dmsg1(000, "regex=%s\n", jcr->job->selection_pattern); + /* Compile regex expression */ + rc = regcomp(&preg, jcr->job->selection_pattern, REG_EXTENDED); + if (rc != 0) { + regerror(rc, &preg, prbuf, sizeof(prbuf)); + Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), + jcr->job->selection_pattern, prbuf); + goto bail_out; + } + /* Basic query for names */ + Mmsg(query, query1, jcr->pool->hdr.name); + if (!db_sql_query(jcr->db, query.c_str(), unique_name_handler, + (void *)item_chain)) { + Jmsg(jcr, M_FATAL, 0, + _("SQL to get %s failed. ERR=%s\n"), type, db_strerror(jcr->db)); + goto bail_out; + } + /* Now apply the regex to the names and remove any item not matched */ + foreach_dlist(item, item_chain) { + const int nmatch = 30; + regmatch_t pmatch[nmatch]; + if (last_item) { + Dmsg1(000, "Remove item %s\n", last_item->item); + free(last_item->item); + item_chain->remove(last_item); + } + Dmsg1(000, "Jobitem=%s\n", item->item); + rc = regexec(&preg, item->item, nmatch, pmatch, 0); + if (rc == 0) { + last_item = NULL; /* keep this one */ + } else { + last_item = item; + } + } + if (last_item) { + free(last_item->item); + Dmsg1(000, "Remove item %s\n", last_item->item); + item_chain->remove(last_item); + } + regfree(&preg); + /* + * At this point, we have a list of items in item_chain + * that have been matched by the regex, so now we need + * to look up their jobids. + */ + ji->count = 0; + foreach_dlist(item, item_chain) { + Dmsg1(000, "Got Job: %s\n", item->item); + Mmsg(query, query2, item->item, jcr->pool->hdr.name); + if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)&ji)) { + Jmsg(jcr, M_FATAL, 0, + _("SQL failed. ERR=%s\n"), db_strerror(jcr->db)); + goto bail_out; + } + } + if (ji->count == 0) { + Jmsg(jcr, M_INFO, 0, _("No %ss found to migrate.\n"), type); + ok = true; + } +bail_out: + Dmsg1(000, "Job Jobids=%s\n", ji->JobIds); + delete item_chain; + return ok; +} + + /* * Release resources allocated during backup. */ diff --git a/bacula/src/lib/base64.c b/bacula/src/lib/base64.c index b59411dfb4..08b95d4851 100644 --- a/bacula/src/lib/base64.c +++ b/bacula/src/lib/base64.c @@ -23,7 +23,7 @@ #include "bacula.h" -const bool compatible = true; +const bool compatible = false; #ifdef TEST_MODE #include diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index eff170455e..46a72d95d6 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -61,7 +61,7 @@ bool status_cmd(JCR *jcr) DEVICE *dev; BSOCK *user = jcr->dir_bsock; char dt[MAX_TIME_LENGTH]; - char b1[30], b2[30], b3[30]; + char b1[35], b2[35], b3[35], b4[35]; int bpb; bnet_fsend(user, _("\n%s Version: %s (%s) %s %s %s\n"), my_name, @@ -73,14 +73,11 @@ bool status_cmd(JCR *jcr) else { bnet_fsend(user, _("Daemon started %s, %d Jobs run since started.\n"), dt, num_jobs_run); } - if (debug_level > 0) { - char b1[35], b2[35], b3[35], b4[35]; - bnet_fsend(user, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), - edit_uint64_with_commas(sm_bytes, b1), - edit_uint64_with_commas(sm_max_bytes, b2), - edit_uint64_with_commas(sm_buffers, b3), - edit_uint64_with_commas(sm_max_buffers, b4)); - } + bnet_fsend(user, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), + edit_uint64_with_commas(sm_bytes, b1), + edit_uint64_with_commas(sm_max_bytes, b2), + edit_uint64_with_commas(sm_buffers, b3), + edit_uint64_with_commas(sm_max_buffers, b4)); /* * List running jobs diff --git a/bacula/src/version.h b/bacula/src/version.h index 703fd04794..d56476dcc8 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "1.39.9" -#define BDATE "22 April 2006" -#define LSMDATE "22Apr06" +#define VERSION "1.39.10" +#define BDATE "23 April 2006" +#define LSMDATE "23Apr06" /* Debug flags */ #undef DEBUG -- 2.39.5