Package hudson.remoting
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 Summary
Constructors Constructor Description LocalChannel(ExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V,T extends Throwable>
Vcall(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> intf, T instance)
Exports an object for remoting to the otherChannel
by creating a remotable proxy.void
join()
Waits for thisChannel
to be closed down.void
join(long timeout)
Waits for thisChannel
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.
-
-
-
Constructor Detail
-
LocalChannel
public LocalChannel(ExecutorService executor)
-
-
Method Detail
-
call
public <V,T extends Throwable> V call(Callable<V,T> callable) throws T extends Throwable
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 interfaceVirtualChannel
- Parameters:
callable
- Callable to be executed- Throws:
T
- User exception defined by the callableT extends Throwable
-
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 theCallable
can be obtained through theFuture
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 interfaceVirtualChannel
- 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 interfaceVirtualChannel
-
join
public void join() throws InterruptedException
Description copied from interface:VirtualChannel
Waits for thisChannel
to be closed down. The close-down of aChannel
might be initiated locally or remotely.- Specified by:
join
in interfaceVirtualChannel
- 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 thisChannel
to be closed down, but only up the given milliseconds.- Specified by:
join
in interfaceVirtualChannel
- 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 otherChannel
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 interfaceVirtualChannel
- 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 otherChannel
, and calling methods on it from the remote side will invoke the same method on the given localinstance
object.null
if the input instance isnull
.
-
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 interfaceVirtualChannel
- Throws:
InterruptedException
-
-