edu.ucdavis.rj.Ops
Class OpProxy

java.lang.Object
  extended by edu.ucdavis.rj.Ops.OpProxy
All Implemented Interfaces:
Op, java.io.Serializable

public class OpProxy
extends java.lang.Object
implements java.io.Serializable, Op

An OpProxy acts like a capability in JR or SR terms. Its methods are delegated to the remote object. To get an OpProxy for an OpRemote f, just use new OpProxy(f).

See Also:
Serialized Form

Field Summary
private  int cachedImplHashCode
           
private  java.lang.String cachedImplId
           
private  boolean cachedImplIsNoop
           
private  OpRemote impl
           
 
Constructor Summary
OpProxy(OpRemote impl)
           
 
Method Summary
 Invocation call()
          Invoke this operation synchronously.
 Invocation call(Invocation inv)
          Invoke this operation synchronously.
 boolean canAppearInInni()
          Can this operation be serviced by an inni? Only an OpInni can.
 void deliverPendingMessages()
          If operation's queue of pending invocations was locked due to equivalence class locking stuff (e.g., merging), then deliver pending messages.
 OpInniIterator elements()
          Get an iterator to iterate over pending invocations of this operation.
 boolean equals(java.lang.Object other)
          xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
 long getFirstTime()
          Get the timestamp of the first (oldest) pending invocation of this operation.
 java.lang.String getId()
          Returns unique identifier for this operation.
 InLock getLock()
          Get the equivalence class lock for this operation.
 OpRemote getOpRemote()
          xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
 int hashCode()
          // force hashing to use equals.
 boolean isNoop()
          Determines whether this operation is a noop.
 boolean isRemote(java.lang.String site)
          Is this operation on a remote VM or on the current VM?
 int length()
          Returns the number of Invocations pending for this operation.
 Invocation P()
          A semaphore P (aka down) operation.
 Invocation receive()
          Get the first (oldest) pending invocation of this OpInni.
 void send()
          Invoke this operation asynchronously.
 void send(Invocation inv)
          Invoke this operation asynchronously.
 void V()
          A semaphore V (aka up) operation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

impl

private OpRemote impl

cachedImplId

private java.lang.String cachedImplId

cachedImplIsNoop

private boolean cachedImplIsNoop

cachedImplHashCode

private int cachedImplHashCode
Constructor Detail

OpProxy

public OpProxy(OpRemote impl)
Method Detail

getOpRemote

public OpRemote getOpRemote()
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

Returns:

getId

public java.lang.String getId()
                       throws java.rmi.RemoteException
Description copied from interface: Op
Returns unique identifier for this operation.

Specified by:
getId in interface Op
Returns:
that id.
Throws:
java.rmi.RemoteException

isNoop

public boolean isNoop()
               throws java.rmi.RemoteException
Description copied from interface: Op
Determines whether this operation is a noop.

Specified by:
isNoop in interface Op
Returns:
true if and only if this operation is a noop.
Throws:
java.rmi.RemoteException

getFirstTime

public long getFirstTime()
                  throws java.rmi.RemoteException
Description copied from interface: Op
Get the timestamp of the first (oldest) pending invocation of this operation.

Specified by:
getFirstTime in interface Op
Returns:
that timestamp.
Throws:
java.rmi.RemoteException

canAppearInInni

public boolean canAppearInInni()
                        throws java.rmi.RemoteException
Description copied from interface: Op
Can this operation be serviced by an inni? Only an OpInni can.

Specified by:
canAppearInInni in interface Op
Returns:
true if and only if this operation is an OpInni.
Throws:
java.rmi.RemoteException

getLock

public InLock getLock()
               throws java.rmi.RemoteException
Description copied from interface: Op
Get the equivalence class lock for this operation.

Specified by:
getLock in interface Op
Returns:
that lock.
Throws:
java.rmi.RemoteException

isRemote

public boolean isRemote(java.lang.String site)
                 throws java.rmi.RemoteException
Description copied from interface: Op
Is this operation on a remote VM or on the current VM?

