Package com.dtolabs.rundeck.core.utils
Class NodeSet
- java.lang.Object
-
- com.dtolabs.rundeck.core.utils.NodeSet
-
- All Implemented Interfaces:
NodesSelector
public class NodeSet extends java.lang.Object implements NodesSelector
NodeSet provides filtering logic for Node criteria
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
NodeSet.Exclude
static class
NodeSet.FILTER_ENUM
Enum of filters.class
NodeSet.Include
class
NodeSet.SetSelector
SetSelector is a filter
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FILTER_KEY
static java.util.List<java.lang.String>
FILTER_KEYS_LIST
names of the filter attributes used by exclude/include that are exposed to the CLI interfacestatic java.util.Collection<java.lang.String>
FILTER_KEYSET
Collection of names of attributes used by exclude/include that are exposed to the CLI interfacestatic java.lang.String
HOSTNAME
static java.lang.String
NAME
static java.lang.String
OS_ARCH
static java.lang.String
OS_FAMILY
static java.lang.String
OS_NAME
static java.lang.String
OS_VERSION
static java.lang.String
TAGS
static java.lang.String
TYPE
-
Constructor Summary
Constructors Constructor Description NodeSet()
default constructorNodeSet(INodeEntry singleNode)
Create a nodeset for a single nodeNodeSet(java.lang.String singleNodeName)
Create a nodeset with a single node name
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptNode(INodeEntry entry)
NodeSet.Exclude
createExclude()
NodeSet.Exclude
createExclude(java.util.Map excludeMap)
Creates anNodeSet.Exclude
object populating its properties from the keys of the mapNodeSet.Include
createInclude()
NodeSet.Include
createInclude(java.util.Map includeMap)
Creates anNodeSet.Include
object populating its properties from the keys of the mapboolean
equals(java.lang.Object o)
static NodeSet
fromFilter(java.lang.String filter)
Create a NodeSet from a filterstatic java.lang.String
generateFilter(NodeSet set)
NodeSet.Exclude
getExclude()
java.io.File
getFailedNodesfile()
NodeSet.Include
getInclude()
java.lang.String
getSingleNodeName()
int
getThreadCount()
int
hashCode()
boolean
isBlank()
Return true if the include/exclude filters are blank or non-existentboolean
isKeepgoing()
protected static boolean
matchesInput(java.lang.String inputSelector, java.lang.String propValue)
protected static boolean
matchesInput(java.util.Map<java.lang.String,java.lang.String> attrSelectors, java.util.Map<java.lang.String,java.lang.String> values, boolean matchAll)
static boolean
matchRegexOrEquals(java.lang.String inputSelector, java.lang.String item)
Tests whether the selector string matches the item, in three possible ways: first, if the selector looks like: "/.../" then it the outer '/' chars are removed and it is treated as a regular expression *only* and PatternSyntaxExceptions are not caught.NodesSelector
nodeSelectorWithDefault(java.lang.String nodename)
NodesSelector
nodeSelectorWithDefaultAll()
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
parseFilter(java.lang.String filter)
Parse textual filter and return a map of maps: [include: [key:value,...], exclude: [key:value,...]]static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
parseFilter(java.lang.String filter, boolean joinMulti, java.lang.String defaultKey)
NodeSet.SetSelector
populateSetSelector(java.util.Map map, NodeSet.SetSelector setselector)
Creates anNodeSet.SetSelector
object populating its properties from the keys of the mapvoid
setFailedNodesfile(java.io.File failedNodesfile)
void
setKeepgoing(boolean keepgoing)
void
setSingleNodeName(java.lang.String singleNodeName)
void
setThreadCount(int threadCount)
boolean
shouldExclude(INodeEntry entry)
Return true if the node entry should be excluded based on the includes and excludes parameters.java.lang.String
toString()
void
validate()
Validate input.
-
-
-
Field Detail
-
HOSTNAME
public static final java.lang.String HOSTNAME
- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
TYPE
public static final java.lang.String TYPE
- See Also:
- Constant Field Values
-
TAGS
public static final java.lang.String TAGS
- See Also:
- Constant Field Values
-
OS_NAME
public static final java.lang.String OS_NAME
- See Also:
- Constant Field Values
-
OS_FAMILY
public static final java.lang.String OS_FAMILY
- See Also:
- Constant Field Values
-
OS_ARCH
public static final java.lang.String OS_ARCH
- See Also:
- Constant Field Values
-
OS_VERSION
public static final java.lang.String OS_VERSION
- See Also:
- Constant Field Values
-
DEFAULT_FILTER_KEY
public static final java.lang.String DEFAULT_FILTER_KEY
- See Also:
- Constant Field Values
-
FILTER_KEYS_LIST
public static final java.util.List<java.lang.String> FILTER_KEYS_LIST
names of the filter attributes used by exclude/include that are exposed to the CLI interface
-
FILTER_KEYSET
public static final java.util.Collection<java.lang.String> FILTER_KEYSET
Collection of names of attributes used by exclude/include that are exposed to the CLI interface
-
-
Constructor Detail
-
NodeSet
public NodeSet()
default constructor
-
NodeSet
public NodeSet(java.lang.String singleNodeName)
Create a nodeset with a single node name- Parameters:
singleNodeName
- node name
-
NodeSet
public NodeSet(INodeEntry singleNode)
Create a nodeset for a single node- Parameters:
singleNode
- the node
-
-
Method Detail
-
getSingleNodeName
public java.lang.String getSingleNodeName()
-
setSingleNodeName
public void setSingleNodeName(java.lang.String singleNodeName)
-
acceptNode
public boolean acceptNode(INodeEntry entry)
- Specified by:
acceptNode
in interfaceNodesSelector
-
nodeSelectorWithDefault
public NodesSelector nodeSelectorWithDefault(java.lang.String nodename)
- Parameters:
nodename
- name- Returns:
- a new Node Selector that will apply the include/exclude filters if they are set, otherwise it only includes the node with the given nodename
-
nodeSelectorWithDefaultAll
public NodesSelector nodeSelectorWithDefaultAll()
- Returns:
- a new Node Selector that will apply the include/exclude filters if they are set, otherwise it will accept all nodes
-
isBlank
public boolean isBlank()
Return true if the include/exclude filters are blank or non-existent- Returns:
- true if all filters are blank or empty
-
createInclude
public NodeSet.Include createInclude()
-
createExclude
public NodeSet.Exclude createExclude()
-
getInclude
public NodeSet.Include getInclude()
-
getExclude
public NodeSet.Exclude getExclude()
-
shouldExclude
public boolean shouldExclude(INodeEntry entry)
Return true if the node entry should be excluded based on the includes and excludes parameters. When both include and exclude patterns match the node, it will be excluded based on which filterset is dominant.- Parameters:
entry
- node descriptor entry- Returns:
- true if the node should be excluded.
-
getThreadCount
public int getThreadCount()
-
setThreadCount
public void setThreadCount(int threadCount)
-
isKeepgoing
public boolean isKeepgoing()
-
setKeepgoing
public void setKeepgoing(boolean keepgoing)
-
validate
public void validate()
Validate input. If failedNodesfile looks like an invalid property reference, set it to null.
-
matchesInput
protected static boolean matchesInput(java.lang.String inputSelector, java.lang.String propValue)
- Parameters:
inputSelector
- inputpropValue
- value- Returns:
- true if the input selector matches the specified property value
-
matchesInput
protected static boolean matchesInput(java.util.Map<java.lang.String,java.lang.String> attrSelectors, java.util.Map<java.lang.String,java.lang.String> values, boolean matchAll)
- Parameters:
matchAll
- if true, require all selectors match a value, otherwise return true if any selector matchesattrSelectors
- map of attribute key to selectorvalues
- map of key to value- Returns:
- true if any attribute selector matches the corresponding attribute value
-
matchRegexOrEquals
public static boolean matchRegexOrEquals(java.lang.String inputSelector, java.lang.String item)
Tests whether the selector string matches the item, in three possible ways: first, if the selector looks like: "/.../" then it the outer '/' chars are removed and it is treated as a regular expression *only* and PatternSyntaxExceptions are not caught. Otherwise, it is treated as a regular expression and any PatternSyntaxExceptions are caught. If it does not match or if the pattern is invalid, it is tested for string equality with the input.- Parameters:
inputSelector
- test string which may be a regular expression, or explicit regular expression string wrapped in '/' charactersitem
- item to test- Returns:
- true if the item matches the selector
-
fromFilter
public static NodeSet fromFilter(java.lang.String filter)
Create a NodeSet from a filter- Parameters:
filter
- filter string- Returns:
- node set
-
parseFilter
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parseFilter(java.lang.String filter)
Parse textual filter and return a map of maps: [include: [key:value,...], exclude: [key:value,...]]- Parameters:
filter
- filter string- Returns:
- parsed filter
-
parseFilter
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parseFilter(java.lang.String filter, boolean joinMulti, java.lang.String defaultKey)
-
generateFilter
public static java.lang.String generateFilter(NodeSet set)
-
createExclude
public NodeSet.Exclude createExclude(java.util.Map excludeMap)
Creates anNodeSet.Exclude
object populating its properties from the keys of the map- Parameters:
excludeMap
- Map containing nodes.properties data- Returns:
- new Exclude object configured for use in this NodeSet
-
createInclude
public NodeSet.Include createInclude(java.util.Map includeMap)
Creates anNodeSet.Include
object populating its properties from the keys of the map- Parameters:
includeMap
- Map containing nodes.properties data- Returns:
- new Exclude object configured for use in this NodeSet
-
populateSetSelector
public NodeSet.SetSelector populateSetSelector(java.util.Map map, NodeSet.SetSelector setselector)
Creates anNodeSet.SetSelector
object populating its properties from the keys of the map- Parameters:
map
- Map containing nodes.properties datasetselector
- include or exclude object- Returns:
- new SetSelector object configured for use in this NodeSet
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getFailedNodesfile
public java.io.File getFailedNodesfile()
-
setFailedNodesfile
public void setFailedNodesfile(java.io.File failedNodesfile)
-
-