edu.ucdavis.rj.Ops
Class OpImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by edu.ucdavis.rj.Ops.OpImpl
All Implemented Interfaces:
Op, OpRemote, java.io.Serializable, java.rmi.Remote
Direct Known Subclasses:
OpInni, OpMethod

public abstract class OpImpl
extends java.rmi.server.UnicastRemoteObject
implements OpRemote

Basic operation abstraction. In general, an OpImpl shouldn't be passed as a parameter. Instead, use an OpProxy. E.g., if f is an OpImpl, then pass new OpProxy(f))

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.ucdavis.rj.Ops.OpRemote
OpRemote.Helper
 
Field Summary
private  boolean aNoop
          Since have one noop per VM, need to know whether an OpImpl is a noop.
private  java.lang.String id
           
private static long seqNum
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
OpImpl()
          Create an instance of an OpImpl.
OpImpl(boolean aNoop)
          Create an instance of an OpImpl.
 
Method Summary
 Invocation call()
          Invoke this operation synchronously.
 Invocation call(Invocation originalInv)
          Invoke this operation synchronously.
 boolean equals(java.lang.Object other)
          Compares this OpImpl object with the specified object, which can be an OpRemote or an OpProxy.
 java.lang.String getId()
          Returns unique identifier for this operation.
 int hashCode()
          Returns a hash code for this OpImpl.
(package private) abstract  void internalSend(Invocation inv)
          Internal asynchronous invocation.
 boolean isNoop()
          Determines whether this operation is a noop.
abstract  int length()
          Returns the number of Invocations pending for this operation.
private  java.lang.String makeId()
          An OpImpl's Id is formed from VM name and seqNum so it is unique across the entire program.
 void send()
          Invoke this operation asynchronously.
 void send(Invocation originalInv)
          Invoke this operation asynchronously.
 void V()
          A semaphore V (aka up) operation.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
getRef, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.ucdavis.rj.Ops.Op
canAppearInInni, deliverPendingMessages, elements, getFirstTime, getLock, isRemote, P, receive
 

Field Detail

seqNum

private static long seqNum

id

private java.lang.String id

aNoop

private boolean aNoop
Since have one noop per VM, need to know whether an OpImpl is a noop. (If c is an OpProxy, comparing noop == c c.equals(noop) won't work w/o something extra.

Constructor Detail

OpImpl

public OpImpl()
       throws java.rmi.RemoteException
Create an instance of an OpImpl.

Throws:
java.rmi.RemoteException

OpImpl

OpImpl(boolean aNoop)
 throws java.rmi.RemoteException
Create an instance of an OpImpl. This is the more general case, but needed only internally.

Throws:
java.rmi.RemoteException
Method Detail

makeId

private java.lang.String makeId()
An OpImpl's Id is formed from VM name and seqNum so it is unique across the entire program.

Returns:
The Id.

getId

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

Specified by:
getId in interface Op
Returns:
that id.

isNoop

public boolean isNoop()
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.

send

public void send(Invocation originalInv)
Invoke this operation asynchronously.

Specified by:
send in interface Op
Parameters:
originalInv - The invocation to service.

send

public void send()
Invoke this operation asynchronously. Abbreviation for this.send (new Invocation(...)); See Op.send(edu.ucdavis.rj.Ops.Invocation).

Specified by:
send in interface Op

V

public void V()
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

internalSend

abstract void internalSend(Invocation inv)
Internal asynchronous invocation. Note that both call and send come through here.

Parameters:
inv - The invocation to service. It is assumed to have already been cloned and its replyOp set properly (null for send; non-null for call).

call

public Invocation call(Invocation originalInv)
Invoke this operation synchronously.

Specified by:
call in interface Op
Parameters:
inv - The invocation to service.
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);.


call

public Invocation call()
Invoke this operation synchronously. Abbreviation for this.call (new Invocation(...)); See Op.call(edu.ucdavis.rj.Ops.Invocation).

Specified by:
call in interface Op

length

public abstract int length()
Returns the number of Invocations pending for this operation.

Specified by:
length in interface Op
Returns:
The number of pending Invocations.

equals

public boolean equals(java.lang.Object other)
Compares this OpImpl object with the specified object, which can be an OpRemote or an OpProxy.

Overrides:
equals in class java.rmi.server.RemoteObject
Parameters:
other - The other Object to compare.
Returns:
true if and only if the two objects are equal.

hashCode

public int hashCode()
Returns a hash code for this OpImpl. The hashCode for noop is same across all VMs. The hashCodes for non-noops are different on and across VMs.

Overrides:
hashCode in class java.rmi.server.RemoteObject
Returns:
a hash code value for this object.