hudson.model
Class Node

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.Node
All Implemented Interfaces:
ExtensionPoint, Describable<Node>, ModelObject, SearchableModelObject, SearchItem, AccessControlled
Direct Known Subclasses:
Hudson, Slave

@ExportedBean
public abstract class Node
extends AbstractModelObject
implements Describable<Node>, ExtensionPoint, AccessControlled

Base type of Hudson slaves (although in practice, you probably extend Slave to define a new slave type.)

As a special case, Hudson extends from here.

Author:
Kohsuke Kawaguchi
See Also:
NodeMonitor, NodeDescriptor

Nested Class Summary
static class Node.Mode
          Constants that control how Hudson allocates jobs to slaves.
static class Node.NodeListener
          Listener for set offline cause for node when computer get started.
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
Node()
           
 
Method Summary
 CauseOfBlockage canTake(Queue.Task task)
          Called by the Queue to determine whether or not this node can take the given task.
 void checkPermission(Permission permission)
          Convenient short-cut for getACL().checkPermission(permission)
abstract  Launcher createLauncher(TaskListener listener)
          Returns a Launcher for executing programs on this node.
 FilePath createPath(String absolutePath)
          Gets the FilePath on this node.
 ACL getACL()
          Obtains the ACL associated with this object.
 Set<LabelAtom> getAssignedLabels()
          Returns the possibly empty set of labels that are assigned to this node, including the automatic self label, manually assigned labels and dynamically assigned labels via the LabelFinder extension point.
 hudson.remoting.VirtualChannel getChannel()
          Gets the current channel, if the node is connected and online, or null.
abstract  ClockDifference getClockDifference()
          Estimates the clock difference with this slave.
abstract  NodeDescriptor getDescriptor()
          Gets the descriptor for this instance.
 String getDisplayName()
           
 FileSystemProvisioner getFileSystemProvisioner()
           
 TagCloud<LabelAtom> getLabelCloud()
          Return the possibly empty tag cloud for the labels of this node.
abstract  String getLabelString()
          Returns the manually configured label for a node.
abstract  Node.Mode getMode()
          Returns Node.Mode.EXCLUSIVE if this node is only available for those jobs that exclusively specifies this node as the assigned node.
abstract  String getNodeDescription()
          Human-readable description of this node.
abstract  String getNodeName()
          Name of this node.
abstract  DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()
          Gets the NodeProperty instances configured for this Node.
 List<NodePropertyDescriptor> getNodePropertyDescriptors()
           
abstract  int getNumExecutors()
          Returns the number of Executors.
abstract  FilePath getRootPath()
          Gets the root directory of this node.
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
 LabelAtom getSelfLabel()
          Gets the special label that represents this node itself.
abstract  FilePath getWorkspaceFor(TopLevelItem item)
          Returns a "workspace" directory for the given TopLevelItem.
 boolean hasPermission(Permission permission)
          Convenient short-cut for getACL().hasPermission(permission)
 boolean isHoldOffLaunchUntilSave()
           
abstract  void setNodeName(String name)
          Deprecated. to indicate that this method isn't really meant to be called by random code.
 void setOfflineCause(OfflineCause cause)
          Sets the reason about why the node is offline and save configuration.
 Computer toComputer()
          Gets the corresponding Computer object.
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

setOfflineCause

public void setOfflineCause(OfflineCause cause)
Sets the reason about why the node is offline and save configuration.

Parameters:
cause - the offline cause

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface ModelObject

getSearchUrl

public String getSearchUrl()
Description copied from interface: SearchItem
Returns the URL of this item relative to the parent SearchItem.

Specified by:
getSearchUrl in interface SearchItem
Returns:
URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Hudson.)

isHoldOffLaunchUntilSave

public boolean isHoldOffLaunchUntilSave()

getNodeName

@Exported(visibility=999)
public abstract String getNodeName()
Name of this node.

Returns:
"" if this is master

setNodeName

