Class LocalChannel

java.lang.Object
hudson.remoting.LocalChannel
All Implemented Interfaces:
VirtualChannel

public class LocalChannel extends Object implements VirtualChannel
VirtualChannel that performs computation on the local JVM.
Author:
Kohsuke Kawaguchi
  • Constructor Details

  • Method Details

    • call

      public <V, T extends Throwable> V call(Callable<V,T> callable) throws T
      Description copied from interface: VirtualChannel
      Makes a remote procedure call.

      Sends Callable to the remote system, executes it, and returns its result. Such calls will be considered as user-space requests. If the channel cannot execute the requests (e.g. when it is being closed), the operations may be rejected even if the channel is still active.

      Specified by:
      call in interface VirtualChannel
      Parameters:
      callable - Callable to be executed
      Throws:
      T - User exception defined by the callable
    • callAsync

      public <V, T extends Throwable> Future<V> callAsync(@NonNull Callable<V,T> callable)
      Description copied from interface: VirtualChannel
      Makes an asynchronous remote procedure call.

      Similar to VirtualChannel.call(Callable) but returns immediately. The result of the Callable can be obtained through the Future object. Such calls will be considered as user-space requests. If the channel cannot execute the requests (e.g. when it is being closed), the operations may be rejected even if the channel is still active.

      Specified by:
      callAsync in interface VirtualChannel
      Returns:
      The Future object that can be used to wait for the completion.
    • close

      public void close()
      Description copied from interface: VirtualChannel
      Performs an orderly shut down of this channel (and the remote peer.)
      Specified by:
      close in interface VirtualChannel
    • join

      public void join() throws InterruptedException
      Description copied from interface: VirtualChannel
      Waits for this Channel to be closed down. The close-down of a Channel might be initiated locally or remotely.
      Specified by:
      join in interface VirtualChannel
      Throws:
      InterruptedException - If the current thread is interrupted while waiting for the completion.
    • join

      public void join(long timeout) throws InterruptedException
      Description copied from interface: VirtualChannel
      Waits for this Channel to be closed down, but only up the given milliseconds.
      Specified by:
      join in interface VirtualChannel
      Parameters:
      timeout - Timeout in milliseconds
      Throws:
      InterruptedException - If the current thread is interrupted while waiting for the completion.
    • export

      public <T> T export(@NonNull Class<T> intf, T instance)
      Description copied from interface: VirtualChannel
      Exports an object for remoting to the other Channel by creating a remotable proxy. The returned reference must be kept if there is ongoing operation on the remote side. Once it is released, the exported object will be deallocated as well. Please keep in mind that the object may be also released earlier than expected by JVM (e.g. see JENKINS-23271).
      Specified by:
      export in interface VirtualChannel
      Type Parameters:
      T - Type
      Parameters:
      intf - Interface to be remoted.
      instance - Instance to be exported. null instances won't be exported to the remote instance.

      All the parameters and return values must be serializable.

      Returns:
      the proxy object that implements T. This object can be transferred to the other Channel, and calling methods on it from the remote side will invoke the same method on the given local instance object. null if the input instance is null.
    • syncLocalIO

      public void syncLocalIO() throws InterruptedException
      Description copied from interface: VirtualChannel
      Blocks until all the I/O packets sent from remote is fully locally executed, then return.
      Specified by:
      syncLocalIO in interface VirtualChannel
      Throws:
      InterruptedException