arlut.csd.ganymede
Class serverClientProxy

java.lang.Object
  |
  +--arlut.csd.ganymede.serverClientProxy
All Implemented Interfaces:
java.lang.Runnable

public class serverClientProxy
extends java.lang.Object
implements java.lang.Runnable

serverClientProxy is a partial server-side Client proxy object which buffers async client updates, coalescing update events as needed to maximize server efficiency. Each serverClientProxy object has a background thread which communicates with a remote Client in the background, allowing the Ganymede server's operations to be asynchronous with respect to Client messages.

See Also:
clientEvent

Field Summary
private static int classCounter
          Used to generate a unique name for our background thread.
private  arlut.csd.ganymede.Client client
          Our remote reference to the Client
private  java.lang.Thread commThread
          Our background communications thread, which is responsible for calling the remote Client via RMI.
private  int dequeuePtr
          Index pointer to the slot for the next item to be pulled from
private  boolean done
          If true, we have been told to shut down, and our background commThread will exit as soon as it can clear its event queue.
private  int ebSz
          Current counter for how many events we have queued
private  int enqueuePtr
          Index pointer to the slot for the next item to be place in
private  java.lang.String errorCondition
          If our commThread receives a remote exception when communicating with a remote Client, this field will become non-null, and no more communications will be attempted with that client.
private  arlut.csd.ganymede.clientEvent[] eventBuffer
          Our queue of clientEvent objects.
private  arlut.csd.ganymede.clientEvent[] lookUp
          Handy direct look-up table for events in eventBuffer
private  int maxBufferSize
          How many events we'll queue up before deciding that the Client isn't responding.
 
Constructor Summary
serverClientProxy(arlut.csd.ganymede.Client client)
           
 
Method Summary
private  void addEvent(arlut.csd.ganymede.clientEvent newEvent)
          private helper method in serverClientProxy, used to add an event to the proxy's event buffer.
private  arlut.csd.ganymede.clientEvent dequeue()
          private dequeue method.
private  void enqueue(arlut.csd.ganymede.clientEvent item)
          private enqueue method.
 boolean isAlive()
          Returns true if we are successfully in communications with the attached Client.
private  void replaceEvent(arlut.csd.ganymede.clientEvent newEvent)
          private helper method in serverClientProxy, used to add an event to the proxy's event buffer.
 void run()
          The serverClientProxy's background thread's run() method.
 void sendMessage(int type, java.lang.String message)
          This method is used to submit a message to be sent to the client.
 void shutdown()
          This method shuts down the background thread.
private  void throwOverflow()
          This method throws a remoteException which describes the state of the event buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classCounter

private static int classCounter

Used to generate a unique name for our background thread.


client

private arlut.csd.ganymede.Client client

Our remote reference to the Client


commThread

private java.lang.Thread commThread

Our background communications thread, which is responsible for calling the remote Client via RMI.


eventBuffer

private final arlut.csd.ganymede.clientEvent[] eventBuffer

Our queue of clientEvent objects.


enqueuePtr

private int enqueuePtr

Index pointer to the slot for the next item to be place in


dequeuePtr

private int dequeuePtr

Index pointer to the slot for the next item to be pulled from


ebSz

private int ebSz

Current counter for how many events we have queued


maxBufferSize

private final int maxBufferSize

How many events we'll queue up before deciding that the Client isn't responding.

See Also:
Constant Field Values

done

private volatile boolean done

If true, we have been told to shut down, and our background commThread will exit as soon as it can clear its event queue.

.


errorCondition

private java.lang.String errorCondition

If our commThread receives a remote exception when communicating with a remote Client, this field will become non-null, and no more communications will be attempted with that client.


lookUp

private arlut.csd.ganymede.clientEvent[] lookUp

Handy direct look-up table for events in eventBuffer

Constructor Detail

serverClientProxy

public serverClientProxy(arlut.csd.ganymede.Client client)
Method Detail

isAlive

public boolean isAlive()

Returns true if we are successfully in communications with the attached Client.


shutdown

public void shutdown()

This method shuts down the background thread.


sendMessage

public void sendMessage(int type,
                        java.lang.String message)
                 throws java.rmi.RemoteException

This method is used to submit a message to be sent to the client. If the serverClientProxy has already had its shutdown() method called, sendMessage() will silently fail, and the message will not be queued.

java.rmi.RemoteException

run

public void run()

The serverClientProxy's background thread's run() method. This method runs in the Client proxy thread to read events from this console's serverClientProxy eventBuffer and send them down to the Client.

Specified by:
run in interface java.lang.Runnable

addEvent

private void addEvent(arlut.csd.ganymede.clientEvent newEvent)
               throws java.rmi.RemoteException

private helper method in serverClientProxy, used to add an event to the proxy's event buffer. If the buffer already contains an event of the same type as newEvent, both events will be sent to the Client, in chronological order.

java.rmi.RemoteException

replaceEvent

private void replaceEvent(arlut.csd.ganymede.clientEvent newEvent)
                   throws java.rmi.RemoteException

private helper method in serverClientProxy, used to add an event to the proxy's event buffer. If the buffer already contains an event of the same type as newEvent, the old event's contents will be replaced with the new, and the remote client will never be notified of the old event's contents.

java.rmi.RemoteException

throwOverflow

private void throwOverflow()
                    throws java.rmi.RemoteException

This method throws a remoteException which describes the state of the event buffer. This is called from addEvent and replaceEvent.

java.rmi.RemoteException

enqueue

private void enqueue(arlut.csd.ganymede.clientEvent item)
private enqueue method.


dequeue

private arlut.csd.ganymede.clientEvent dequeue()
private dequeue method. assumes that the calling code will check bounds.