Class HintScanPrioritizer

All Implemented Interfaces:

public class HintScanPrioritizer extends Object implements ScanPrioritizer
When configured for a scan executor, this prioritizer allows scanners to set priorities as integers. Lower integers result in higher priority.

Scanners can put the key/values priority=<integer> and/or scan_type=<type> in the map passed to ScannerBase.setExecutionHints(Map) to set the priority. When a priority hint is set it takes precedence and the value is used as the priority. When a scan_type hint is set the priority is looked up using the value.

This prioritizer accepts the option default_priority=<integer> which determines what priority to use for scans without a hint. If not set, then default_priority is Integer.MAX_VALUE.

This prioritizer accepts the option bad_hint_action=fail|log|none. This option determines what happens when a priority hint is not an integer. It defaults to log which logs a warning. The fail option throws an exception which may fail the scan. The none option silently ignores invalid hints.

This prioritizer accepts the option priority.<type>=<integer> which maps a scan type hint to a priority.

When two scans have the same priority, the scan is prioritized based on last run time and then creation time.

If a secondary or tertiary priority is needed, this can be done with bit shifting. For example assume a primary priority of 1 to 3 is desired followed by a secondary priority of 1 to 10 . This can be encoded as int priority = primary << 4 | secondary. When the primary bits are equal the comparison naturally falls back to the secondary bits. The example does not handle the case where the primary of secondary priorities are outside expected ranges.