uka.karmi.stream
Class StreamClientConnection

java.lang.Object
  extended byuka.transport.JdkMarshalContext
      extended byuka.karmi.rmi.Connection
          extended byuka.karmi.rmi.ClientConnection
              extended byuka.karmi.stream.StreamClientConnection
All Implemented Interfaces:
CallHandler.BlockingOperation, Constants

public abstract class StreamClientConnection
extends ClientConnection
implements Constants

Base class for all client-side connections in stream-based technologies. A StreamClientConnection encapsulates an input and an output stream for marshaling and unmarshaling method arguments and results.

A connection is used on the client side by the stub to marshal the method arguments.

Author:
Bernhard Haumacher
See Also:
RemoteStub

Field Summary
(package private)  StreamTechnology.CallBack cb
           
private  DGCMarshalContext marshalContext
           
static int SIZE_HEADER
           
private  DGCUnmarshalContext unmarshalContext
           
(package private)  long unusedSince
          Time stamp managed by the connection collector.
 
Fields inherited from class uka.karmi.rmi.ClientConnection
handler, next, returnCode
 
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
 
Fields inherited from interface uka.karmi.rmi.server.Constants
APP_CALL, COLLECTIVE_OPERATION, DGC_ACK, DGC_CALL, DGC_CALL_ASYNC, MID_BARRIER, MID_COLLECTIVE_EXCHANGE, MID_COLLECTIVE_UPDATE, MID_EXCLUSIVE_LOCK, MID_EXCLUSIVE_UPDATE, MID_REQUEST_TICKET, MID_REQUEST_WAIT, MID_RMA, MID_SERVICE_CREATE_REPLICA, MID_SERVICE_GET_STUB, MID_SERVICE_INTERRUPT, MID_SERVICE_MIGRATE, MID_SERVICE_UPDATE_REFERENCES, MID_WAKEUP, SERVICE_CALL, SKELETON_EXTENSION, STUB_EXTENSION
 
Constructor Summary
StreamClientConnection(MarshalOutputStream snd, MarshalInputStream rcv, StreamTechnology.CallBack cb)
           
 
Method Summary
 void close()
           
 void closeAsynchronousCall()
           
 void closeExceptionally()
          If an unmashaling problem occurs, this method is called form the sub to mark this connection as unusable.
 void closeReceiveDgcResult()
           
 void closeReceiveResult()
          Called after the result of the method invocation was unmarshaled and just before a received exception is thrown.
 void closeSendCall()
          Submits the invocation to the remote server implementation.
 void closeSendDgcCall()
           
 boolean openReceiveDgcResult()
           
 boolean openReceiveResult()
          Called by the generated stub method just before the return value is unmarshaled.
 void openSendAsynchronousCall()
           
 void openSendCall()
          Initializes the remote method invocation.
private  void reuseConnection()
           
private  void sendHeader()
           
 
Methods inherited from class uka.karmi.rmi.ClientConnection
dispatchInterrupt, doBlocking, finishMigration, getBlockingProblem, getRemoteUTID, setContext, startMigration
 
Methods inherited from class uka.karmi.rmi.Connection
toString, toStringMembers
 
Methods inherited from class uka.transport.JdkMarshalContext
areObjectsReceived, areObjectsSent, 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

unmarshalContext

private DGCUnmarshalContext unmarshalContext

marshalContext

private DGCMarshalContext marshalContext

unusedSince

long unusedSince
Time stamp managed by the connection collector. After a remote method invocation a connection is not closed immediately but inserted into a linked list of unused connections for reuse in another remote method invocation. If no reuse occurs in a certain time, the connection is closed.

See Also:
StreamTechnology.collectConnections()

SIZE_HEADER

public static final int SIZE_HEADER

cb

StreamTechnology.CallBack cb
Constructor Detail

StreamClientConnection

public StreamClientConnection(MarshalOutputStream snd,
                              MarshalInputStream rcv,
                              StreamTechnology.CallBack cb)
Method Detail

close

public void close()
           throws java.io.IOException
Overrides:
close in class JdkMarshalContext
Throws:
java.io.IOException

openSendCall

public void openSendCall()
                  throws java.io.IOException
Description copied from class: ClientConnection

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.

Specified by:
openSendCall in class ClientConnection
Throws:
java.io.IOException
See Also:
RemoteStub

openSendAsynchronousCall

public void openSendAsynchronousCall()
                              throws java.io.IOException
Specified by:
openSendAsynchronousCall in class ClientConnection
Throws:
java.io.IOException

sendHeader

private void sendHeader()
                 throws java.io.IOException
Throws:
java.io.IOException

closeSendCall

public void closeSendCall()
                   throws java.io.IOException
Description copied from class: ClientConnection
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.

Specified by:
closeSendCall in class ClientConnection
Throws:
java.io.IOException
See Also:
RemoteStub

closeSendDgcCall

public void closeSendDgcCall()
                      throws java.io.IOException
Specified by:
closeSendDgcCall in class ClientConnection
Throws:
java.io.IOException
See Also:
ClientConnection.closeSendCall()

openReceiveResult

public boolean openReceiveResult()
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Description copied from class: ClientConnection

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.

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

openReceiveDgcResult

public boolean openReceiveDgcResult()
                             throws java.io.IOException
Throws:
java.io.IOException

closeReceiveResult

public void closeReceiveResult()
                        throws RemoteException
Description copied from class: ClientConnection

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.

Specified by:
closeReceiveResult in class ClientConnection
Throws:
RemoteException
See Also:
RemoteStub

closeAsynchronousCall

public void closeAsynchronousCall()
                           throws RemoteException
Specified by:
closeAsynchronousCall in class Connection
Throws:
RemoteException

reuseConnection

private void reuseConnection()
                      throws RemoteException
Throws:
RemoteException

closeExceptionally

public void closeExceptionally()
Description copied from class: ClientConnection

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.

Specified by:
closeExceptionally in class ClientConnection

closeReceiveDgcResult

public void closeReceiveDgcResult()
                           throws RemoteException
Specified by:
closeReceiveDgcResult in class ClientConnection
Throws:
RemoteException
See Also:
ClientConnection.closeReceiveResult()