uka.karmi.rmi
Class ClientConnection

java.lang.Object
  extended byuka.transport.JdkMarshalContext
      extended byuka.karmi.rmi.Connection
          extended byuka.karmi.rmi.ClientConnection
All Implemented Interfaces:
CallHandler.BlockingOperation
Direct Known Subclasses:
StreamClientConnection

public abstract class ClientConnection
extends Connection
implements CallHandler.BlockingOperation

Connection objects represent the context of a remote method invocation. Stub and skeleton objects use connections to marshal and unmarshal method arguments and results.

Author:
Bernhard Haumacher
See Also:
StreamClientConnection

Field Summary
protected  CallHandler handler
          The call handler responsible for this connection.
 ClientConnection next
          Implements list functionality.
private  java.lang.Throwable receivingProblem
           
protected  byte returnCode
           
private  MarshalOutput snd
          The underlying marshal stream used to set migration options before starting a call.
 
Fields inherited from class uka.karmi.rmi.Connection
cid, mid, oid, RETURN_EXCEPTION, RETURN_INTERNAL, RETURN_INTERRUPT, RETURN_OK, tid
 
Fields inherited from class uka.transport.JdkMarshalContext
 
Constructor Summary
ClientConnection(MarshalOutput snd, MarshalInput rcv)
           
 
Method Summary
abstract  void closeExceptionally()
          If an unmashaling problem occurs, this method is called form the sub to mark this connection as unusable.
abstract  void closeReceiveDgcResult()
           
abstract  void closeReceiveResult()
          Called after the result of the method invocation was unmarshaled and just before a received exception is thrown.
abstract  void closeSendCall()
          Submits the invocation to the remote server implementation.
abstract  void closeSendDgcCall()
           
 boolean dispatchInterrupt()
          If a thread that waits for this blocking operation to complete is interrupted, this method is called to anounce the interrupt.
 void doBlocking()
           
 void finishMigration()
           
 java.lang.Throwable getBlockingProblem()
           
(package private)  ClientConnection getOutOfOrderContext(byte cid, int mid, int oid, long tid)
          Creates a context for an out-of-order invocation along this connection.
abstract  UTID getRemoteUTID()
          Returns an identifier for the technology, this connection is connected to.
abstract  boolean openReceiveResult()
          Called by the generated stub method just before the return value is unmarshaled.
abstract  void openSendAsynchronousCall()
           
abstract  void openSendCall()
          Initializes the remote method invocation.
 void setContext(byte cid, int oid, int mid, long tid)
           
 void startMigration(java.lang.Object obj)
          Start the remote object migration process for object obj.
 
Methods inherited from class uka.karmi.rmi.Connection
closeAsynchronousCall, toString, toStringMembers
 
Methods inherited from class uka.transport.JdkMarshalContext
areObjectsReceived, areObjectsSent, close, closeReceivePrimitive, closeSendPrimitive, flush, getMarshalStream, getUnmarshalStream, openReceivePrimitive, openSendPrimitive, receiveBoolean, receiveByte, receiveChar, receiveDouble, receiveFloat, receiveInt, receiveLong, receiveObject, receiveSingleBoolean, receiveSingleByte, receiveSingleChar, receiveSingleDouble, receiveSingleFloat, receiveSingleInt, receiveSingleLong, resetReceive, resetSend, sendBoolean, sendByte, sendChar, sendDouble, sendFloat, sendInt, sendLong, sendObject, sendSingleBoolean, sendSingleByte, sendSingleChar, sendSingleDouble, sendSingleFloat, sendSingleInt, sendSingleLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

public ClientConnection next
Implements list functionality. Unused connections can be linked together for future re-usage.


handler

protected final CallHandler handler
The call handler responsible for this connection. When this connection is active, its call handler can be used to dispatch a callback method invocation re-eintering this machine.

See Also:
CallHandler.dispatch(CallHandler.CallbackOperation)

snd

private MarshalOutput snd
The underlying marshal stream used to set migration options before starting a call.


returnCode

protected byte returnCode
See Also:
doBlocking()

receivingProblem

private java.lang.Throwable receivingProblem
See Also:
getBlockingProblem()
Constructor Detail

ClientConnection

public ClientConnection(MarshalOutput snd,
                        MarshalInput rcv)
Method Detail

getRemoteUTID

