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 Modifier and Type Class Description static class
Nodes.ScheduleMaintenanceAfterSavingNode
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNode(Node node)
Adds a node.XmlFile
getConfigFile(Node node)
XmlFile
getConfigFile(File dir)
XmlFile
getConfigFile(String nodeName)
Node
getNode(String name)
Returns the named node.List<Node>
getNodes()
Returns the list of nodes.Node
getOrLoad(String name)
File
getRootDir()
Gets the root directory on the file system that thisItem
can use freely for storing the configuration data.File
getRootDirFor(Node node)
boolean
isLegacy()
Returnstrue
if and only if the list of nodes is stored in the legacy location.void
load()
Loads the nodes from disk.void
load(File dir)
Node
load(String name)
void
removeNode(Node node)
Removes a node.boolean
replaceNode(Node oldOne, Node newOne)
Replace node of given name.void
save()
Persists the state of this object into XML.void
setNodes(Collection<? extends Node> nodes)
Sets the list of nodes.void
unload(Node node)
boolean
updateNode(Node node)
Updates an existing node on disk.
-
-
-
Method Detail
-
getNodes
@NonNull public List<Node> getNodes()
Returns the list of nodes.- Returns:
- the list of nodes.
-
setNodes
public void setNodes(@NonNull Collection<? extends Node> nodes) throws IOException
Sets the list of nodes.- Parameters:
nodes
- the new list of nodes.- Throws:
IOException
- if the new list of nodes could not be persisted.
-
addNode
public void addNode(@NonNull Node node) throws IOException
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.
-
updateNode
public boolean updateNode(@NonNull Node node) throws IOException
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
public boolean replaceNode(Node oldOne, @NonNull Node newOne) throws IOException
Replace node of given name.- Returns:
true
if node was replaced.- Throws:
IOException
- Since:
- 2.8
-
removeNode
public void removeNode(@NonNull Node node) throws IOException
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
public void save() throws IOException
Description copied from interface:Saveable
Persists 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:
save
in interfaceSaveable
- Throws:
IOException
- if the persistence failed.
-
getNode
@CheckForNull public Node getNode(String name)
Returns the named node.- Parameters:
name
- theNode.getNodeName()
of the node to retrieve.- Returns:
- the
Node
ornull
if the node could not be found.
-
load
public void load() throws IOException
Loads the nodes from disk.- Throws:
IOException
- if the nodes could not be deserialized.
-
load
public void load(File dir) throws IOException
- Throws:
IOException
-
unload
public void unload(Node node)
-
isLegacy
public boolean isLegacy()
Returnstrue
if and only if the list of nodes is stored in the legacy location.- Returns:
true
if and only if the list of nodes is stored in the legacy location.
-
getRootDir
public File getRootDir()
Description copied from interface:PersistenceRoot
Gets the root directory on the file system that thisItem
can use freely for storing the configuration data.This parameter is given by the
ItemGroup
whenItem
is loaded from memory.- Specified by:
getRootDir
in interfacePersistenceRoot
-
-