edu.ucdavis.rj.Ops
Class OpInni

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
                  extended by edu.ucdavis.rj.Ops.OpInni
All Implemented Interfaces:
Op, OpRemote, java.io.Serializable, java.rmi.Remote

public class OpInni
extends OpImpl

An operation that's to be serviced via inni.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.ucdavis.rj.Ops.OpRemote
OpRemote.Helper
 
Field Summary
private static int defaultSemValue
           
protected  java.util.List<Invocation> msgList
           
static OpInni noop
          Invoking the noop operation via send has no effect.
(package private) static long serialVersionUID
           
protected  InLock theLock
           
protected  java.util.List<Invocation> waitList
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
OpInni()
          Create a new instance of an operation that's to be serviced via inni.
OpInni(boolean aNoop)
           
 
Method Summary
 Invocation call(Invocation originalInv)
          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.
 long getFirstTime()
          Return timestamp (>=0) of first invocation in this queue, if there are any invocations; otherwise, return -1.
 InLock getLock()
          Get the equivalence class lock for this operation.
(package private)  void internalSend(Invocation inv)
          Internal asynchronous invocation.
 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.
static OpInni newOpInni()
          Instantiate an OpInni.
static OpInni newSem()
          /////////////////////////////
static OpInni newSem(int initialSemValue)
          Instantiate an OpInni that looks somewhat like a semaphore.
 Invocation P()
          ///////////////
 Invocation receive()
          Get the first (oldest) pending invocation of this operation.
 void send(Invocation originalInv)
          Invoke this operation asynchronously.
 
Methods inherited from class edu.ucdavis.rj.Ops.OpImpl
call, equals, getId, hashCode, isNoop, send, V
 
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
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

theLock

protected InLock theLock

msgList

protected java.util.List<Invocation> msgList

waitList

protected java.util.List<Invocation> waitList

defaultSemValue

private static final int defaultSemValue
See Also:
Constant Field Values

noop

public static final OpInni noop
Invoking the noop operation via send has no effect. Invoking the noop operation via call has no effect; the invocation's return value is set to null. ("no effect" means other than possible side effects in parameter evaluation.) noop's invocation queue is always empty. Thus, servicing the noop operation with receive causes the servicing process to block forever; servicing the noop operation within an inni arm means that arm will never be selected for servicing.

Constructor Detail

OpInni

public OpInni()
       throws java.rmi.RemoteException
Create a new instance of an operation that's to be serviced via inni.

Throws:
java.rmi.RemoteException

OpInni

OpInni(boolean aNoop)
 throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

newOpInni

public static OpInni newOpInni()
Instantiate an OpInni. This method just calls the appropriate constructor, but hides the java.rmi.RemoteException.

Returns:
The new instance of the OpInni.

newSem

public static OpInni newSem(int initialSemValue)
Instantiate an OpInni that looks somewhat like a semaphore.

Parameters:
The - initial value of the semaphore.
Returns:
The new instance of the OpInni.

newSem

public static OpInni newSem()
/////////////////////////////


length

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

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

send

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

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

internalSend

void internalSend(Invocation inv)
Internal asynchronous invocation. Note that both call and send come through here. This operation is not noop.

Specified by:
internalSend in class OpImpl
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).

receive

public Invocation receive()
Get the first (oldest) pending invocation of this operation. Wait if no invocation is pending.

Returns:
The first pending invocation.

P

public Invocation P()
///////////////

Returns:
The first pending invocation.

call

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

Specified by:
call in interface Op
Overrides:
call in class OpImpl
Parameters:
originalInv - 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 may not be the same as originalInv. See details under Op.call(edu.ucdavis.rj.Ops.Invocation).


getFirstTime

public long getFirstTime()
Return timestamp (>=0) of first invocation in this queue, if there are any invocations; otherwise, return -1. (For noop, queue is empty.)

Returns:
The timestamp of the first pending invocation.

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.

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.

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?

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.

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.

Returns:
that iterator.
Throws:
java.rmi.RemoteException