public abstract UTID getRemoteUTID()
Returns an identifier for the technology, this connection is connected to. This is not necessarily the same as the location of the target object that is being called. If the target object can not be reached directly, the connection is routed through a proxy object. In this case, getRemoteUTID() identifies only the first hop of the connection.


getOutOfOrderContext

ClientConnection getOutOfOrderContext(byte cid,
                                      int mid,
                                      int oid,
                                      long tid)
                                throws RemoteException
Creates a context for an out-of-order invocation along this connection. The created connection targets the same machine than this connection.

Throws:
RemoteException

setContext

public void setContext(byte cid,
                       int oid,
                       int mid,
                       long tid)
See Also:
Technology.getContext(byte, int, int, long, UTID)

startMigration

public void startMigration(java.lang.Object obj)
Start the remote object migration process for object obj. Object migration is implemented in KaRMI directly. A remote object is migrated to another machine by announcing the server implementation object (obj) to the underlying marshal stream to prevent replacing this object by a corresponding stub object during the next call. After startMigration() has been called, the given server implementation object can be passed as parameter to a migration service call. This causes that the remote server implementation is marshaled to the remote node, where it can be re-exported as remote object. The service call can transmit a remote reference to the migrated object as result. This remote reference can be used to redirect future remote calls to the remote server object to its new location.

Parameters:
obj - the object that should be migrated.

finishMigration

public void finishMigration()
See Also:
startMigration(Object)

openSendCall

public abstract void openSendCall()
                           throws java.io.IOException

Initializes the remote method invocation. This method is called by the stub just before marshaling the method arguments.

This method belongs to the client-side stub interface of the connection.

Throws:
java.io.IOException
See Also:
RemoteStub

openSendAsynchronousCall

public abstract void openSendAsynchronousCall()
                                       throws java.io.IOException
Throws:
java.io.IOException

closeSendCall

public abstract void closeSendCall()
                            throws java.io.IOException
Submits the invocation to the remote server implementation. This method is called by the stub method after marshaling the method parameters.

This method belongs to the client-side stub interface of the connection.

Throws:
java.io.IOException
See Also:
RemoteStub

closeSendDgcCall

public abstract void closeSendDgcCall()
                               throws java.io.IOException
Throws:
java.io.IOException
See Also:
closeSendCall()

openReceiveResult

public abstract boolean openReceiveResult()
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException

Called by the generated stub method just before the return value is unmarshaled. The result indicates whether the remote method invocation completed by returning a result or by throwing an exception. If an exception was thrown, it must be unmarshaled and rethrown from the stub method.

This method belongs to the client-side stub interface of the connection.

Returns:
true if there was a normal return, false if an exception was thrown.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
RemoteStub

closeReceiveResult

public abstract void closeReceiveResult()
                                 throws RemoteException

Called after the result of the method invocation was unmarshaled and just before a received exception is thrown. The call to this method informs the technology that the communication link can be reused by another call.

This method belongs to the client-side stub interface of the connection.

Throws:
RemoteException
See Also:
RemoteStub

closeExceptionally

public abstract void closeExceptionally()

If an unmashaling problem occurs, this method is called form the sub to mark this connection as unusable. During a remote call either closeReceiveResult() or closeExceptionally() is called.

This method declares no exceptions, because when it is called another exception is on the way. All other exceptions are less important and must be ignored.

This method belongs to the client-side stub interface of the connection.


closeReceiveDgcResult

public abstract void closeReceiveDgcResult()
                                    throws RemoteException
Throws:
RemoteException
See Also:
closeReceiveResult()

doBlocking

public void doBlocking()
Specified by:
doBlocking in interface CallHandler.BlockingOperation
See Also:
CallHandler.BlockingOperation

getBlockingProblem

public java.lang.Throwable getBlockingProblem()
Specified by:
getBlockingProblem in interface CallHandler.BlockingOperation
See Also:
CallHandler.BlockingOperation

dispatchInterrupt

public boolean dispatchInterrupt()
                          throws RemoteException
Description copied from interface: CallHandler.BlockingOperation
If a thread that waits for this blocking operation to complete is interrupted, this method is called to anounce the interrupt. It returns whether the interrupt was delivered successfully. If the method returns false, the interrupt will be signaled to the waiting thread when it resumes operation.

Specified by:
dispatchInterrupt in interface CallHandler.BlockingOperation
Throws:
RemoteException
See Also:
CallHandler.BlockingOperation