public abstract void setNodeName(String name)
Deprecated. to indicate that this method isn't really meant to be called by random code.

When the user clones a Node, Hudson uses this method to change the node name right after the cloned Node object is instantiated.

This method is never used for any other purpose, and as such for all practical intents and purposes, the node name should be treated like immutable.


getNodeDescription

@Exported
public abstract String getNodeDescription()
Human-readable description of this node.


createLauncher

public abstract Launcher createLauncher(TaskListener listener)
Returns a Launcher for executing programs on this node.

The callee must call Launcher.decorateFor(Node) before returning to complete the decoration.


getNumExecutors

@Exported
public abstract int getNumExecutors()
Returns the number of Executors. This may be different from getExecutors().size() because it takes time to adjust the number of executors.


getMode

@Exported
public abstract Node.Mode getMode()
Returns Node.Mode.EXCLUSIVE if this node is only available for those jobs that exclusively specifies this node as the assigned node.


toComputer

public final Computer toComputer()
Gets the corresponding Computer object.

Returns:
this method can return null if there's no Computer object for this node, such as when this node has no executors at all.

getChannel

public final hudson.remoting.VirtualChannel getChannel()
Gets the current channel, if the node is connected and online, or null. This is just a convenience method for Computer.getChannel() with null check.


getLabelCloud

public TagCloud<LabelAtom> getLabelCloud()
Return the possibly empty tag cloud for the labels of this node.


getAssignedLabels

@Exported
public Set<LabelAtom> getAssignedLabels()
Returns the possibly empty set of labels that are assigned to this node, including the automatic self label, manually assigned labels and dynamically assigned labels via the LabelFinder extension point. This method has a side effect of updating the hudson-wide set of labels and should be called after events that will change that - e.g. a slave connecting.


getLabelString

public abstract String getLabelString()
Returns the manually configured label for a node. The list of assigned and dynamically determined labels is available via getAssignedLabels() and includes all labels that have been manually configured. Mainly for form binding.


getSelfLabel

public LabelAtom getSelfLabel()
Gets the special label that represents this node itself.


canTake

public CauseOfBlockage canTake(Queue.Task task)
Called by the Queue to determine whether or not this node can take the given task. The default checks include whether or not this node is part of the task's assigned label, whether this node is in Node.Mode.EXCLUSIVE mode if it is not in the task's assigned label, and whether or not any of this node's NodePropertys say that the task cannot be run.

Since:
1.360

getWorkspaceFor

public abstract FilePath getWorkspaceFor(TopLevelItem item)
Returns a "workspace" directory for the given TopLevelItem.

Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.

Returns:
null if this node is not connected hence the path is not available

getRootPath

public abstract FilePath getRootPath()
Gets the root directory of this node.

Hudson always owns a directory on every node. This method returns that.

Returns:
null if the node is offline and hence the FilePath object is not available.

createPath

public FilePath createPath(String absolutePath)
Gets the FilePath on this node.


getFileSystemProvisioner

public FileSystemProvisioner getFileSystemProvisioner()

getNodeProperties

public abstract DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()
Gets the NodeProperty instances configured for this Node.


getNodePropertyDescriptors

public List<NodePropertyDescriptor> getNodePropertyDescriptors()

getACL

public ACL getACL()
Description copied from interface: AccessControlled
Obtains the ACL associated with this object.

Specified by:
getACL in interface AccessControlled
Returns:
never null.

checkPermission

public final void checkPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().checkPermission(permission)

Specified by:
checkPermission in interface AccessControlled

hasPermission

public final boolean hasPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().hasPermission(permission)

Specified by:
hasPermission in interface AccessControlled

getDescriptor

public abstract NodeDescriptor getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<Node>

getClockDifference

public abstract ClockDifference getClockDifference()
                                            throws IOException,
                                                   InterruptedException
Estimates the clock difference with this slave.

Returns:
always non-null.
Throws:
InterruptedException - if the operation is aborted.
IOException


Copyright © 2004-2013 Hudson. All Rights Reserved.