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());
+ jcr->store_mngr->apply_write_policy();
+ Dmsg2(100, "Configured storages: %s, source: %s\n",
+ jcr->store_mngr->print_origin_wlist(), jcr->store_mngr->get_wsource());
+ Dmsg2(100, "Possible storage choices after applying \"%s\" policy: %s\n",
+ jcr->store_mngr->get_policy_name(),
+ jcr->store_mngr->print_possible_wlist());
iter_no = 2;
}
Dmsg1(100, "Failed to start job on the storage: %s\n", jcr->store_mngr->get_wstore()->name());
continue;
} else {
- Jmsg(jcr, M_INFO, 0, _("Selected storage: %s, device: %s, StorageGroupPolicy: \"%s\"\n"),
- jcr->store_mngr->get_wstore()->name(), jcr->write_dev, jcr->store_mngr->get_policy_name());
sd_job_started = true;
break;
}
}
if(sd_job_started) {
+ int group_size = jcr->store_mngr->get_origin_wstore_list()->size();
+ Jmsg(jcr, M_INFO, 0,
+ "Storage \"%s\" was selected out of group of %d available storages. "
+ "StorageGroupPolicy used: \"%s\"",
+ jcr->store_mngr->get_wstore()->name(), group_size,
+ jcr->store_mngr->get_policy_name());
/* We can decrement not-used SDs since job was started against first available storage from the list */
jcr->store_mngr->dec_unused_wstores();
storage::storage() {
list = New(alist(10, not_owned_by_alist));
+ origin_list = New(alist(10, not_owned_by_alist));
source = get_pool_memory(PM_MESSAGE);
list_str = get_pool_memory(PM_MESSAGE);
*source = 0;
delete list;
list = NULL;
}
+ if (origin_list) {
+ delete origin_list;
+ origin_list = NULL;
+ }
if (source) {
free_and_null_pool_memory(source);
}
return list;
}
+alist *storage::get_origin_list() {
+ return origin_list;
+}
+
const char *storage::get_source() const {
return source;
}
reset();
list->append(storage);
+ origin_list->append(storage);
store = storage;
if (!source) {
STORE *s;
foreach_alist(s, storage) {
list->append(s);
+ origin_list->append(s);
}
store = (STORE *)list->first();
void storage::reset() {
store = NULL;
+
while (list->size()) {
list->remove(0);
}
+ while (origin_list->size()) {
+ origin_list->remove(0);
+ }
*source = 0;
*list_str = 0;
}
}
}
-const char *storage::print_list() {
+const char *storage::print_list(alist *list) {
lock_guard lg(mutex);
*list_str = 0;
return quote_string(list_str, tmp.addr());
}
+const char *storage::print_origin_list() {
+ return print_list(origin_list);
+}
+
+const char *storage::print_possible_list() {
+ return print_list(list);
+}
+
void storage::dec_unused_stores() {
lock_guard lg(mutex);
STORE *tmp_store;
}
}
+void LeastUsedStore::apply_write_policy() {
+ return apply_policy(true);
+}
+
+void LeastUsedStore::apply_read_policy() {
+ return apply_policy(false);
+}
StorageManager::StorageManager(const char *policy) {
this->policy = bstrdup(policy);
return rstore.get_list();
}
+alist *StorageManager::get_origin_rstore_list() {
+ return rstore.get_origin_list();
+}
+
const char *StorageManager::get_rsource() const {
return rstore.get_source();
}
return wstore.get_list();
}
+alist *StorageManager::get_origin_wstore_list() {
+ return wstore.get_origin_list();
+}
+
const char *StorageManager::get_wsource() const {
return wstore.get_source();
}
rstore.reset();
}
-const char *StorageManager::print_rlist() {
- return rstore.print_list();
+const char *StorageManager::print_possible_rlist() {
+ return rstore.print_possible_list();
+}
+
+const char *StorageManager::print_origin_rlist() {
+ return rstore.print_origin_list();
}
bool StorageManager::set_current_wstorage(STORE *storage) {
wstore.reset();
}
-const char *StorageManager::print_wlist() {
- return wstore.print_list();
+const char *StorageManager::print_possible_wlist() {
+ return wstore.print_possible_list();
+}
+
+const char *StorageManager::print_origin_wlist() {
+ return wstore.print_origin_list();
}
void StorageManager::reset_rwstorage() {
private:
bool write; /* Write or read storage */
STORE *store; /* Selected storage to be used */
+ alist *origin_list; /* Configured Storage (raw list without any policy applied) */
alist *list; /* Storage possibilities */
POOLMEM *source; /* Where the storage came from */
POOLMEM *list_str; /* List of storage names in the list */
/* Only when we are a write storage - increment concurrent write counters for all storages on the list */
bool inc_wstores(JCR *jcr);
+
+ const char *print_list(alist *list);
+
public:
storage();
return store;
}
- /* Get list of all possible storages */
+ /* Get list of all possible storages.
+ * This metod can possibly return list with less storages than the original group.
+ * It's because some of it's elements can ba unavailable at that time (e.g. reached maxConcJobs limit). */
alist *get_list();
+ /* Get original list of all storages as assigned by the set() method. */
+ alist *get_origin_list();
+
/* Get source of the storage (pool, job, commandline, unknown, ...) */
const char *get_source() const;
void dec_curr_store();
/* Print all elements of the list (sample result of print_list() -> "File1, File2, File3" */
- const char *print_list();
+ const char *print_origin_list();
+ const char *print_possible_list();
};
storage rstore; /* Read storage */
storage wstore; /* Write storage */
const char *policy; /* Storage Group Policy used */
+ virtual void apply_policy(bool write_store) = 0;
public:
- virtual void apply_policy(bool write_store) = 0;
+ virtual void apply_write_policy() = 0;
+ virtual void apply_read_policy() = 0;
virtual ~StorageManager() {
reset_rwstorage();
alist *get_rstore_list();
+ alist *get_origin_rstore_list();
+
const char *get_rsource() const;
const char *get_rmedia_type() const;
void dec_read_stores();
- const char *print_rlist();
+ const char *print_possible_rlist();
+ const char *print_origin_rlist();
/************ WRITE STORAGE HELPERS ************/
STORE *get_wstore() {
alist *get_wstore_list();
+ alist *get_origin_wstore_list();
+
const char *get_wsource() const;
const char *get_wmedia_type() const;
void reset_wstorage();
- const char *print_wlist();
+ const char *print_possible_wlist();
+ const char *print_origin_wlist();
bool inc_write_stores(JCR *jcr);
* Least used policy chooses storage from the list which has the least concurrent jobs number.
*/
class LeastUsedStore : public StorageManager {
- public:
+ private:
void apply_policy(bool write_store);
+ public:
+ void apply_write_policy();
+ void apply_read_policy();
LeastUsedStore() : StorageManager("LeastUsed") {
}
*/
class ListedOrderStore : public StorageManager {
private:
-
- public:
void apply_policy(bool write_store) {
/* Do nothing for now */
}
+ public:
+ void apply_write_policy() {
+ return apply_policy(true);
+ }
+ void apply_read_policy() {
+ return apply_policy(false);
+ }
ListedOrderStore(): StorageManager("ListedOrder") {
}