Default ctor. If a file location is given, it will be read on construction and reloaded every interval seconds. Note that if there is a problem reading or parsing the config file (when set) the ctor will continue loading with the defaults and if an interval is set, will attempt to reload at a later
(final TSDB tsdb)
| 88 | * @throws IllegalArgumentException if the default limits are less than zero. |
| 89 | */ |
| 90 | public QueryLimitOverride(final TSDB tsdb) { |
| 91 | overrides = Maps.newConcurrentMap(); |
| 92 | default_byte_limit = tsdb.getConfig().getLong("tsd.query.limits.bytes.default"); |
| 93 | default_data_points_limit = tsdb.getConfig() |
| 94 | .getLong("tsd.query.limits.data_points.default"); |
| 95 | if (tsdb.getConfig().hasProperty("tsd.query.limits.overrides.interval")) { |
| 96 | reload_interval = tsdb.getConfig().getInt("tsd.query.limits.overrides.interval"); |
| 97 | } else { |
| 98 | reload_interval = 0; |
| 99 | } |
| 100 | file_location = tsdb.getConfig().getString("tsd.query.limits.overrides.config"); |
| 101 | timer = (HashedWheelTimer) tsdb.getTimer(); |
| 102 | if (default_byte_limit < 0) { |
| 103 | throw new IllegalArgumentException("The default byte limit cannot be negative"); |
| 104 | } |
| 105 | if (default_data_points_limit < 0) { |
| 106 | throw new IllegalArgumentException("The default data points limit cannot" |
| 107 | + " be negative"); |
| 108 | } |
| 109 | |
| 110 | if (!Strings.isNullOrEmpty(file_location)) { |
| 111 | loadFromFile(); |
| 112 | if (reload_interval > 0) { |
| 113 | timer.newTimeout(this, reload_interval, TimeUnit.SECONDS); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** @return The default byte limit used when a match fails */ |
| 119 | public long getDefaultByteLimit() { |
nothing calls this directly
no test coverage detected