arlut.csd.ganymede
Class serverAdminProxy

java.lang.Object
  |
  +--arlut.csd.ganymede.serverAdminProxy
All Implemented Interfaces:
Admin, java.rmi.Remote, java.lang.Runnable

public class serverAdminProxy
extends java.lang.Object
implements Admin, java.lang.Runnable

serverAdminProxy is a server-side Admin object which buffers console status updates, coalescing update events as needed to maximize server efficiency. Each serverAdminProxy object has a background thread which communicates with an admin console in the background, allowing the Ganymede server's operations to be asynchronous with respect to admin console updates.

See Also:
adminEvent

Field Summary
private  java.lang.Thread commThread
          Our background communications thread, which is responsible for calling the admin console via RMI.
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  java.lang.String errorCondition
          If our commThread receives a remote exception when communicating with an admin console, this field will become non-null, and no more communications will be attempted with that console.
private  java.util.Vector eventBuffer
          Our queue of adminEvent objects.
private  adminEvent[] lookUp
          Handy direct look-up table for events in eventBuffer
private  int maxBufferSize
          How many events we'll queue up before deciding that the admin console isn't responding.
private  Admin remoteConsole
          Our remote reference to the admin console client
 
Constructor Summary
serverAdminProxy(Admin remoteConsole)
           
 
Method Summary
private  void addEvent(adminEvent newEvent)
          private helper method in serverAdminProxy, used to add an event to the proxy's event buffer.
 void changeAdmins(java.lang.String adminStatus)
          This method is called by the Ganymede server to update the number of admin consoles attached to the server.
 void changeState(java.lang.String state)
          This method is called by the Ganymede server to update the admin console's server state display.
 void changeStatus(java.lang.String status)
          This method is called by the Ganymede server to add to the admin console's log display.
 void changeStatus(java.lang.String status, boolean timeLabelled)
          This method is called by the Ganymede server to add to the admin console's log display.
 void changeTasks(java.util.Vector tasks)
          This method is called by the Ganymede server to update the admin console's task table.
 void changeUsers(java.util.Vector entries)
          This method is called by the Ganymede server to update the admin console's connected user table.
 void forceDisconnect(java.lang.String reason)
          Callback: The server can tell us to disconnect if the server is going down.
 java.lang.String getName()
          This method is called by the Ganymede server to obtain the username given when the admin console was started.
 java.lang.String getPassword()
          This method is called by the Ganymede server to obtain the password given when the admin console was started.
 boolean isAlive()
          Returns true if we are successfully in communications with the attached admin console.
private  void replaceEvent(adminEvent newEvent)
          private helper method in serverAdminProxy, used to add an event to the proxy's event buffer.
 void run()
          The serverAdminProxy's background thread's run() method.
 void setLastDumpTime(java.util.Date date)
          This method is called by the Ganymede server to set the last dump date in the admin console.
 void setLocksHeld(int locks)
          This method is called by the Ganymede server to set the number of locks held in the admin console.
 void setMemoryState(long freeMem, long totalMem)
          This method is called by the Ganymede server to update the memory status display in the admin console.
 void setObjectsCheckedOut(int objs)
          This method is called by the Ganymede server to set the number of objects checked out in the admin console.
 void setServerStart(java.util.Date date)
          This method is called by the Ganymede server to set the server start date in the admin console.
 void setTransactionsInJournal(int trans)
          This method is called by the Ganymede server to set the number of transactions in the server's journal in the admin console.
 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, registerNatives, toString, wait, wait, wait
 

Field Detail

commThread

private java.lang.Thread commThread

Our background communications thread, which is responsible for calling the admin console via RMI.


eventBuffer

private java.util.Vector eventBuffer

Our queue of adminEvent objects.


maxBufferSize

private int maxBufferSize

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


remoteConsole

private Admin remoteConsole

Our remote reference to the admin console client


done

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.

.


errorCondition

private java.lang.String errorCondition

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


lookUp

private adminEvent[] lookUp

Handy direct look-up table for events in eventBuffer

Constructor Detail

serverAdminProxy

public serverAdminProxy(Admin remoteConsole)
Method Detail