Specified by:
isRemote in interface Op
Returns:
true if and only if this operation is remote.
Throws:
java.rmi.RemoteException

deliverPendingMessages

public void deliverPendingMessages()
                            throws java.rmi.RemoteException
Description copied from interface: Op
If operation's queue of pending invocations was locked due to equivalence class locking stuff (e.g., merging), then deliver pending messages.

Specified by:
deliverPendingMessages in interface Op
Throws:
java.rmi.RemoteException

elements

public OpInniIterator elements()
                        throws java.rmi.RemoteException
Description copied from interface: Op
Get an iterator to iterate over pending invocations of this operation.

Specified by:
elements in interface Op
Returns:
that iterator.
Throws:
java.rmi.RemoteException

send

public void send(Invocation inv)
          throws java.rmi.RemoteException
Description copied from interface: Op
Invoke this operation asynchronously.

Specified by:
send in interface Op
Parameters:
inv - The invocation to service.
Throws:
java.rmi.RemoteException

send

public void send()
          throws java.rmi.RemoteException
Description copied from interface: Op
Invoke this operation asynchronously. Abbreviation for this.send (new Invocation(...)); See Op.send(edu.ucdavis.rj.Ops.Invocation).

Specified by:
send in interface Op
Throws:
java.rmi.RemoteException

V

public void V()
       throws java.rmi.RemoteException
Description copied from interface: Op
A semaphore V (aka up) operation. Intended for use on OpInni's semaphore operations.

Specified by:
V in interface Op
Throws:
java.rmi.RemoteException

call

public Invocation call(Invocation inv)
                throws java.rmi.RemoteException
Description copied from interface: Op
Invoke this operation synchronously.

Specified by:
call in interface Op
Returns:
The invocation, from which the return value of the operation can be extracted.

N.B., (the reference for) the returned invocation might not be the same as inv. For example, do NOT use, e.g., Invocation inv = new Invocation(...); thefun.call(inv); System.out.println(inv.getReturnValue()); because inv's value after the call will be the same as its value before the call, and inv.getReturnValue() will likely be null. Instead, in this example, use inv = thefun.call(inv);.

Throws:
java.rmi.RemoteException

call

public Invocation call()
                throws java.rmi.RemoteException
Description copied from interface: Op
Invoke this operation synchronously. Abbreviation for this.call (new Invocation(...)); See Op.call(edu.ucdavis.rj.Ops.Invocation).

Specified by:
call in interface Op
Throws:
java.rmi.RemoteException

receive

public Invocation receive()
                   throws java.rmi.RemoteException
Description copied from interface: Op
Get the first (oldest) pending invocation of this OpInni. Wait if no invocation is pending.

Specified by:
receive in interface Op
Returns:
The first pending invocation.
Throws:
java.rmi.RemoteException

P

public Invocation P()
             throws java.rmi.RemoteException
Description copied from interface: Op
A semaphore P (aka down) operation. Intended for use on OpInni's semaphore operations.

Specified by:
P in interface Op
Throws:
java.rmi.RemoteException

length

public int length()
           throws java.rmi.RemoteException
Description copied from interface: Op
Returns the number of Invocations pending for this operation.

Specified by:
length in interface Op
Returns:
The number of pending Invocations.
Throws:
java.rmi.RemoteException

equals

public boolean equals(java.lang.Object other)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Two OpProxys are equal if their OpRemotes are. An OpProxy equals an OpRemote if the OpProxy's impl is the OpRemote. Consistent with other equals (e.g. String.equals, return false for null or a non-OpProxy and non-OpRemote object.

Overrides:
equals in class java.lang.Object
Parameters:
The - other Object to compare.
Returns:

hashCode

public int hashCode()
// force hashing to use equals. // not good for performance, but hard to discriminate between // values of OpProxy. // (Could give each one an Id, like OpImpl's id, just for this purpose.) /////////// reconsider this later... public int hashCode() { return 9999; }

Overrides:
hashCode in class java.lang.Object