forked from irods/irods_capability_storage_tiering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_tiering_configuration.cpp
104 lines (83 loc) · 5.32 KB
/
storage_tiering_configuration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "storage_tiering_configuration.hpp"
#include <irods/irods_server_properties.hpp>
namespace irods {
storage_tiering_configuration::storage_tiering_configuration(
const std::string& _instance_name ) :
instance_name{_instance_name} {
bool success_flag = false;
try {
const auto& rule_engines = get_server_property<
const nlohmann::json&>(
std::vector<std::string>{
KW_CFG_PLUGIN_CONFIGURATION,
KW_CFG_PLUGIN_TYPE_RULE_ENGINE});
for ( const auto& rule_engine : rule_engines ) {
const auto& inst_name = rule_engine.at( KW_CFG_INSTANCE_NAME).get_ref<const std::string&>();
if ( inst_name == _instance_name ) {
if(rule_engine.count(KW_CFG_PLUGIN_SPECIFIC_CONFIGURATION) > 0) {
const auto& plugin_spec_cfg = rule_engine.at(KW_CFG_PLUGIN_SPECIFIC_CONFIGURATION);
if(plugin_spec_cfg.find("access_time_attribute") != plugin_spec_cfg.end()) {
access_time_attribute = plugin_spec_cfg.at("access_time_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("group_attribute") != plugin_spec_cfg.end()) {
group_attribute = plugin_spec_cfg.at("group_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("time_attribute") != plugin_spec_cfg.end()) {
time_attribute = plugin_spec_cfg.at("time_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("query_attribute") != plugin_spec_cfg.end()) {
query_attribute = plugin_spec_cfg.at("query_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("verification_attribute") != plugin_spec_cfg.end()) {
verification_attribute = plugin_spec_cfg.at("verification_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("data_movement_parameters_attribute") != plugin_spec_cfg.end()) {
data_movement_parameters_attribute = plugin_spec_cfg.at("data_movement_parameters_attribute").get<std::string>();
}
if(plugin_spec_cfg.find("minimum_restage_tier") != plugin_spec_cfg.end()) {
minimum_restage_tier = plugin_spec_cfg.at("minimum_restage_tier").get<std::string>();
}
if(plugin_spec_cfg.find("preserve_replicas") != plugin_spec_cfg.end()) {
preserve_replicas = plugin_spec_cfg.at("preserve_replicas").get<std::string>();
}
if(plugin_spec_cfg.find("object_limit") != plugin_spec_cfg.end()) {
object_limit = plugin_spec_cfg.at("object_limit").get<std::string>();
}
if(plugin_spec_cfg.find("default_data_movement_parameters") != plugin_spec_cfg.end()) {
default_data_movement_parameters = plugin_spec_cfg.at("default_data_movement_parameters").get<std::string>();
}
if(plugin_spec_cfg.find("minimum_delay_time") != plugin_spec_cfg.end()) {
default_data_movement_parameters = plugin_spec_cfg.at("minimum_delay_time").get<std::string>();
}
if(plugin_spec_cfg.find("maximum_delay_time") != plugin_spec_cfg.end()) {
default_data_movement_parameters = plugin_spec_cfg.at("maximum_delay_time").get<std::string>();
}
if(plugin_spec_cfg.find("time_check_string") != plugin_spec_cfg.end()) {
time_check_string = plugin_spec_cfg.at("time_check_string").get<std::string>();
}
if(plugin_spec_cfg.find("number_of_scheduling_threads") != plugin_spec_cfg.end()) {
number_of_scheduling_threads = plugin_spec_cfg.at("number_of_scheduling_threads").get<int>();
}
if(plugin_spec_cfg.find(data_transfer_log_level_key) != plugin_spec_cfg.end()) {
const std::string& val = plugin_spec_cfg.at(data_transfer_log_level_key).get_ref<const std::string&>();
if("LOG_NOTICE" == val) {
data_transfer_log_level_value = LOG_NOTICE;
}
}
}
success_flag = true;
} // if inst_name
} // for rule_engines
} catch ( const boost::bad_any_cast& e ) {
THROW( INVALID_ANY_CAST, e.what() );
} catch ( const std::out_of_range& e ) {
THROW( KEY_NOT_FOUND, e.what() );
}
if(!success_flag) {
THROW(
SYS_INVALID_INPUT_PARAM,
boost::format("failed to find configuration for storage_tiering plugin [%s]") %
_instance_name);
}
} // ctor storage_tiering_configuration
} // namepsace irods