@@ -31,12 +31,12 @@ bool HasValidNodeIds(const ClusterShardInfos& new_config) {
31
31
32
32
for (const auto & shard : new_config) {
33
33
if (!CheckAndInsertNode (shard.master .id )) {
34
- LOG (WARNING ) << " Master " << shard.master .id << " appears more than once" ;
34
+ LOG (ERROR ) << " Master " << shard.master .id << " appears more than once" ;
35
35
return false ;
36
36
}
37
37
for (const auto & replica : shard.replicas ) {
38
38
if (!CheckAndInsertNode (replica.id )) {
39
- LOG (WARNING ) << " Replica " << replica.id << " appears more than once" ;
39
+ LOG (ERROR ) << " Replica " << replica.id << " appears more than once" ;
40
40
return false ;
41
41
}
42
42
}
@@ -56,21 +56,21 @@ bool IsConfigValid(const ClusterShardInfos& new_config) {
56
56
for (const auto & shard : new_config) {
57
57
for (const auto & slot_range : shard.slot_ranges ) {
58
58
if (slot_range.start > slot_range.end ) {
59
- LOG (WARNING ) << " Invalid cluster config: start=" << slot_range.start
60
- << " is larger than end=" << slot_range.end ;
59
+ LOG (ERROR ) << " Invalid cluster config: start=" << slot_range.start
60
+ << " is larger than end=" << slot_range.end ;
61
61
return false ;
62
62
}
63
63
64
64
for (SlotId slot = slot_range.start ; slot <= slot_range.end ; ++slot) {
65
65
if (slot >= slots_found.size ()) {
66
- LOG (WARNING ) << " Invalid cluster config: slot=" << slot
67
- << " is bigger than allowed max=" << slots_found.size ();
66
+ LOG (ERROR ) << " Invalid cluster config: slot=" << slot
67
+ << " is bigger than allowed max=" << slots_found.size ();
68
68
return false ;
69
69
}
70
70
71
71
if (slots_found[slot]) {
72
- LOG (WARNING ) << " Invalid cluster config: slot=" << slot
73
- << " was already configured by another slot range." ;
72
+ LOG (ERROR ) << " Invalid cluster config: slot=" << slot
73
+ << " was already configured by another slot range." ;
74
74
return false ;
75
75
}
76
76
@@ -80,7 +80,7 @@ bool IsConfigValid(const ClusterShardInfos& new_config) {
80
80
}
81
81
82
82
if (!all_of (slots_found.begin (), slots_found.end (), [](bool b) { return b; }) > 0UL ) {
83
- LOG (WARNING ) << " Invalid cluster config: some slots were missing." ;
83
+ LOG (ERROR ) << " Invalid cluster config: some slots were missing." ;
84
84
return false ;
85
85
}
86
86
@@ -129,7 +129,7 @@ constexpr string_view kInvalidConfigPrefix = "Invalid JSON cluster config: "sv;
129
129
130
130
template <typename T> optional<T> ReadNumeric (const JsonType& obj) {
131
131
if (!obj.is_number ()) {
132
- LOG (WARNING ) << kInvalidConfigPrefix << " object is not a number " << obj;
132
+ LOG (ERROR ) << kInvalidConfigPrefix << " object is not a number " << obj;
133
133
return nullopt;
134
134
}
135
135
@@ -138,15 +138,15 @@ template <typename T> optional<T> ReadNumeric(const JsonType& obj) {
138
138
139
139
optional<SlotRanges> GetClusterSlotRanges (const JsonType& slots) {
140
140
if (!slots.is_array ()) {
141
- LOG (WARNING ) << kInvalidConfigPrefix << " slot_ranges is not an array " << slots;
141
+ LOG (ERROR ) << kInvalidConfigPrefix << " slot_ranges is not an array " << slots;
142
142
return nullopt;
143
143
}
144
144
145
145
std::vector<SlotRange> ranges;
146
146
147
147
for (const auto & range : slots.array_range ()) {
148
148
if (!range.is_object ()) {
149
- LOG (WARNING ) << kInvalidConfigPrefix << " slot_ranges element is not an object " << range;
149
+ LOG (ERROR ) << kInvalidConfigPrefix << " slot_ranges element is not an object " << range;
150
150
return nullopt;
151
151
}
152
152
@@ -164,7 +164,7 @@ optional<SlotRanges> GetClusterSlotRanges(const JsonType& slots) {
164
164
165
165
optional<ClusterExtendedNodeInfo> ParseClusterNode (const JsonType& json) {
166
166
if (!json.is_object ()) {
167
- LOG (WARNING ) << kInvalidConfigPrefix << " node config is not an object " << json;
167
+ LOG (ERROR ) << kInvalidConfigPrefix << " node config is not an object " << json;
168
168
return nullopt;
169
169
}
170
170
@@ -173,7 +173,7 @@ optional<ClusterExtendedNodeInfo> ParseClusterNode(const JsonType& json) {
173
173
{
174
174
auto id = json.at_or_null (" id" );
175
175
if (!id.is_string ()) {
176
- LOG (WARNING ) << kInvalidConfigPrefix << " invalid id for node " << json;
176
+ LOG (ERROR ) << kInvalidConfigPrefix << " invalid id for node " << json;
177
177
return nullopt;
178
178
}
179
179
node.id = std::move (id).as_string ();
@@ -182,7 +182,7 @@ optional<ClusterExtendedNodeInfo> ParseClusterNode(const JsonType& json) {
182
182
{
183
183
auto ip = json.at_or_null (" ip" );
184
184
if (!ip.is_string ()) {
185
- LOG (WARNING ) << kInvalidConfigPrefix << " invalid ip for node " << json;
185
+ LOG (ERROR ) << kInvalidConfigPrefix << " invalid ip for node " << json;
186
186
return nullopt;
187
187
}
188
188
node.ip = std::move (ip).as_string ();
@@ -200,7 +200,7 @@ optional<ClusterExtendedNodeInfo> ParseClusterNode(const JsonType& json) {
200
200
auto health = json.at_or_null (" health" );
201
201
if (!health.is_null ()) {
202
202
if (!health.is_string ()) {
203
- LOG (WARNING ) << kInvalidConfigPrefix << " invalid health status for node " << json;
203
+ LOG (ERROR ) << kInvalidConfigPrefix << " invalid health status for node " << json;
204
204
} else {
205
205
auto health_str = std::move (health).as_string ();
206
206
if (absl::EqualsIgnoreCase (health_str, " FAIL" )) {
@@ -209,8 +209,10 @@ optional<ClusterExtendedNodeInfo> ParseClusterNode(const JsonType& json) {
209
209
node.health = NodeHealth::LOADING;
210
210
} else if (absl::EqualsIgnoreCase (health_str, " ONLINE" )) {
211
211
node.health = NodeHealth::ONLINE;
212
+ } else if (absl::EqualsIgnoreCase (health_str, " HIDDEN" )) {
213
+ node.health = NodeHealth::HIDDEN;
212
214
} else {
213
- LOG (WARNING ) << kInvalidConfigPrefix << " invalid health status for node: " << health_str;
215
+ LOG (ERROR ) << kInvalidConfigPrefix << " invalid health status for node: " << health_str;
214
216
}
215
217
}
216
218
}
@@ -237,7 +239,7 @@ optional<std::vector<MigrationInfo>> ParseMigrations(const JsonType& json) {
237
239
auto slots = GetClusterSlotRanges (element.at_or_null (" slot_ranges" ));
238
240
239
241
if (!node_id.is_string () || !ip.is_string () || !port || !slots) {
240
- LOG (WARNING ) << kInvalidConfigPrefix << " invalid migration json " << json;
242
+ LOG (ERROR ) << kInvalidConfigPrefix << " invalid migration json " << json;
241
243
return nullopt;
242
244
}
243
245
@@ -253,15 +255,15 @@ optional<ClusterShardInfos> BuildClusterConfigFromJson(const JsonType& json) {
253
255
std::vector<ClusterShardInfo> config;
254
256
255
257
if (!json.is_array ()) {
256
- LOG (WARNING ) << kInvalidConfigPrefix << " not an array " << json;
258
+ LOG (ERROR ) << kInvalidConfigPrefix << " not an array " << json;
257
259
return nullopt;
258
260
}
259
261
260
262
for (const auto & element : json.array_range ()) {
261
263
ClusterShardInfo shard;
262
264
263
265
if (!element.is_object ()) {
264
- LOG (WARNING ) << kInvalidConfigPrefix << " shard element is not an object " << element;
266
+ LOG (ERROR ) << kInvalidConfigPrefix << " shard element is not an object " << element;
265
267
return nullopt;
266
268
}
267
269
@@ -279,7 +281,7 @@ optional<ClusterShardInfos> BuildClusterConfigFromJson(const JsonType& json) {
279
281
280
282
auto replicas = element.at_or_null (" replicas" );
281
283
if (!replicas.is_array ()) {
282
- LOG (WARNING ) << kInvalidConfigPrefix << " replicas is not an array " << replicas;
284
+ LOG (ERROR ) << kInvalidConfigPrefix << " replicas is not an array " << replicas;
283
285
return nullopt;
284
286
}
285
287
@@ -309,7 +311,7 @@ shared_ptr<ClusterConfig> ClusterConfig::CreateFromConfig(string_view my_id,
309
311
std::string_view json_str) {
310
312
optional<JsonType> json_config = JsonFromString (json_str, PMR_NS::get_default_resource ());
311
313
if (!json_config.has_value ()) {
312
- LOG (WARNING ) << " Can't parse JSON for ClusterConfig " << json_str;
314
+ LOG (ERROR ) << " Can't parse JSON for ClusterConfig " << json_str;
313
315
return nullptr ;
314
316
}
315
317
0 commit comments