isAlive

public boolean isAlive()

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


shutdown

public void shutdown()

This method shuts down the background thread.


getName

public java.lang.String getName()
                         throws java.rmi.RemoteException

This method is called by the Ganymede server to obtain the username given when the admin console was started.

Specified by:
getName in interface Admin

getPassword

public java.lang.String getPassword()
                             throws java.rmi.RemoteException

This method is called by the Ganymede server to obtain the password given when the admin console was started.

Specified by:
getPassword in interface Admin

forceDisconnect

public void forceDisconnect(java.lang.String reason)
                     throws java.rmi.RemoteException
Callback: The server can tell us to disconnect if the server is going down.
Specified by:
forceDisconnect in interface Admin

setServerStart

public void setServerStart(java.util.Date date)
                    throws java.rmi.RemoteException

This method is called by the Ganymede server to set the server start date in the admin console.

Specified by:
setServerStart in interface Admin

setLastDumpTime

public void setLastDumpTime(java.util.Date date)
                     throws java.rmi.RemoteException

This method is called by the Ganymede server to set the last dump date in the admin console.

Specified by:
setLastDumpTime in interface Admin

setTransactionsInJournal

public void setTransactionsInJournal(int trans)
                              throws java.rmi.RemoteException

This method is called by the Ganymede server to set the number of transactions in the server's journal in the admin console.

Specified by:
setTransactionsInJournal in interface Admin

setObjectsCheckedOut

public void setObjectsCheckedOut(int objs)
                          throws java.rmi.RemoteException

This method is called by the Ganymede server to set the number of objects checked out in the admin console.

Specified by:
setObjectsCheckedOut in interface Admin

setLocksHeld

public void setLocksHeld(int locks)
                  throws java.rmi.RemoteException

This method is called by the Ganymede server to set the number of locks held in the admin console.

Specified by:
setLocksHeld in interface Admin

setMemoryState

public void setMemoryState(long freeMem,
                           long totalMem)
                    throws java.rmi.RemoteException

This method is called by the Ganymede server to update the memory status display in the admin console.

Specified by:
setMemoryState in interface Admin

changeState

public void changeState(java.lang.String state)
                 throws java.rmi.RemoteException

This method is called by the Ganymede server to update the admin console's server state display.

Specified by:
changeState in interface Admin

changeStatus

public void changeStatus(java.lang.String status)
                  throws java.rmi.RemoteException

This method is called by the Ganymede server to add to the admin console's log display.

Specified by:
changeStatus in interface Admin

changeStatus

public void changeStatus(java.lang.String status,
                         boolean timeLabelled)
                  throws java.rmi.RemoteException

This method is called by the Ganymede server to add to the admin console's log display.


changeAdmins

public void changeAdmins(java.lang.String adminStatus)
                  throws java.rmi.RemoteException

This method is called by the Ganymede server to update the number of admin consoles attached to the server.

Specified by:
changeAdmins in interface Admin

changeUsers

public void changeUsers(java.util.Vector entries)
                 throws java.rmi.RemoteException

This method is called by the Ganymede server to update the admin console's connected user table.

Specified by:
changeUsers in interface Admin
Parameters:
entries - a Vector of AdminEntry login description objects.

changeTasks

public void changeTasks(java.util.Vector tasks)
                 throws java.rmi.RemoteException

This method is called by the Ganymede server to update the admin console's task table.

Specified by:
changeTasks in interface Admin
Parameters:
tasks - a Vector of scheduleHandle objects describing the tasks registered in the Ganymede server.

run

public void run()

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

Specified by:
run in interface java.lang.Runnable

addEvent

private void addEvent(adminEvent newEvent)
               throws java.rmi.RemoteException

private helper method in serverAdminProxy, 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 admin console, in chronological order.


replaceEvent

private void replaceEvent(adminEvent newEvent)
                   throws java.rmi.RemoteException

private helper method in serverAdminProxy, 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 admin console will never be notified of the old event's contents.


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. The GanymedeAdmin code that calls the Admin proxy methods in serverAdminProxy take repeated remote exceptions as an indication that they need to detach the admin console, which is why we use RemoteException.