public class LocalChannel extends Object implements VirtualChannel
VirtualChannel
that performs computation on the local JVM.Constructor and Description |
---|
LocalChannel(ExecutorService executor) |
Modifier and Type | Method and Description |
---|---|
<V,T extends Throwable> |
call(Callable<V,T> callable)
Makes a remote procedure call.
|
<V,T extends Throwable> |
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 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.
|
public LocalChannel(ExecutorService executor)
public <V,T extends Throwable> V call(Callable<V,T> callable) throws T extends Throwable
VirtualChannel
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.
call
in interface VirtualChannel
callable
- Callable to be executedT
- User exception defined by the callableT extends Throwable
public <V,T extends Throwable> Future<V> callAsync(@NonNull Callable<V,T> callable)
VirtualChannel
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.
callAsync
in interface VirtualChannel
Future
object that can be used to wait for the completion.public void close()
VirtualChannel
close
in interface VirtualChannel
public void join() throws InterruptedException
VirtualChannel
Channel
to be closed down.
The close-down of a Channel
might be initiated locally or remotely.join
in interface VirtualChannel
InterruptedException
- If the current thread is interrupted while waiting for the completion.public void join(long timeout) throws InterruptedException
VirtualChannel
Channel
to be closed down, but only up the given milliseconds.join
in interface VirtualChannel
timeout
- Timeout in millisecondsInterruptedException
- If the current thread is interrupted while waiting for the completion.public <T> T export(@NonNull Class<T> intf, T instance)
VirtualChannel
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).export
in interface VirtualChannel
T
- Typeintf
- 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.
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
.public void syncLocalIO() throws InterruptedException
VirtualChannel
syncLocalIO
in interface VirtualChannel
InterruptedException
Copyright © 2004–2022. All rights reserved.