-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
GuardrailsMBean.java
654 lines (551 loc) · 24 KB
/
GuardrailsMBean.java
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.db.guardrails;
import java.util.Set;
import javax.annotation.Nullable;
/**
* JMX entrypoint for updating the default guardrails configuration parsed from {@code cassandra.yaml}.
* <p>
* This is different to just exposing {@link GuardrailsConfig} in that the methods here should be JMX-friendly.
*
* <p>For consistency, guardrails based on a simple numeric threshold should use the naming scheme
* {@code <whatIsGuarded>WarnThreshold} for soft limits and {@code <whatIsGuarded>FailThreshold} for hard
* ones, and if the value has a unit, that unit should be added at the end (for instance,
* {@code <whatIsGuarded>FailThresholdInKb}). For "boolean" guardrails that disable a feature, use
* {@code <whatIsGuardedEnabled}. Other type of guardrails can use appropriate suffixes but should start with
* {@code <whatIsGuarded>}.
*/
public interface GuardrailsMBean
{
/**
* @return The threshold to warn when creating more user keyspaces than threshold.
* -1 means disabled.
*/
int getKeyspacesWarnThreshold();
/**
* @return The threshold to prevent creating more user keyspaces than threshold.
* -1 means disabled.
*/
int getKeyspacesFailThreshold();
/**
* @param warn The threshold to warn when creating more user keyspaces than threshold. -1 means disabled.
* @param fail The threshold to prevent creating more user keyspaces than threshold. -1 means disabled.
*/
void setKeyspacesThreshold(int warn, int fail);
/**
* @return The threshold to warn when creating more tables than threshold.
* -1 means disabled.
*/
int getTablesWarnThreshold();
/**
* @return The threshold to prevent creating more tables than threshold.
* -1 means disabled.
*/
int getTablesFailThreshold();
/**
* @param warn The threshold to warn when creating more tables than threshold. -1 means disabled.
* @param fail The threshold to prevent creating more tables than threshold. -1 means disabled.
*/
void setTablesThreshold(int warn, int fail);
/**
* @return The threshold to warn when having more columns per table than threshold.
* -1 means disabled.
*/
int getColumnsPerTableWarnThreshold();
/**
* @return The threshold to prevent having more columns per table than threshold. -1 means disabled.
*/
int getColumnsPerTableFailThreshold();
/**
* @param warn The threshold to warn when having more columns per table than threshold. -1 means disabled.
* @param fail The threshold to prevent having more columns per table than threshold. -1 means disabled.
*/
void setColumnsPerTableThreshold(int warn, int fail);
/**
* @return The threshold to warn when creating more secondary indexes per table than threshold. -1 means disabled.
*/
int getSecondaryIndexesPerTableWarnThreshold();
/**
* @return The threshold to prevent creating more secondary indexes per table than threshold. -1 means disabled.
*/
int getSecondaryIndexesPerTableFailThreshold();
/**
* @param warn The threshold to warn when creating more secondary indexes per table than threshold. -1 means disabled.
* @param fail The threshold to prevent creating more secondary indexes per table than threshold. -1 means disabled.
*/
void setSecondaryIndexesPerTableThreshold(int warn, int fail);
/**
* @return Whether secondary index creation is active or not on the node
*/
boolean getSecondaryIndexesEnabled();
/**
* Enables or disables the ability to create secondary indexes
*
* @param enabled
*/
void setSecondaryIndexesEnabled(boolean enabled);
/**
* @return The threshold to warn when creating more materialized views per table than threshold.
* -1 means disabled.
*/
int getMaterializedViewsPerTableWarnThreshold();
/**
* @return The threshold to prevent creating more materialized views per table than threshold.
* -1 means disabled.
*/
int getMaterializedViewsPerTableFailThreshold();
/**
* @param warn The threshold to warn when creating more materialized views per table than threshold. -1 means disabled.
* @param fail The threshold to prevent creating more materialized views per table than threshold. -1 means disabled.
*/
void setMaterializedViewsPerTableThreshold(int warn, int fail);
/**
* @return properties that are warned about when creating or altering a table.
*/
Set<String> getTablePropertiesWarned();
/**
* @return Comma-separated list of properties that are warned about when creating or altering a table.
*/
String getTablePropertiesWarnedCSV();
/**
* @param properties properties that are warned about when creating or altering a table.
*/
void setTablePropertiesWarned(Set<String> properties);
/**
* @param properties Comma-separated list of properties that are warned about when creating or altering a table.
*/
void setTablePropertiesWarnedCSV(String properties);
/**
* @return properties that are not allowed when creating or altering a table.
*/
Set<String> getTablePropertiesDisallowed();
/**
* @return Comma-separated list of properties that are not allowed when creating or altering a table.
*/
String getTablePropertiesDisallowedCSV();
/**
* @param properties properties that are not allowed when creating or altering a table.
*/
void setTablePropertiesDisallowed(Set<String> properties);
/**
* @param properties Comma-separated list of properties that are not allowed when creating or altering a table.
*/
void setTablePropertiesDisallowedCSV(String properties);
/**
* @return properties that are ignored when creating or altering a table.
*/
Set<String> getTablePropertiesIgnored();
/**
* @return Comma-separated list of properties that are ignored when creating or altering a table.
*/
String getTablePropertiesIgnoredCSV();
/**
* @param properties properties that are ignored when creating or altering a table.
*/
void setTablePropertiesIgnored(Set<String> properties);
/**
* @param properties Comma-separated list of properties that are ignored when creating or altering a table.
*/
void setTablePropertiesIgnoredCSV(String properties);
/**
* Returns whether user-provided timestamps are allowed.
*
* @return {@code true} if user-provided timestamps are allowed, {@code false} otherwise.
*/
boolean getUserTimestampsEnabled();
/**
* Sets whether user-provided timestamps are allowed.
*
* @param enabled {@code true} if user-provided timestamps are allowed, {@code false} otherwise.
*/
void setUserTimestampsEnabled(boolean enabled);
/**
* Returns whether ALLOW FILTERING property is allowed.
*
* @return {@code true} if ALLOW FILTERING is allowed, {@code false} otherwise.
*/
boolean getAllowFilteringEnabled();
/**
* Sets whether ALLOW FILTERING is allowed.
*
* @param enabled {@code true} if ALLOW FILTERING is allowed, {@code false} otherwise.
*/
void setAllowFilteringEnabled(boolean enabled);
/**
* Returns whether SimpleStrategy is allowed on keyspace creation or alteration
*
* @return {@code true} if SimpleStrategy is allowed; {@code false} otherwise
*/
boolean getSimpleStrategyEnabled();
/**
* Sets whether SimpleStrategy is allowed on keyspace creation or alteration
*
* @param enabled {@code true} if SimpleStrategy is allowed, {@code false} otherwise.
*/
void setSimpleStrategyEnabled(boolean enabled);
/**
* Returns whether users can disable compression on tables
*
* @return {@code true} if users can disable compression on a table, {@code false} otherwise.
*/
boolean getUncompressedTablesEnabled();
/**
* Sets whether users can disable compression on tables
*
* @param enabled {@code true} if users can disable compression on a table, {@code false} otherwise.
*/
void setUncompressedTablesEnabled(boolean enabled);
/**
* Returns whether users can create new COMPACT STORAGE tables
*
* @return {@code true} if allowed, {@code false} otherwise.
*/
boolean getCompactTablesEnabled();
/**
* Sets whether users can create new COMPACT STORAGE tables
*
* @param enabled {@code true} if allowed, {@code false} otherwise.
*/
void setCompactTablesEnabled(boolean enabled);
/**
* Gets whether users can use the ALTER TABLE statement to change columns
*
* @return {@code true} if ALTER TABLE is allowed, {@code false} otherwise.
*/
boolean getAlterTableEnabled();
/**
* Sets whether users can use the ALTER TABLE statement to change columns
*
* @param enabled {@code true} if changing columns is allowed, {@code false} otherwise.
*/
void setAlterTableEnabled(boolean enabled);
/**
* Returns whether GROUP BY queries are allowed.
*
* @return {@code true} if allowed, {@code false} otherwise.
*/
boolean getGroupByEnabled();
/**
* Sets whether GROUP BY queries are allowed.
*
* @param enabled {@code true} if allowed, {@code false} otherwise.
*/
void setGroupByEnabled(boolean enabled);
/**
* Returns whether users can TRUNCATE or DROP TABLE
*
* @return {@code true} if allowed, {@code false} otherwise.
*/
boolean getDropTruncateTableEnabled();
/**
* Sets whether users can TRUNCATE or DROP TABLE
*/
void setDropTruncateTableEnabled(boolean enabled);
/**
* Returns whether users can DROP a keyspace
*
* @return {@code true} if allowed, {@code false} otherwise.
*/
boolean getDropKeyspaceEnabled();
/**
* Sets whether users can DROP a keyspace
*/
void setDropKeyspaceEnabled(boolean enabled);
/**
* @return The threshold to warn when requested page size greater than threshold.
* -1 means disabled.
*/
int getPageSizeWarnThreshold();
/**
* @return The threshold to prevent requesting page with more elements than threshold.
* -1 means disabled.
*/
int getPageSizeFailThreshold();
/**
* @param warn The threshold to warn when the requested page size is greater than threshold. -1 means disabled.
* @param fail The threshold to prevent requesting pages with more elements than threshold. -1 means disabled.
*/
void setPageSizeThreshold(int warn, int fail);
/**
* Returns whether list operations that require read before write are allowed.
*
* @return {@code true} if list operations that require read before write are allowed, {@code false} otherwise.
*/
boolean getReadBeforeWriteListOperationsEnabled();
/**
* Sets whether list operations that require read before write are allowed.
*
* @param enabled {@code true} if list operations that require read before write are allowed, {@code false} otherwise.
*/
void setReadBeforeWriteListOperationsEnabled(boolean enabled);
/**
* @return The threshold to warn when the number of partition keys in a select statement greater than threshold.
* -1 means disabled.
*/
int getPartitionKeysInSelectWarnThreshold();
/**
* @return The threshold to fail when the number of partition keys in a select statement greater than threshold.
* -1 means disabled.
*/
int getPartitionKeysInSelectFailThreshold();
/**
* @param warn The threshold to warn when the number of partition keys in a select statement is greater than
* threshold -1 means disabled.
* @param fail The threshold to prevent when the number of partition keys in a select statement is more than
* threshold -1 means disabled.
*/
void setPartitionKeysInSelectThreshold(int warn, int fail);
/**
* @return The threshold to warn when an IN query creates a cartesian product with a size exceeding threshold.
* -1 means disabled.
*/
public int getInSelectCartesianProductWarnThreshold();
/**
* @return The threshold to prevent IN queries creating a cartesian product with a size exceeding threshold.
* -1 means disabled.
*/
public int getInSelectCartesianProductFailThreshold();
/**
* @param warn The threshold to warn when an IN query creates a cartesian product with a size exceeding threshold.
* -1 means disabled.
* @param fail The threshold to prevent IN queries creating a cartesian product with a size exceeding threshold.
* -1 means disabled.
*/
public void setInSelectCartesianProductThreshold(int warn, int fail);
/**
* @return consistency levels that are warned about when reading.
*/
Set<String> getReadConsistencyLevelsWarned();
/**
* @return Comma-separated list of consistency levels that are warned about when reading.
*/
String getReadConsistencyLevelsWarnedCSV();
/**
* @param consistencyLevels consistency levels that are warned about when reading.
*/
void setReadConsistencyLevelsWarned(Set<String> consistencyLevels);
/**
* @param consistencyLevels Comma-separated list of consistency levels that are warned about when reading.
*/
void setReadConsistencyLevelsWarnedCSV(String consistencyLevels);
/**
* @return consistency levels that are not allowed when reading.
*/
Set<String> getReadConsistencyLevelsDisallowed();
/**
* @return Comma-separated list of consistency levels that are not allowed when reading.
*/
String getReadConsistencyLevelsDisallowedCSV();
/**
* @param consistencyLevels consistency levels that are not allowed when reading.
*/
void setReadConsistencyLevelsDisallowed(Set<String> consistencyLevels);
/**
* @param consistencyLevels Comma-separated list of consistency levels that are not allowed when reading.
*/
void setReadConsistencyLevelsDisallowedCSV(String consistencyLevels);
/**
* @return consistency levels that are warned about when writing.
*/
Set<String> getWriteConsistencyLevelsWarned();
/**
* @return Comma-separated list of consistency levels that are warned about when writing.
*/
String getWriteConsistencyLevelsWarnedCSV();
/**
* @param consistencyLevels consistency levels that are warned about when writing.
*/
void setWriteConsistencyLevelsWarned(Set<String> consistencyLevels);
/**
* @param consistencyLevels Comma-separated list of consistency levels that are warned about when writing.
*/
void setWriteConsistencyLevelsWarnedCSV(String consistencyLevels);
/**
* @return consistency levels that are not allowed when writing.
*/
Set<String> getWriteConsistencyLevelsDisallowed();
/**
* @return Comma-separated list of consistency levels that are not allowed when writing.
*/
String getWriteConsistencyLevelsDisallowedCSV();
/**
* @param consistencyLevels consistency levels that are not allowed when writing.
*/
void setWriteConsistencyLevelsDisallowed(Set<String> consistencyLevels);
/**
* @param consistencyLevels Comma-separated list of consistency levels that are not allowed when writing.
*/
void setWriteConsistencyLevelsDisallowedCSV(String consistencyLevels);
/**
* @return The threshold to warn when encountering column values larger than threshold, as a string formatted as
* in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null} value means disabled.
*/
@Nullable
String getColumnValueSizeWarnThreshold();
/**
* @return The threshold to prevent column values larger than threshold, as a string formatted as in, for example,
* {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null} value means disabled.
*/
@Nullable
String getColumnValueSizeFailThreshold();
/**
* @param warnSize The threshold to warn when encountering column values larger than threshold, as a string
* formatted as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}.
* A {@code null} value means disabled.
* @param failSize The threshold to prevent column values larger than threshold, as a string formatted as in, for
* example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}.
* A {@code null} value means disabled.
*/
void setColumnValueSizeThreshold(@Nullable String warnSize, @Nullable String failSize);
/**
* @return The threshold to warn when encountering larger size of collection data than threshold, as a string
* formatted as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null} value
* means that the threshold is disabled.
*/
@Nullable
String getCollectionSizeWarnThreshold();
/**
* @return The threshold to prevent collections with larger data size than threshold, as a string formatted as in,
* for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null} value means that the
* threshold is disabled.
*/
@Nullable
String getCollectionSizeFailThreshold();
/**
* @param warnSize The threshold to warn when encountering larger size of collection data than threshold, as a
* string formatted as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}.
* A {@code null} value means disabled.
* @param failSize The threshold to prevent collections with larger data size than threshold, as a string formatted
* as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null}
* value means disabled.
*/
void setCollectionSizeThreshold(@Nullable String warnSize, @Nullable String failSize);
/**
* @return The threshold to warn when encountering more elements in a collection than threshold.
*/
int getItemsPerCollectionWarnThreshold();
/**
* @return The threshold to prevent collections with more elements than threshold.
*/
int getItemsPerCollectionFailThreshold();
/**
* @param warn The threshold to warn when encountering more elements in a collection than threshold.
* @param fail The threshold to prevent collectiosn with more elements than threshold.
*/
void setItemsPerCollectionThreshold(int warn, int fail);
/**
* @return The threshold to warn when creating a UDT with more fields than threshold. -1 means disabled.
*/
int getFieldsPerUDTWarnThreshold();
/**
* @return The threshold to fail when creating a UDT with more fields than threshold. -1 means disabled.
*/
int getFieldsPerUDTFailThreshold();
/**
* @param warn The threshold to warn when creating a UDT with more fields than threshold. -1 means disabled.
* @param fail The threshold to prevent creating a UDT with more fields than threshold. -1 means disabled.
*/
void setFieldsPerUDTThreshold(int warn, int fail);
/**
* @return The threshold to warn when local data disk usage percentage exceeds that threshold.
* Allowed values are in the range {@code [1, 100]}, and -1 means disabled.
*/
int getDataDiskUsagePercentageWarnThreshold();
/**
* @return The threshold to fail when local data disk usage percentage exceeds that threshold.
* Allowed values are in the range {@code [1, 100]}, and -1 means disabled.
*/
int getDataDiskUsagePercentageFailThreshold();
/**
* @param warn The threshold to warn when local disk usage percentage exceeds that threshold.
* Allowed values are in the range {@code [1, 100]}, and -1 means disabled.
* @param fail The threshold to fail when local disk usage percentage exceeds that threshold.
* Allowed values are in the range {@code [1, 100]}, and -1 means disabled.
*/
public void setDataDiskUsagePercentageThreshold(int warn, int fail);
/**
* @return The max disk size of the data directories when calculating disk usage thresholds, as a string formatted
* as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}. A {@code null} value means
* disabled.
*/
@Nullable
String getDataDiskUsageMaxDiskSize();
/**
* @param size The max disk size of the data directories when calculating disk usage thresholds, as a string
* formatted as in, for example, {@code 10GiB}, {@code 20MiB}, {@code 30KiB} or {@code 40B}.
* A {@code null} value means disabled.
*/
void setDataDiskUsageMaxDiskSize(@Nullable String size);
/**
* @return The threshold to warn when replication factor is lesser than threshold.
*/
int getMinimumReplicationFactorWarnThreshold();
/**
* @return The threshold to fail when replication factor is lesser than threshold.
*/
int getMinimumReplicationFactorFailThreshold();
/**
* @param warn The threshold to warn when the minimum replication factor is lesser than threshold.
* -1 means disabled.
* @param fail The threshold to fail when the minimum replication factor is lesser than threshold.
* -1 means disabled.
*/
void setMinimumReplicationFactorThreshold (int warn, int fail);
/**
* @return The threshold to fail when replication factor is greater than threshold.
*/
int getMaximumReplicationFactorWarnThreshold();
/**
* @return The threshold to fail when replication factor is greater than threshold.
*/
int getMaximumReplicationFactorFailThreshold();
/**
* @param warn The threshold to warn when the maximum replication factor is greater than threshold.
* -1 means disabled.
* @param fail The threshold to fail when the maximum replication factor is greater than threshold.
* -1 means disabled.
*/
void setMaximumReplicationFactorThreshold (int warn, int fail);
/**
* Returns whether warnings will be emitted when usage of 0 default TTL on a
* table with TimeWindowCompactionStrategy is detected.
*
* @return {@code true} if warnings will be emitted, {@code false} otherwise.
*/
boolean getZeroTTLOnTWCSWarned();
/**
* Sets whether warnings will be emitted when usage of 0 default TTL on a
* table with TimeWindowCompactionStrategy is detected.
*
* @param value {@code true} if warning will be emitted, {@code false} otherwise.
*/
void setZeroTTLOnTWCSWarned(boolean value);
/**
* Returns whether it is allowed to create or alter table to use 0 default TTL with TimeWindowCompactionStrategy.
* If it is not, such query will fail.
*
* @return {@code true} if 0 default TTL is allowed on TWCS table, {@code false} otherwise.
*/
boolean getZeroTTLOnTWCSEnabled();
/**
* Sets whether users can use 0 default TTL on a table with TimeWindowCompactionStrategy.
*
* @param value {@code true} if 0 default TTL on TWCS tables is allowed, {@code false} otherwise.
*/
void setZeroTTLOnTWCSEnabled(boolean value);
}