Class 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 GuardrailsConfig class and not directly by the code checking each guarded constraint. That code should use the higher level abstractions defined in Guardrails).

    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 Detail

      • GuardrailsOptions

        public GuardrailsOptions​(Config config)
    • Method Detail

      • getKeyspacesWarnThreshold

        public int getKeyspacesWarnThreshold()
        Specified by:
        getKeyspacesWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when creating more user keyspaces than threshold.
      • getKeyspacesFailThreshold

        public int getKeyspacesFailThreshold()
        Specified by:
        getKeyspacesFailThreshold in interface GuardrailsConfig
        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:
        getTablesWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when creating more user tables than threshold.
      • getTablesFailThreshold

        public int getTablesFailThreshold()
        Specified by:
        getTablesFailThreshold in interface GuardrailsConfig
        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:
        getColumnsPerTableWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when creating more columns per table than threshold.
      • getColumnsPerTableFailThreshold

        public int getColumnsPerTableFailThreshold()
        Specified by:
        getColumnsPerTableFailThreshold in interface GuardrailsConfig
        Returns:
        The threshold to fail when creating more columns per table than threshold.
      • setColumnsPerTableThreshold

        public void setColumnsPerTableThreshold​(int warn,
                                                int fail)
      • setSecondaryIndexesPerTableThreshold

        public void setSecondaryIndexesPerTableThreshold​(int warn,
                                                         int fail)
      • setPartitionKeysInSelectThreshold

        public void setPartitionKeysInSelectThreshold​(int warn,
                                                      int fail)
      • setMaterializedViewsPerTableThreshold

        public void setMaterializedViewsPerTableThreshold​(int warn,
                                                          int fail)
      • getPageSizeWarnThreshold

        public int getPageSizeWarnThreshold()
        Specified by:
        getPageSizeWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when page size exceeds given size.
      • getPageSizeFailThreshold

        public int getPageSizeFailThreshold()
        Specified by:
        getPageSizeFailThreshold in interface GuardrailsConfig
        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:
        getTablePropertiesWarned in interface GuardrailsConfig
        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:
        getTablePropertiesIgnored in interface GuardrailsConfig
        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:
        getTablePropertiesDisallowed in interface GuardrailsConfig
        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: GuardrailsConfig
        Returns whether user-provided timestamps are allowed.
        Specified by:
        getUserTimestampsEnabled in interface GuardrailsConfig
        Returns:
        true if user-provided timestamps are allowed, false otherwise.
      • setUserTimestampsEnabled

        public void setUserTimestampsEnabled​(boolean enabled)
      • getGroupByEnabled

        public boolean getGroupByEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether GROUP BY functionality is allowed
        Specified by:
        getGroupByEnabled in interface GuardrailsConfig
        Returns:
        true if allowed, false otherwise.
      • setGroupByEnabled

        public void setGroupByEnabled​(boolean enabled)
      • getDropTruncateTableEnabled

        public boolean getDropTruncateTableEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether TRUNCATE or DROP table are allowed
        Specified by:
        getDropTruncateTableEnabled in interface GuardrailsConfig
        Returns:
        true if allowed, false otherwise.
      • setDropTruncateTableEnabled

        public void setDropTruncateTableEnabled​(boolean enabled)
      • getDropKeyspaceEnabled

        public boolean getDropKeyspaceEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether DROP on keyspaces is allowed
        Specified by:
        getDropKeyspaceEnabled in interface GuardrailsConfig
        Returns:
        true if allowed, false otherwise.
      • setDropKeyspaceEnabled

        public void setDropKeyspaceEnabled​(boolean enabled)
      • setSecondaryIndexesEnabled

        public void setSecondaryIndexesEnabled​(boolean enabled)
      • getUncompressedTablesEnabled

        public boolean getUncompressedTablesEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether tables can be uncompressed
        Specified by:
        getUncompressedTablesEnabled in interface GuardrailsConfig
        Returns:
        true if user's can disable compression, false otherwise.
      • setUncompressedTablesEnabled

        public void setUncompressedTablesEnabled​(boolean enabled)
      • getCompactTablesEnabled

        public boolean getCompactTablesEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether users can create new COMPACT STORAGE tables
        Specified by:
        getCompactTablesEnabled in interface GuardrailsConfig
        Returns:
        true if allowed, false otherwise.
      • setCompactTablesEnabled

        public void setCompactTablesEnabled​(boolean enabled)
      • getAlterTableEnabled

        public boolean getAlterTableEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether users are allowed access to the ALTER TABLE statement to mutate columns or not
        Specified by:
        getAlterTableEnabled in interface GuardrailsConfig
        Returns:
        true if ALTER TABLE ADD/REMOVE/RENAME is allowed, false otherwise.
      • setAlterTableEnabled

        public void setAlterTableEnabled​(boolean enabled)
      • getReadBeforeWriteListOperationsEnabled

        public boolean getReadBeforeWriteListOperationsEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether list operations that require read before write are allowed.
        Specified by:
        getReadBeforeWriteListOperationsEnabled in interface GuardrailsConfig
        Returns:
        true if list operations that require read before write are allowed, false otherwise.
      • setReadBeforeWriteListOperationsEnabled

        public void setReadBeforeWriteListOperationsEnabled​(boolean enabled)
      • getAllowFilteringEnabled

        public boolean getAllowFilteringEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether ALLOW FILTERING property is allowed.
        Specified by:
        getAllowFilteringEnabled in interface GuardrailsConfig
        Returns:
        true if ALLOW FILTERING is allowed, false otherwise.
      • setAllowFilteringEnabled

        public void setAllowFilteringEnabled​(boolean enabled)
      • getSimpleStrategyEnabled

        public boolean getSimpleStrategyEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether setting SimpleStrategy via keyspace creation or alteration is enabled
        Specified by:
        getSimpleStrategyEnabled in interface GuardrailsConfig
        Returns:
        true if SimpleStrategy is allowed, false otherwise.
      • setSimpleStrategyEnabled

        public void setSimpleStrategyEnabled​(boolean enabled)
      • getInSelectCartesianProductWarnThreshold

        public int getInSelectCartesianProductWarnThreshold()
        Specified by:
        getInSelectCartesianProductWarnThreshold in interface GuardrailsConfig
        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:
        getInSelectCartesianProductFailThreshold in interface GuardrailsConfig
        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)
      • setReadConsistencyLevelsWarned

        public void setReadConsistencyLevelsWarned​(java.util.Set<ConsistencyLevel> consistencyLevels)
      • setReadConsistencyLevelsDisallowed

        public void setReadConsistencyLevelsDisallowed​(java.util.Set<ConsistencyLevel> consistencyLevels)
      • setWriteConsistencyLevelsWarned

        public void setWriteConsistencyLevelsWarned​(java.util.Set<ConsistencyLevel> consistencyLevels)
      • setWriteConsistencyLevelsDisallowed

        public void setWriteConsistencyLevelsDisallowed​(java.util.Set<ConsistencyLevel> consistencyLevels)
      • getPartitionTombstonesWarnThreshold

        public long getPartitionTombstonesWarnThreshold()
        Specified by:
        getPartitionTombstonesWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when writing partitions with more tombstones than threshold.
      • getPartitionTombstonesFailThreshold

        public long getPartitionTombstonesFailThreshold()
        Specified by:
        getPartitionTombstonesFailThreshold in interface GuardrailsConfig
        Returns:
        The threshold to fail when writing partitions with more tombstones than threshold.
      • setPartitionTombstonesThreshold

        public void setPartitionTombstonesThreshold​(long warn,
                                                    long fail)
      • getItemsPerCollectionWarnThreshold

        public int getItemsPerCollectionWarnThreshold()
        Specified by:
        getItemsPerCollectionWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when encountering more elements in a collection than threshold.
      • setItemsPerCollectionThreshold

        public void setItemsPerCollectionThreshold​(int warn,
                                                   int fail)
      • getFieldsPerUDTWarnThreshold

        public int getFieldsPerUDTWarnThreshold()
        Specified by:
        getFieldsPerUDTWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when creating a UDT with more fields than threshold.
      • getFieldsPerUDTFailThreshold

        public int getFieldsPerUDTFailThreshold()
        Specified by:
        getFieldsPerUDTFailThreshold in interface GuardrailsConfig
        Returns:
        The threshold to fail when creating a UDT with more fields than threshold.
      • setFieldsPerUDTThreshold

        public void setFieldsPerUDTThreshold​(int warn,
                                             int fail)
      • getVectorDimensionsWarnThreshold

        public int getVectorDimensionsWarnThreshold()
        Specified by:
        getVectorDimensionsWarnThreshold in interface GuardrailsConfig
        Returns:
        The threshold to warn when creating a vector with more dimensions than threshold.
      • getVectorDimensionsFailThreshold

        public int getVectorDimensionsFailThreshold()
        Specified by:
        getVectorDimensionsFailThreshold in interface GuardrailsConfig
        Returns:
        The threshold to fail when creating a vector with more dimensions than threshold.
      • setVectorDimensionsThreshold

        public void setVectorDimensionsThreshold​(int warn,
                                                 int fail)
      • getDataDiskUsagePercentageWarnThreshold

        public int getDataDiskUsagePercentageWarnThreshold()
        Specified by:
        getDataDiskUsagePercentageWarnThreshold in interface GuardrailsConfig
        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:
        getDataDiskUsagePercentageFailThreshold in interface GuardrailsConfig
        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)
      • setMinimumReplicationFactorThreshold

        public void setMinimumReplicationFactorThreshold​(int warn,
                                                         int fail)
      • setMaximumReplicationFactorThreshold

        public void setMaximumReplicationFactorThreshold​(int warn,
                                                         int fail)
      • getZeroTTLOnTWCSWarned

        public boolean getZeroTTLOnTWCSWarned()
        Description copied from interface: GuardrailsConfig
        Returns whether warnings will be emitted when usage of 0 default TTL on a table with TimeWindowCompactionStrategy is detected.
        Specified by:
        getZeroTTLOnTWCSWarned in interface GuardrailsConfig
        Returns:
        true if warnings will be emitted, false otherwise.
      • setZeroTTLOnTWCSWarned

        public void setZeroTTLOnTWCSWarned​(boolean value)
        Description copied from interface: GuardrailsConfig
        Sets whether warnings will be emitted when usage of 0 default TTL on a table with TimeWindowCompactionStrategy is detected.
        Specified by:
        setZeroTTLOnTWCSWarned in interface GuardrailsConfig
        Parameters:
        value - true if warning will be emitted, false otherwise.
      • getZeroTTLOnTWCSEnabled

        public boolean getZeroTTLOnTWCSEnabled()
        Description copied from interface: GuardrailsConfig
        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.
        Specified by:
        getZeroTTLOnTWCSEnabled in interface GuardrailsConfig
        Returns:
        true if 0 default TTL is allowed on TWCS table, false otherwise.
      • setZeroTTLOnTWCSEnabled

        public void setZeroTTLOnTWCSEnabled​(boolean value)
        Description copied from interface: GuardrailsConfig
        Sets whether users can use 0 default TTL on a table with TimeWindowCompactionStrategy.
        Specified by:
        setZeroTTLOnTWCSEnabled in interface GuardrailsConfig
        Parameters:
        value - true if 0 default TTL on TWCS tables is allowed, false otherwise.
      • getIntersectFilteringQueryWarned

        public boolean getIntersectFilteringQueryWarned()
        Specified by:
        getIntersectFilteringQueryWarned in interface GuardrailsConfig
        Returns:
        true if a client warning is emitted for a filtering query with an intersection on mutable columns at a consistency level requiring coordinator reconciliation
      • getIntersectFilteringQueryEnabled

        public boolean getIntersectFilteringQueryEnabled()
        Specified by:
        getIntersectFilteringQueryEnabled in interface GuardrailsConfig
        Returns:
        true if it is possible to execute a filtering query with an intersection on mutable columns at a consistency level requiring coordinator reconciliation
      • setMaximumTimestampThreshold

        public void setMaximumTimestampThreshold​(@Nullable
                                                 DurationSpec.LongMicrosecondsBound warn,
                                                 @Nullable
                                                 DurationSpec.LongMicrosecondsBound fail)
        Description copied from interface: GuardrailsConfig
        Sets the warning upper bound for user supplied timestamps
        Specified by:
        setMaximumTimestampThreshold in interface GuardrailsConfig
        Parameters:
        warn - The highest acceptable difference between now and the written value timestamp before triggering a warning. null means disabled.
        fail - The highest acceptable difference between now and the written value timestamp before triggering a failure. null means disabled.
      • setMinimumTimestampThreshold

        public void setMinimumTimestampThreshold​(@Nullable
                                                 DurationSpec.LongMicrosecondsBound warn,
                                                 @Nullable
                                                 DurationSpec.LongMicrosecondsBound fail)
        Description copied from interface: GuardrailsConfig
        Sets the warning lower bound for user supplied timestamps
        Specified by:
        setMinimumTimestampThreshold in interface GuardrailsConfig
        Parameters:
        warn - The lowest acceptable difference between now and the written value timestamp before triggering a warning. null means disabled.
        fail - The lowest acceptable difference between now and the written value timestamp before triggering a failure. null means disabled.
      • setSaiSSTableIndexesPerQueryThreshold

        public void setSaiSSTableIndexesPerQueryThreshold​(int warn,
                                                          int fail)
        Description copied from interface: GuardrailsConfig
        Sets warning and failure thresholds for the number of SAI SSTable indexes searched by a query
        Specified by:
        setSaiSSTableIndexesPerQueryThreshold in interface GuardrailsConfig
        Parameters:
        warn - value to set for warn threshold
        fail - value to set for fail threshold
      • getNonPartitionRestrictedQueryEnabled

        public boolean getNonPartitionRestrictedQueryEnabled()
        Description copied from interface: GuardrailsConfig
        Returns whether it is possible to execute a query against secondary indexes without specifying any partition key restrictions.
        Specified by:
        getNonPartitionRestrictedQueryEnabled in interface GuardrailsConfig
        Returns:
        true if it is possible to execute a query without a partition key, false otherwise
      • setNonPartitionRestrictedQueryEnabled

        public void setNonPartitionRestrictedQueryEnabled​(boolean enabled)
        Description copied from interface: GuardrailsConfig
        Sets whether it is possible to execute a query against indexes (secondary or SAI) without specifying any partition key restrictions.
        Specified by:
        setNonPartitionRestrictedQueryEnabled in interface GuardrailsConfig
        Parameters:
        enabled - true if a query without partition key is enabled or not
      • getVectorTypeEnabled

        public boolean getVectorTypeEnabled()
        Specified by:
        getVectorTypeEnabled in interface GuardrailsConfig
        Returns:
        Whether new columns can be created with vector type