-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
TrackWarnings.java
108 lines (91 loc) · 3.74 KB
/
TrackWarnings.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
/*
* 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.config;
import org.apache.cassandra.exceptions.ConfigurationException;
public class TrackWarnings
{
public volatile boolean enabled = false; // should set to true in 4.2
public final LongByteThreshold coordinator_read_size = new LongByteThreshold();
public final LongByteThreshold local_read_size = new LongByteThreshold();
public final IntByteThreshold row_index_size = new IntByteThreshold();
public void validate(String prefix)
{
prefix += ".";
coordinator_read_size.validate(prefix + "coordinator_read_size");
local_read_size.validate(prefix + "local_read_size");
row_index_size.validate(prefix + "row_index_size");
}
public static class LongByteThreshold
{
public volatile long warn_threshold_kb = 0;
public volatile long abort_threshold_kb = 0;
public long getWarnThresholdKb()
{
return warn_threshold_kb;
}
public void setWarnThresholdKb(long value)
{
warn_threshold_kb = Math.max(value, 0);
}
public long getAbortThresholdKb()
{
return abort_threshold_kb;
}
public void setAbortThresholdKb(long value)
{
abort_threshold_kb = Math.max(value, 0);
}
public void validate(String prefix)
{
warn_threshold_kb = Math.max(warn_threshold_kb, 0);
abort_threshold_kb = Math.max(abort_threshold_kb, 0);
if (abort_threshold_kb != 0 && abort_threshold_kb < warn_threshold_kb)
throw new ConfigurationException(String.format("abort_threshold_kb (%d) must be greater than or equal to warn_threshold_kb (%d); see %s",
abort_threshold_kb, warn_threshold_kb, prefix));
}
}
public static class IntByteThreshold
{
public volatile int warn_threshold_kb = 0;
public volatile int abort_threshold_kb = 0;
public int getWarnThresholdKb()
{
return warn_threshold_kb;
}
public void setWarnThresholdKb(int value)
{
warn_threshold_kb = Math.max(value, 0);
}
public int getAbortThresholdKb()
{
return abort_threshold_kb;
}
public void setAbortThresholdKb(int value)
{
abort_threshold_kb = Math.max(value, 0);
}
public void validate(String prefix)
{
warn_threshold_kb = Math.max(warn_threshold_kb, 0);
abort_threshold_kb = Math.max(abort_threshold_kb, 0);
if (abort_threshold_kb != 0 && abort_threshold_kb < warn_threshold_kb)
throw new ConfigurationException(String.format("abort_threshold_kb (%d) must be greater than or equal to warn_threshold_kb (%d); see %s",
abort_threshold_kb, warn_threshold_kb, prefix));
}
}
}