Package jenkins.model
Class Nodes
java.lang.Object
jenkins.model.Nodes
- All Implemented Interfaces:
PersistenceRoot,Saveable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class Nodes
extends Object
implements PersistenceRoot
Manages all the nodes for Jenkins.
- Since:
- 1.607
-
Nested Class Summary
Nested Classes -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a node.booleanaddNodeIfAbsent(Node node) Adds a node if a node with the given name doesn't already exist.getConfigFile(Node node) getConfigFile(File dir) getConfigFile(String nodeName) Returns the named node.getNodes()Returns the list of nodes.Gets the root directory on the file system that thisItemcan use freely for storing the configuration data.getRootDirFor(Node node) booleanisLegacy()Returnstrueif and only if the list of nodes is stored in the legacy location.voidload()Loads the nodes from disk.voidvoidremoveNode(Node node) Removes a node.booleanreplaceNode(Node oldOne, Node newOne) Replace node of given name.voidsave()Persists the state of this object into XML.voidsetNodes(Collection<? extends Node> nodes) Sets the list of nodes.voidbooleanupdateNode(Node node) Updates an existing node on disk.
-
Method Details
-
getNodes
Returns the list of nodes.- Returns:
- the list of nodes.
-
setNodes
Sets the list of nodes.- Parameters:
nodes- the new list of nodes.- Throws:
IOException- if the new list of nodes could not be persisted.
-
addNodeIfAbsent
Adds a node if a node with the given name doesn't already exist. This is equivalent toif (nodes.getNode(node.getNodeName()) == null) { nodes.addNode(node); }except that it happens atomically.- Parameters:
node- the new node.- Returns:
- True if the node was added. False otherwise (indicating a node with the given name already exists)
- Throws:
IOException- if the list of nodes could not be persisted.- Since:
- 2.529
-
addNode
Adds a node. If a node of the same name already exists then that node will be replaced.- Parameters:
node- the new node.- Throws:
IOException- if the list of nodes could not be persisted.
-
getConfigFile
-
getConfigFile
-
getConfigFile
-
updateNode
Updates an existing node on disk. If the node instance is not in the list of nodes, then this will be a no-op, even if there is another instance with the sameNode.getNodeName().- Parameters:
node- the node to be updated.- Returns:
true, if the node was updated.false, if the node was not in the list of nodes.- Throws:
IOException- if the node could not be persisted.- Since:
- 1.634
-
replaceNode
Replace node of given name.- Returns:
trueif node was replaced.- Throws:
IOException- Since:
- 2.8
-
removeNode
Removes a node. If the node instance is not in the list of nodes, then this will be a no-op, even if there is another instance with the sameNode.getNodeName().- Parameters:
node- the node instance to remove.- Throws:
IOException- if the list of nodes could not be persisted.
-
save
Description copied from interface:SaveablePersists the state of this object into XML.For making a bulk change efficiently, see
BulkChange.To support listeners monitoring changes to this object, call
SaveableListener.fireOnChange(hudson.model.Saveable, hudson.XmlFile)- Specified by:
savein interfaceSaveable- Throws:
IOException- if the persistence failed.
-
getNode
Returns the named node.- Parameters:
name- theNode.getNodeName()of the node to retrieve.- Returns:
- the
Nodeornullif the node could not be found.
-
load
Loads the nodes from disk.- Throws:
IOException- if the nodes could not be deserialized.
-
getOrLoad
-
load
-
load
- Throws:
IOException
-
unload
-
isLegacy
public boolean isLegacy()Returnstrueif and only if the list of nodes is stored in the legacy location.- Returns:
trueif and only if the list of nodes is stored in the legacy location.
-
getRootDir
Description copied from interface:PersistenceRootGets the root directory on the file system that thisItemcan use freely for storing the configuration data.This parameter is given by the
ItemGroupwhenItemis loaded from memory.- Specified by:
getRootDirin interfacePersistenceRoot
-
getRootDirFor
-