]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #7644 About Storage Groups messages changes
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Mon, 17 May 2021 21:23:28 +0000 (23:23 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:02 +0000 (09:03 +0100)
Allow user to explcitly set 'ListedOrder' policy for storage group
defined. This policy will be also used when no policy is specified at
all.
Change messages about Storage Groups and storage choice.

bacula/src/dird/backup.c
bacula/src/dird/dird_conf.c
bacula/src/dird/job.c
bacula/src/dird/store_mngr.c
bacula/src/dird/store_mngr.h

index 8a9b7fed44f6e4caa11d23339dff7f30dc72ed91..15fc77c3c5d47c139d29ae3e3099b227af731c58 100644 (file)
@@ -542,8 +542,7 @@ bool do_backup(JCR *jcr)
    if (wstore_group) {
       /* Apply policy for the write storage list */
       jcr->store_mngr->apply_policy(true);
-      Jmsg(jcr, M_INFO, 0, _("Possible storage choices: %s\n"),
-            jcr->store_mngr->print_wlist());
+      Dmsg1(100, "Possible storage choices: %s\n", jcr->store_mngr->print_wlist());
       iter_no = 2;
    }
 
@@ -558,10 +557,10 @@ bool do_backup(JCR *jcr)
    for (int iter=0; iter<iter_no; iter++) {
       if (wstore_group) {
          if (iter == 0) {
-            Jmsg(jcr, M_INFO, 0, _("Trying to start job on any storage from the list without "
-                     "waiting for busy devices first.\n"));
+            Dmsg0(100, "Trying to start job on any storage from the list without "
+                     "waiting for busy devices first.\n");
          } else {
-            Jmsg(jcr, M_INFO, 0, _("All devices are currently busy, need to wait at each try of storage reservation.\n"));
+            Dmsg0(100, "All devices are currently busy, need to wait at each try of storage reservation.\n");
          }
       }
 
@@ -576,12 +575,10 @@ bool do_backup(JCR *jcr)
           * Start conversation with Storage daemon
           */
          if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
-            Jmsg(jcr, M_INFO, 0, _("Failed connect to the storage: %s\n"),
-                  jcr->store_mngr->get_wstore()->name());
+            Dmsg1(100, "Failed connect to the storage: %s\n", jcr->store_mngr->get_wstore()->name());
             continue;
          } else {
-            Jmsg(jcr, M_INFO, 0, _("Connected to the storage: %s\n"),
-                  jcr->store_mngr->get_wstore()->name());
+            Dmsg1(100, "Connected to the storage: %s\n", jcr->store_mngr->get_wstore()->name());
          }
 
          alist wlist;
@@ -595,12 +592,11 @@ bool do_backup(JCR *jcr)
           * because we have only 2 iterations (so 'iter' variable is either 0 or 1)
           */
          if (!start_storage_daemon_job(jcr, NULL, &wlist, wstore_group ? (bool)iter : true)) {
-            Jmsg(jcr, M_INFO, 0, _("Failed to start job on the storage: %s\n"),
-                  jcr->store_mngr->get_wstore()->name());
+            Dmsg1(100, "Failed to start job on the storage: %s\n", jcr->store_mngr->get_wstore()->name());
             continue;
          } else {
-            Jmsg(jcr, M_INFO, 0, _("Started job on storage: %s\n"),
-                  jcr->store_mngr->get_wstore()->name());
+            Jmsg(jcr, M_INFO, 0, _("Selected storage: %s, StorageGroupPolicy: \"%s\"\n"),
+                  jcr->store_mngr->get_wstore()->name(), jcr->store_mngr->get_policy_name());
             sd_job_started = true;
             break;
          }
index 0f0f8d9e7a14f1da64cdddebc737ef925029faac..66cc4c210fa25d7c3d4200feea3dd183f0dc263c 100644 (file)
@@ -602,7 +602,7 @@ RES_ITEM job_items[] = {
    {"Level",     store_level,   ITEM(res_job.JobLevel),    0, 0, 0},
    {"Messages",  store_res,     ITEM(res_job.messages),  R_MSGS, ITEM_REQUIRED, 0},
    {"Storage",   store_alist_res, ITEM(res_job.storage),  R_STORAGE, 0, 0},
-   {"StoragePolicy",   store_storage_mngr, ITEM(res_job.storage_policy),  0, 0, 0},
+   {"StorageGroupPolicy",   store_storage_mngr, ITEM(res_job.storage_policy),  0, 0, 0},
    {"Pool",      store_res,     ITEM(res_job.pool),      R_POOL, ITEM_REQUIRED, 0},
    {"NextPool",  store_res,     ITEM(res_job.next_pool), R_POOL, 0, 0},
    {"FullBackupPool",  store_res, ITEM(res_job.full_pool),   R_POOL, 0, 0},
index 2f128d2e9ef50026b5dc7595f4c9e1eb86502938..d6100da4a2f95b80e859290e80b3e2b76a7f9dc5 100644 (file)
@@ -1629,9 +1629,11 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
    if (job->storage_policy) {
       if (strcmp(job->storage_policy, "LeastUsed") == 0) {
          jcr->store_mngr = New(LeastUsedStore());
+      } else if (strcmp(job->storage_policy, "ListedOrder") == 0) {
+         jcr->store_mngr = New(ListedOrderStore());
       }
    } else {
-      jcr->store_mngr = New(SimpleStoreMngr());
+      jcr->store_mngr = New(ListedOrderStore());
    }
 
    set_jcr_default_store(jcr, job);
index f5615cdb431025b5eb6c5f581084e5794475fddf..c3e54bef480811fd49469fb339ae5e5741babe93 100644 (file)
@@ -299,7 +299,8 @@ void LeastUsedStore::apply_policy(bool write_store) {
 }
 
 
-StorageManager::StorageManager() {
+StorageManager::StorageManager(const char *policy) {
+   this->policy = bstrdup(policy);
    rstore.set_rw(false);
    wstore.set_rw(true);
 };
index 14c64c4745288cc0ecbe48048336230fa95e0e5b..916c7cb15919b415b2fd1b9a0bc99f59046c49f4 100644 (file)
@@ -42,6 +42,7 @@ class STORE;
  */
 static char const *storage_mngmt_policy[] = {
    "LeastUsed",
+   "ListedOrder",
    NULL
 };
 
@@ -124,15 +125,17 @@ class StorageManager : public SMARTALLOC {
    protected:
       storage rstore;   /* Read storage */
       storage wstore;   /* Write storage */
+      const char *policy;
 
    public:
       virtual void apply_policy(bool write_store) = 0;
 
       virtual ~StorageManager() {
          reset_rwstorage();
+         free(policy);
       };
 
-      StorageManager();
+      StorageManager(const char *policy);
 
       /* Helper to validate if policy user wants to use is a valid one */
       static bool check_policy(const char *policy) {
@@ -194,6 +197,10 @@ class StorageManager : public SMARTALLOC {
 
       /************ GENERIC STORAGE HELPERS ************/
       void reset_rwstorage();
+
+      const char *get_policy_name() {
+         return policy;
+      }
 };
 
 /*
@@ -203,7 +210,7 @@ class LeastUsedStore : public StorageManager {
    public:
       void apply_policy(bool write_store);
 
-   LeastUsedStore() {
+   LeastUsedStore() : StorageManager("LeastUsed") {
    }
 
    ~LeastUsedStore() {
@@ -213,7 +220,7 @@ class LeastUsedStore : public StorageManager {
 /*
  * Default policy for the storage group. It uses first available storage from the list.
  */
-class SimpleStoreMngr : public StorageManager {
+class ListedOrderStore : public StorageManager {
    private:
 
    public:
@@ -221,10 +228,10 @@ class SimpleStoreMngr : public StorageManager {
          /* Do nothing for now */
       }
 
-   SimpleStoreMngr() {
+   ListedOrderStore(): StorageManager("ListedOrder")  {
    }
 
-   ~SimpleStoreMngr() {
+   ~ListedOrderStore() {
    }
 };