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 static int classCounter
          Used to generate a unique name for our background thread.
private  java.lang.Thread commThread
          Our background communications thread, which is responsible for calling the admin console via RMI.
private static boolean debug
           
private  int dequeuePtr
           
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
           
private  int enqueuePtr
           
private  arlut.csd.ganymede.adminEvent[] eventBuffer
          Our queue of adminEvent objects.
private  arlut.csd.ganymede.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  arlut.csd.ganymede.Admin remoteConsole
          Our remote reference to the admin console client
 
Constructor Summary
serverAdminProxy(arlut.csd.ganymede.Admin remoteConsole)
           
 
Method Summary
private  void addEvent(arlut.csd.ganymede.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 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.
private  arlut.csd.ganymede.adminEvent dequeue()
          private dequeue method.
private  void enqueue(arlut.csd.ganymede.adminEvent item)
          private enqueue method.
 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(byte method, java.lang.Object param)
          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, toString, wait, wait, wait
 

Field Detail

debug

private static final boolean debug
See Also:
Constant Field Values

classCounter

private static int classCounter

Used to generate a unique name for our background thread.


commThread

private java.lang.Thread commThread

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


eventBuffer

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

Our queue of adminEvent objects.


enqueuePtr

private int enqueuePtr

dequeuePtr

private int dequeuePtr

ebSz

private int ebSz

maxBufferSize

private final int maxBufferSize

How many events we'll queue up before deciding that the admin console isn't responding. Right now all events are either being handled with coalesce or replace, so we should never, ever have more objects in our eventBuffer than we have types of events.

See Also:
Constant Field Values

remoteConsole

private arlut.csd.ganymede.Admin remoteConsole

Our remote reference to the admin console client


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.

.

Volatile because we use this as part of our thread synchronization logic.


lookUp

private arlut.csd.ganymede.adminEvent[] lookUp

Handy direct look-up table for events in eventBuffer

Constructor Detail

serverAdminProxy

public serverAdminProxy(arlut.csd.ganymede.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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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
java.rmi.RemoteException

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.
java.rmi.RemoteException

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.
java.rmi.RemoteException

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(arlut.csd.ganymede.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.

java.rmi.RemoteException

replaceEvent

private void replaceEvent(byte method,
                          java.lang.Object param)
                   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 method, the old event's contents will be replaced with param, and the admin console 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. 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.

java.rmi.RemoteException

enqueue

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


dequeue

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