Package org.apache.cassandra.config
Class GuardrailsOptions
- java.lang.Object
-
- org.apache.cassandra.config.GuardrailsOptions
-
- All Implemented Interfaces:
GuardrailsConfig
public class GuardrailsOptions extends java.lang.Object implements GuardrailsConfig
Configuration settings for guardrails populated from the Yaml file.Note that the settings here must only be used to build the
GuardrailsConfigclass and not directly by the code checking each guarded constraint. That code should use the higher level abstractions defined inGuardrails).We have 2 variants of guardrails, soft (warn) and hard (fail) limits, each guardrail having either one of the variants or both. Note in particular that hard limits only make sense for guardrails triggering during query execution. For other guardrails, say one triggering during compaction, aborting that compaction does not make sense.
Additionally, each individual setting should have a specific value (typically -1 for numeric settings), that allows to disable the corresponding guardrail.
-
-
Constructor Summary
Constructors Constructor Description GuardrailsOptions(Config config)
-
Method Summary
-
-
-
Constructor Detail
-
GuardrailsOptions
public GuardrailsOptions(Config config)
-
-
Method Detail
-
getKeyspacesWarnThreshold
public int getKeyspacesWarnThreshold()
- Specified by:
getKeyspacesWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating more user keyspaces than threshold.
-
getKeyspacesFailThreshold
public int getKeyspacesFailThreshold()
- Specified by:
getKeyspacesFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating more user keyspaces than threshold.
-
setKeyspacesThreshold
public void setKeyspacesThreshold(int warn, int fail)
-
getTablesWarnThreshold
public int getTablesWarnThreshold()
- Specified by:
getTablesWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating more user tables than threshold.
-
getTablesFailThreshold
public int getTablesFailThreshold()
- Specified by:
getTablesFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating more user tables than threshold.
-
setTablesThreshold
public void setTablesThreshold(int warn, int fail)
-
getColumnsPerTableWarnThreshold
public int getColumnsPerTableWarnThreshold()
- Specified by:
getColumnsPerTableWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating more columns per table than threshold.
-
getColumnsPerTableFailThreshold
public int getColumnsPerTableFailThreshold()
- Specified by:
getColumnsPerTableFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating more columns per table than threshold.
-
setColumnsPerTableThreshold
public void setColumnsPerTableThreshold(int warn, int fail)
-
getSecondaryIndexesPerTableWarnThreshold
public int getSecondaryIndexesPerTableWarnThreshold()
- Specified by:
getSecondaryIndexesPerTableWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating more secondary indexes per table than threshold.
-
getSecondaryIndexesPerTableFailThreshold
public int getSecondaryIndexesPerTableFailThreshold()
- Specified by:
getSecondaryIndexesPerTableFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating more secondary indexes per table than threshold.
-
setSecondaryIndexesPerTableThreshold
public void setSecondaryIndexesPerTableThreshold(int warn, int fail)
-
getMaterializedViewsPerTableWarnThreshold
public int getMaterializedViewsPerTableWarnThreshold()
- Specified by:
getMaterializedViewsPerTableWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating more materialized views per table than threshold.
-
getPartitionKeysInSelectWarnThreshold
public int getPartitionKeysInSelectWarnThreshold()
- Specified by:
getPartitionKeysInSelectWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when partition keys in select more than threshold.
-
getPartitionKeysInSelectFailThreshold
public int getPartitionKeysInSelectFailThreshold()
- Specified by:
getPartitionKeysInSelectFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when partition keys in select more than threshold.
-
setPartitionKeysInSelectThreshold
public void setPartitionKeysInSelectThreshold(int warn, int fail)
-
getMaterializedViewsPerTableFailThreshold
public int getMaterializedViewsPerTableFailThreshold()
- Specified by:
getMaterializedViewsPerTableFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating more materialized views per table than threshold.
-
setMaterializedViewsPerTableThreshold
public void setMaterializedViewsPerTableThreshold(int warn, int fail)
-
getPageSizeWarnThreshold
public int getPageSizeWarnThreshold()
- Specified by:
getPageSizeWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when page size exceeds given size.
-
getPageSizeFailThreshold
public int getPageSizeFailThreshold()
- Specified by:
getPageSizeFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when page size exceeds given size.
-
setPageSizeThreshold
public void setPageSizeThreshold(int warn, int fail)
-
getTablePropertiesWarned
public java.util.Set<java.lang.String> getTablePropertiesWarned()
- Specified by:
getTablePropertiesWarnedin interfaceGuardrailsConfig- Returns:
- The table properties that are warned about when creating or altering a table.
-
setTablePropertiesWarned
public void setTablePropertiesWarned(java.util.Set<java.lang.String> properties)
-
getTablePropertiesIgnored
public java.util.Set<java.lang.String> getTablePropertiesIgnored()
- Specified by:
getTablePropertiesIgnoredin interfaceGuardrailsConfig- Returns:
- The table properties that are ignored when creating or altering a table.
-
setTablePropertiesIgnored
public void setTablePropertiesIgnored(java.util.Set<java.lang.String> properties)
-
getTablePropertiesDisallowed
public java.util.Set<java.lang.String> getTablePropertiesDisallowed()
- Specified by:
getTablePropertiesDisallowedin interfaceGuardrailsConfig- Returns:
- The table properties that are disallowed when creating or altering a table.
-
setTablePropertiesDisallowed
public void setTablePropertiesDisallowed(java.util.Set<java.lang.String> properties)
-
getUserTimestampsEnabled
public boolean getUserTimestampsEnabled()
Description copied from interface:GuardrailsConfigReturns whether user-provided timestamps are allowed.- Specified by:
getUserTimestampsEnabledin interfaceGuardrailsConfig- Returns:
trueif user-provided timestamps are allowed,falseotherwise.
-
setUserTimestampsEnabled
public void setUserTimestampsEnabled(boolean enabled)
-
getGroupByEnabled
public boolean getGroupByEnabled()
Description copied from interface:GuardrailsConfigReturns whether GROUP BY functionality is allowed- Specified by:
getGroupByEnabledin interfaceGuardrailsConfig- Returns:
trueif allowed,falseotherwise.
-
setGroupByEnabled
public void setGroupByEnabled(boolean enabled)
-
getDropTruncateTableEnabled
public boolean getDropTruncateTableEnabled()
Description copied from interface:GuardrailsConfigReturns whether TRUNCATE or DROP table are allowed- Specified by:
getDropTruncateTableEnabledin interfaceGuardrailsConfig- Returns:
trueif allowed,falseotherwise.
-
setDropTruncateTableEnabled
public void setDropTruncateTableEnabled(boolean enabled)
-
getSecondaryIndexesEnabled
public boolean getSecondaryIndexesEnabled()
- Specified by:
getSecondaryIndexesEnabledin interfaceGuardrailsConfig- Returns:
- Whether creation of secondary indexes is allowed.
-
setSecondaryIndexesEnabled
public void setSecondaryIndexesEnabled(boolean enabled)
-
getUncompressedTablesEnabled
public boolean getUncompressedTablesEnabled()
Description copied from interface:GuardrailsConfigReturns whether tables can be uncompressed- Specified by:
getUncompressedTablesEnabledin interfaceGuardrailsConfig- Returns:
trueif user's can disable compression,falseotherwise.
-
setUncompressedTablesEnabled
public void setUncompressedTablesEnabled(boolean enabled)
-
getCompactTablesEnabled
public boolean getCompactTablesEnabled()
Description copied from interface:GuardrailsConfigReturns whether users can create new COMPACT STORAGE tables- Specified by:
getCompactTablesEnabledin interfaceGuardrailsConfig- Returns:
trueif allowed,falseotherwise.
-
setCompactTablesEnabled
public void setCompactTablesEnabled(boolean enabled)
-
getReadBeforeWriteListOperationsEnabled
public boolean getReadBeforeWriteListOperationsEnabled()
Description copied from interface:GuardrailsConfigReturns whether list operations that require read before write are allowed.- Specified by:
getReadBeforeWriteListOperationsEnabledin interfaceGuardrailsConfig- Returns:
trueif list operations that require read before write are allowed,falseotherwise.
-
setReadBeforeWriteListOperationsEnabled
public void setReadBeforeWriteListOperationsEnabled(boolean enabled)
-
getAllowFilteringEnabled
public boolean getAllowFilteringEnabled()
Description copied from interface:GuardrailsConfigReturns whether ALLOW FILTERING property is allowed.- Specified by:
getAllowFilteringEnabledin interfaceGuardrailsConfig- Returns:
trueif ALLOW FILTERING is allowed,falseotherwise.
-
setAllowFilteringEnabled
public void setAllowFilteringEnabled(boolean enabled)
-
getInSelectCartesianProductWarnThreshold
public int getInSelectCartesianProductWarnThreshold()
- Specified by:
getInSelectCartesianProductWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when an IN query creates a cartesian product with a size exceeding threshold. -1 means disabled.
-
getInSelectCartesianProductFailThreshold
public int getInSelectCartesianProductFailThreshold()
- Specified by:
getInSelectCartesianProductFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to prevent IN queries creating a cartesian product with a size exceeding threshold. -1 means disabled.
-
setInSelectCartesianProductThreshold
public void setInSelectCartesianProductThreshold(int warn, int fail)
-
getReadConsistencyLevelsWarned
public java.util.Set<ConsistencyLevel> getReadConsistencyLevelsWarned()
- Specified by:
getReadConsistencyLevelsWarnedin interfaceGuardrailsConfig- Returns:
- The consistency levels that are warned about when reading.
-
setReadConsistencyLevelsWarned
public void setReadConsistencyLevelsWarned(java.util.Set<ConsistencyLevel> consistencyLevels)
-
getReadConsistencyLevelsDisallowed
public java.util.Set<ConsistencyLevel> getReadConsistencyLevelsDisallowed()
- Specified by:
getReadConsistencyLevelsDisallowedin interfaceGuardrailsConfig- Returns:
- The consistency levels that are disallowed when reading.
-
setReadConsistencyLevelsDisallowed
public void setReadConsistencyLevelsDisallowed(java.util.Set<ConsistencyLevel> consistencyLevels)
-
getWriteConsistencyLevelsWarned
public java.util.Set<ConsistencyLevel> getWriteConsistencyLevelsWarned()
- Specified by:
getWriteConsistencyLevelsWarnedin interfaceGuardrailsConfig- Returns:
- The consistency levels that are warned about when writing.
-
setWriteConsistencyLevelsWarned
public void setWriteConsistencyLevelsWarned(java.util.Set<ConsistencyLevel> consistencyLevels)
-
getWriteConsistencyLevelsDisallowed
public java.util.Set<ConsistencyLevel> getWriteConsistencyLevelsDisallowed()
- Specified by:
getWriteConsistencyLevelsDisallowedin interfaceGuardrailsConfig- Returns:
- The consistency levels that are disallowed when writing.
-
setWriteConsistencyLevelsDisallowed
public void setWriteConsistencyLevelsDisallowed(java.util.Set<ConsistencyLevel> consistencyLevels)
-
getCollectionSizeWarnThreshold
@Nullable public DataStorageSpec.LongBytesBound getCollectionSizeWarnThreshold()
- Specified by:
getCollectionSizeWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when encountering a collection with larger data size than threshold.
-
getCollectionSizeFailThreshold
@Nullable public DataStorageSpec.LongBytesBound getCollectionSizeFailThreshold()
- Specified by:
getCollectionSizeFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to prevent collections with larger data size than threshold.
-
setCollectionSizeThreshold
public void setCollectionSizeThreshold(@Nullable DataStorageSpec.LongBytesBound warn, @Nullable DataStorageSpec.LongBytesBound fail)
-
getItemsPerCollectionWarnThreshold
public int getItemsPerCollectionWarnThreshold()
- Specified by:
getItemsPerCollectionWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when encountering more elements in a collection than threshold.
-
getItemsPerCollectionFailThreshold
public int getItemsPerCollectionFailThreshold()
- Specified by:
getItemsPerCollectionFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to prevent collections with more elements than threshold.
-
setItemsPerCollectionThreshold
public void setItemsPerCollectionThreshold(int warn, int fail)
-
getFieldsPerUDTWarnThreshold
public int getFieldsPerUDTWarnThreshold()
- Specified by:
getFieldsPerUDTWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when creating a UDT with more fields than threshold.
-
getFieldsPerUDTFailThreshold
public int getFieldsPerUDTFailThreshold()
- Specified by:
getFieldsPerUDTFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when creating a UDT with more fields than threshold.
-
setFieldsPerUDTThreshold
public void setFieldsPerUDTThreshold(int warn, int fail)
-
getDataDiskUsagePercentageWarnThreshold
public int getDataDiskUsagePercentageWarnThreshold()
- Specified by:
getDataDiskUsagePercentageWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when local disk usage percentage exceeds that threshold.
Allowed values are in the range
[1, 100], and -1 means disabled.
-
getDataDiskUsagePercentageFailThreshold
public int getDataDiskUsagePercentageFailThreshold()
- Specified by:
getDataDiskUsagePercentageFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when local disk usage percentage exceeds that threshold.
Allowed values are in the range
[1, 100], and -1 means disabled.
-
setDataDiskUsagePercentageThreshold
public void setDataDiskUsagePercentageThreshold(int warn, int fail)
-
getDataDiskUsageMaxDiskSize
public DataStorageSpec.LongBytesBound getDataDiskUsageMaxDiskSize()
- Specified by:
getDataDiskUsageMaxDiskSizein interfaceGuardrailsConfig- Returns:
- The max disk size of the data directories when calculating disk usage thresholds,
nullmeans disabled.
-
setDataDiskUsageMaxDiskSize
public void setDataDiskUsageMaxDiskSize(@Nullable DataStorageSpec.LongBytesBound diskSize)
-
getMinimumReplicationFactorWarnThreshold
public int getMinimumReplicationFactorWarnThreshold()
- Specified by:
getMinimumReplicationFactorWarnThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to warn when replication factor is lesser than threshold.
-
getMinimumReplicationFactorFailThreshold
public int getMinimumReplicationFactorFailThreshold()
- Specified by:
getMinimumReplicationFactorFailThresholdin interfaceGuardrailsConfig- Returns:
- The threshold to fail when replication factor is lesser than threshold.
-
setMinimumReplicationFactorThreshold
public void setMinimumReplicationFactorThreshold(int warn, int fail)
-
-