Package hudson.slaves

Class SlaveComputer

    • Field Detail

      • ALLOW_UNSUPPORTED_REMOTING_VERSIONS

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static boolean ALLOW_UNSUPPORTED_REMOTING_VERSIONS
        Escape hatch for allowing connections from agents with unsupported Remoting versions.
    • Constructor Detail

      • SlaveComputer

        public SlaveComputer​(Slave slave)
    • Method Detail

      • getJnlpMac

        public String getJnlpMac()
        Since:
        1.498
      • isUnix

        public Boolean isUnix()
        Description copied from class: Computer
        True if this computer is a Unix machine (as opposed to Windows machine).
        Specified by:
        isUnix in class Computer
        Returns:
        null if the computer is disconnected and therefore we don't know whether it is Unix or not.
      • getNode

        @CheckForNull
        public Slave getNode()
        Description copied from class: Computer
        Returns the Node that this computer represents.
        Overrides:
        getNode in class Computer
        Returns:
        null if the configuration has changed and the node is removed, yet the corresponding Computer is not yet gone.
      • getListener

        @NonNull
        public TaskListener getListener()
        Offers a way to write to the log file for this agent.
        Since:
        2.9
      • isJnlpAgent

        @Deprecated
        public boolean isJnlpAgent()
        Deprecated.
        since 2008-05-20.
        Description copied from class: Computer
        Returns true if this computer is supposed to be launched via inbound protocol.
        Overrides:
        isJnlpAgent in class Computer
      • isLaunchSupported

        public boolean isLaunchSupported()
        Description copied from class: Computer
        Returns true if this computer can be launched by Hudson proactively and automatically.

        For example, inbound agents return false from this, because the launch process needs to be initiated from the agent side.

        Overrides:
        isLaunchSupported in class Computer
      • _connect

        protected Future<?> _connect​(boolean forceReconnect)
        Description copied from class: Computer
        Allows implementing-classes to provide an implementation for the connect method.

        If already connected or if this computer doesn't support proactive launching, no-op. This method may return immediately while the launch operation happens asynchronously.

        Specified by:
        _connect in class Computer
        Parameters:
        forceReconnect - If true and a connect activity is already in progress, it will be cancelled and the new one will be started. If false, and a connect activity is already in progress, this method will do nothing and just return the pending connection operation.
        Returns:
        A Future representing pending completion of the task. The 'completion' includes both a successful completion and a non-successful completion (such distinction typically doesn't make much sense because as soon as Computer is connected it can be disconnected by some other threads.)
        See Also:
        Computer.disconnect()
      • taskAccepted

        public void taskAccepted​(Executor executor,
                                 Queue.Task task)
        Description copied from interface: ExecutorListener
        Called whenever a task is accepted by an executor.
        Parameters:
        executor - The executor.
        task - The task.
      • taskStarted

        public void taskStarted​(Executor executor,
                                Queue.Task task)
        Description copied from interface: ExecutorListener
        Called whenever a task is started by an executor.
        Parameters:
        executor - The executor.
        task - The task.
      • taskCompleted

        public void taskCompleted​(Executor executor,
                                  Queue.Task task,
                                  long durationMS)
        Description copied from interface: ExecutorListener
        Called whenever a task is completed without any problems by an executor.
        Parameters:
        executor - The executor.
        task - The task.
        durationMS - The number of milliseconds that the task took to complete.
      • taskCompletedWithProblems

        public void taskCompletedWithProblems​(Executor executor,
                                              Queue.Task task,
                                              long durationMS,
                                              Throwable problems)
        Description copied from interface: ExecutorListener
        Called whenever a task is completed with some problems by an executor.
        Parameters:
        executor - The executor.
        task - The task.
        durationMS - The number of milliseconds that the task took to complete.
        problems - The exception that was thrown.
      • setChannel

        public void setChannel​(@NonNull
                               InputStream in,
                               @NonNull
                               OutputStream out,
                               @CheckForNull
                               OutputStream launchLog,
                               @CheckForNull
                               hudson.remoting.Channel.Listener listener)
                        throws IOException,
                               InterruptedException
        Creates a Channel from the given stream and sets that to this agent.
        Parameters:
        in - Stream connected to the remote agent. It's the caller's responsibility to do buffering on this stream, if that's necessary.
        out - Stream connected to the remote peer. It's the caller's responsibility to do buffering on this stream, if that's necessary.
        launchLog - If non-null, receive the portion of data in is before the data goes into the "binary mode". This is useful when the established communication channel might include some data that might be useful for debugging/trouble-shooting.
        listener - Gets a notification when the channel closes, to perform clean up. Can be null. By the time this method is called, the cause of the termination is reported to the user, so the implementation of the listener doesn't need to do that again.
        Throws:
        IOException
        InterruptedException
      • setChannel

        @Restricted(org.kohsuke.accmod.restrictions.Beta.class)
        public void setChannel​(@NonNull
                               hudson.remoting.ChannelBuilder cb,
                               @NonNull
                               hudson.remoting.CommandTransport commandTransport,
                               @CheckForNull
                               hudson.remoting.Channel.Listener listener)
                        throws IOException,
                               InterruptedException
        Creates a Channel from the given Channel Builder and Command Transport. This method can be used to allow ComputerLaunchers to create channels not based on I/O streams.
        Parameters:
        cb - Channel Builder. To print launch logs this channel builder should have a Header Stream defined (see ChannelBuilder.getHeaderStream()) in this argument or by one of ChannelConfigurators.
        commandTransport - Command Transport
        listener - Gets a notification when the channel closes, to perform clean up. Can be null. By the time this method is called, the cause of the termination is reported to the user, so the implementation of the listener doesn't need to do that again.
        Throws:
        IOException
        InterruptedException
        Since:
        2.127
      • getClassLoadingPrefetchCacheCount

        @CheckReturnValue
        public int getClassLoadingPrefetchCacheCount()
                                              throws IOException,
                                                     InterruptedException
        Shows Channel.classLoadingPrefetchCacheCount.
        Returns:
        Requested value or -1 in case that capability is not supported or if the agent is offline.
        Throws:
        IOException
        InterruptedException
        Since:
        1.519
      • getAbsoluteRemoteFs

        @CheckForNull
        public String getAbsoluteRemoteFs()
        Returns the remote FS root absolute path or null if the agent is off-line. The absolute path may change between connections if the connection method does not provide a consistent working directory and the node's remote FS is specified as a relative path.
        Returns:
        the remote FS root absolute path or null if the agent is off-line.
        Since:
        1.606
      • getAbsoluteRemotePath

        @Exported
        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        @CheckForNull
        public String getAbsoluteRemotePath()
        Just for restFul api. Returns the remote FS root absolute path or null if the agent is off-line. The absolute path may change between connections if the connection method does not provide a consistent working directory and the node's remote FS is specified as a relative path.
        Returns:
        the remote FS root absolute path or null if the agent is off-line or don't have connect permission.
        Since:
        2.125
        See Also:
        getAbsoluteRemoteFs()
      • setChannel

        public void setChannel​(@NonNull
                               hudson.remoting.Channel channel,
                               @CheckForNull
                               OutputStream launchLog,
                               @CheckForNull
                               hudson.remoting.Channel.Listener listener)
                        throws IOException,
                               InterruptedException
        Sets up the connection through an existing channel.
        Parameters:
        channel - the channel to use; warning: callers are expected to have called ChannelConfigurator already.
        launchLog - Launch log. If not null, will receive launch log messages
        listener - Channel event listener to be attached (if not null)
        Throws:
        IOException
        InterruptedException
        Since:
        1.444
      • getChannel

        public hudson.remoting.Channel getChannel()
        Description copied from class: Computer
        Gets the channel that can be used to run a program on this computer.
        Specified by:
        getChannel in class Computer
        Returns:
        never null when Computer.isOffline()==false.
      • doSubmitDescription

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public void doSubmitDescription​(org.kohsuke.stapler.StaplerResponse rsp,
                                        @QueryParameter
                                        String description)
                                 throws IOException
        Inline editing of description
        Throws:
        IOException
      • doDoDisconnect

        public org.kohsuke.stapler.HttpResponse doDoDisconnect​(@QueryParameter
                                                               String offlineMessage)
      • disconnect

        public Future<?> disconnect​(OfflineCause cause)
        Description copied from class: Computer
        Disconnect this computer. If this is the built-in node, no-op. This method may return immediately while the launch operation happens asynchronously.
        Overrides:
        disconnect in class Computer
        Parameters:
        cause - Object that identifies the reason the node was disconnected.
        Returns:
        Future to track the asynchronous disconnect operation.
        See Also:
        Computer.connect(boolean)
      • tryReconnect

        public void tryReconnect()
      • getJnlpJars

        @Deprecated
        public Slave.JnlpJar getJnlpJars​(String fileName)
        Deprecated.
        since 2008-08-18. This URL binding is no longer used and moved up directly under to Jenkins, but it's left here for now just in case some old inbound agents request it.
        Serves jar files for inbound agents.
      • doSlaveAgentJnlp

        @WebMethod(name="slave-agent.jnlp")
        public org.kohsuke.stapler.HttpResponse doSlaveAgentJnlp​(org.kohsuke.stapler.StaplerRequest req,
                                                                 org.kohsuke.stapler.StaplerResponse res)
      • doJenkinsAgentJnlp

        @WebMethod(name="jenkins-agent.jnlp")
        public org.kohsuke.stapler.HttpResponse doJenkinsAgentJnlp​(org.kohsuke.stapler.StaplerRequest req,
                                                                   org.kohsuke.stapler.StaplerResponse res)
      • getTarget

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public Object getTarget()
        Specified by:
        getTarget in interface org.kohsuke.stapler.StaplerProxy
        Overrides:
        getTarget in class Computer
      • setNode

        protected void setNode​(Node node)
        Description copied from class: Computer
        Called to notify Computer that its corresponding Node configuration is updated.
        Overrides:
        setNode in class Computer
      • grabLauncher

        protected ComputerLauncher grabLauncher​(Node node)
        Grabs a ComputerLauncher out of Node to keep it in this Computer. The returned launcher will be set to launcher and used to carry out the actual launch operation.

        Subtypes that needs to decorate ComputerLauncher can do so by overriding this method. This is useful for SlaveComputers for clouds for example, where one normally needs additional pre-launch step (such as waiting for the provisioned node to become available) before the user specified launch step (like SSH connection) kicks in.

        See Also:
        ComputerLauncherFilter
      • getChannelToMaster

        @Deprecated
        public static hudson.remoting.VirtualChannel getChannelToMaster()
        Obtains a VirtualChannel that allows some computation to be performed on the controller. This method can be called from any thread on the controller, or from agent (more precisely, it only works from the remoting request-handling thread in agents, which means if you've started separate thread on agents, that'll fail.)
        Returns:
        null if the calling thread doesn't have any trace of where its controller is.
        Since:
        1.362
      • getSystemInfoExtensions

        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        @RestrictedSince("2.163")
        public static List<SlaveSystemInfo> getSystemInfoExtensions()
        Helper method for Jelly.