water
Class RPC<V extends DTask>

java.lang.Object
  extended by water.RPC<V>
All Implemented Interfaces:
java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed, java.util.concurrent.Future<V>, jsr166y.ForkJoinPool.ManagedBlocker

public class RPC<V extends DTask>
extends java.lang.Object
implements java.util.concurrent.Future<V>, java.util.concurrent.Delayed, jsr166y.ForkJoinPool.ManagedBlocker

A remotely executed FutureTask. Flow is: 1- Build a DTask (or subclass). This object will be replicated remotely. 2- Make a RPC object, naming the target Node. Call (re)call(). Call get() to block for result, or cancel() or isDone(), etc. Caller can also arrange for caller.tryComplete() to be called in a F/J thread, to support completion style execution (i.e. Continuation Passing Style). 3- DTask will be serialized and sent to the target; small objects via UDP and large via TCP (using AutoBuffer & auto-gen serializers). 4- An RPC UDP control packet will be sent to target; this will also contain the DTask if its small enough. 4.5- The network may replicate (or drop) the UDP packet. Dups may arrive. 4.5- Sender may timeout, and send dup control UDP packets. 5- Target will capture a UDP packet, and begin filtering dups (via task#). 6- Target will deserialize the DTask, and call DTask.invoke() in a F/J thread. 6.5- Target continues to filter (and drop) dup UDP sends (and timeout resends) 7- Target finishes call, and puts result in DTask. 8- Target serializes result and sends to back to sender. 9- Target sends an ACK back (may be combined with the result if small enough) 10- Target puts the ACK in H2ONode.TASKS for later filtering. 10.5- Target receives dup UDP request, then replies with ACK back. 11- Sender receives ACK result; deserializes; notifies waiters 12- Sender sends ACKACK back 12.5- Sender recieves dup ACK's, sends dup ACKACK's back 13- Target recieves ACKACK, removes TASKS tracking


Nested Class Summary
static class RPC.RemoteHandler
           
static class RPC.RPCCall
           
 
Constructor Summary
RPC(H2ONode target, V dtask)
           
RPC(H2ONode target, V dtask, float f)
           
 
Method Summary
 boolean block()
          Possibly blocks the current thread, for example waiting for a lock or condition.
 RPC<V> call()
           
static
<DT extends DTask>
RPC<DT>
call(H2ONode target, DT dtask)
           
 boolean cancel(boolean mayInterruptIfRunning)
           
 int compareTo(java.util.concurrent.Delayed t)
           
 V get()
           
 V get(long timeout, java.util.concurrent.TimeUnit unit)
           
 long getDelay(java.util.concurrent.TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
 boolean isReleasable()
          Returns true if blocking is unnecessary.
protected  int response(AutoBuffer ab)
           
 RPC<V> setTaskNum()
           
 int size_rez()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RPC

public RPC(H2ONode target,
           V dtask)

RPC

public RPC(H2ONode target,
           V dtask,
           float f)
Method Detail

call

public static <DT extends DTask> RPC<DT> call(H2ONode target,
                                              DT dtask)

setTaskNum

public RPC<V> setTaskNum()

call

public RPC<V> call()

get

public V get()
Specified by:
get in interface java.util.concurrent.Future<V extends DTask>

isReleasable

public boolean isReleasable()
Description copied from interface: jsr166y.ForkJoinPool.ManagedBlocker
Returns true if blocking is unnecessary.

Specified by:
isReleasable in interface jsr166y.ForkJoinPool.ManagedBlocker

block

public boolean block()
Description copied from interface: jsr166y.ForkJoinPool.ManagedBlocker
Possibly blocks the current thread, for example waiting for a lock or condition.

Specified by:
block in interface jsr166y.ForkJoinPool.ManagedBlocker
Returns:
true if no additional blocking is necessary (i.e., if isReleasable would return true)

get

public final V get(long timeout,
                   java.util.concurrent.TimeUnit unit)
Specified by:
get in interface java.util.concurrent.Future<V extends DTask>

isDone

public final boolean isDone()
Specified by:
isDone in interface java.util.concurrent.Future<V extends DTask>

isCancelled

public final boolean isCancelled()
Specified by:
isCancelled in interface java.util.concurrent.Future<V extends DTask>

cancel

public final boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface java.util.concurrent.Future<V extends DTask>

response

protected int response(AutoBuffer ab)

size_rez

public int size_rez()

getDelay

public final long getDelay(java.util.concurrent.TimeUnit unit)
Specified by:
getDelay in interface java.util.concurrent.Delayed

compareTo

public final int compareTo(java.util.concurrent.Delayed t)
Specified by:
compareTo in interface java.lang.Comparable<java.util.concurrent.Delayed>