Interface VirtualChannel

  • All Known Implementing Classes:
    Channel, LocalChannel

    public interface VirtualChannel
    Virtualized Channel that allows different implementations.
    Author:
    Kohsuke Kawaguchi
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <V,​T extends Throwable>
      V
      call​(Callable<V,​T> callable)
      Makes a remote procedure call.
      <V,​T extends Throwable>
      Future<V>
      callAsync​(Callable<V,​T> callable)
      Makes an asynchronous remote procedure call.
      void close()
      Performs an orderly shut down of this channel (and the remote peer.)
      <T> T export​(Class<T> type, T instance)
      Exports an object for remoting to the other Channel by creating a remotable proxy.
      void join()
      Waits for this Channel to be closed down.
      void join​(long timeout)
      Waits for this Channel to be closed down, but only up the given milliseconds.
      void syncLocalIO()
      Blocks until all the I/O packets sent from remote is fully locally executed, then return.
    • Method Detail

      • call

        <V,​T extends Throwable> V call​(Callable<V,​T> callable)
                                      throws IOException,
                                             T extends Throwable,
                                             InterruptedException
        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.

        Parameters:
        callable - Callable to be executed
        Throws:
        InterruptedException - If the current thread is interrupted while waiting for the completion.
        IOException - If there's any error in the communication between Channels.
        T - User exception defined by the callable
        T extends Throwable
      • callAsync

        <V,​T extends ThrowableFuture<V> callAsync​(Callable<V,​T> callable)
                                                   throws IOException
        Makes an asynchronous remote procedure call.

        Similar to 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.

        Returns:
        The Future object that can be used to wait for the completion.
        Throws:
        IOException - If there's an error during the communication.
      • close

        void close()
            throws IOException
        Performs an orderly shut down of this channel (and the remote peer.)
        Throws:
        IOException - if the orderly shut-down failed.
      • join

        void join()
           throws InterruptedException
        Waits for this Channel to be closed down. The close-down of a Channel might be initiated locally or remotely.
        Throws:
        InterruptedException - If the current thread is interrupted while waiting for the completion.
        Since:
        1.300
      • join

        void join​(long timeout)
           throws InterruptedException
        Waits for this Channel to be closed down, but only up the given milliseconds.
        Parameters:
        timeout - Timeout in milliseconds
        Throws:
        InterruptedException - If the current thread is interrupted while waiting for the completion.
        Since:
        1.300
      • export

        @Nullable
        <T> T export​(Class<T> type,
                     @CheckForNull
                     T instance)
        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).
        Type Parameters:
        T - Type
        Parameters:
        instance - Instance to be exported. null instances won't be exported to the remote instance.

        All the parameters and return values must be serializable.

        type - Interface to be remoted.
        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.