Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add soft/hard limits to local reads to protect against reading too mu…
…ch data in a single query patch by David Capwell; reviewed by Caleb Rackliffe and Marcus Eriksson for CASSANDRA-16896
- Loading branch information
Showing
66 changed files
with
2,813 additions
and
570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/java/org/apache/cassandra/config/TrackWarnings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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)); | ||
} | ||
} | ||
} |
Oops, something went wrong.