arlut.csd.ganymede
Class GanymedeAdmin

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--arlut.csd.ganymede.GanymedeAdmin
All Implemented Interfaces:
adminSession, java.rmi.Remote, java.io.Serializable, java.rmi.server.Unreferenced

final class GanymedeAdmin
extends java.rmi.server.UnicastRemoteObject
implements adminSession, java.rmi.server.Unreferenced

GanymedeAdmin is the server-side implementation of the adminSession interface; GanymedeAdmin provides the means by which privileged users can carry out privileged operations on the Ganymede server, including status monitoring and administrative activities.

GanymedeAdmin is actually a dual purpose class. One the one hand, GanymedeAdmin implements adminSession, providing a hook for the admin console to talk to. On the other, GanymedeAdmin contains a lot of static fields and methods which the server code uses to communicate information to any admin consoles that are attached to the server at any given time.


Field Summary
private  java.lang.String adminName
          The name that the admin console authenticated with.
private static java.util.Vector badConsoles
          Static vector of GanymedeAdmin instances for which remote exceptions were caught in the static update methods.
private  java.lang.String clientHost
          The name or ip address of the system that this admin console is attached from.
private static java.util.Vector consoles
          Static vector of GanymedeAdmin instances, used to keep track of the attached admin consoles.
private static boolean debug
           
private static long freeMem
          Free memory statistic that the server sends to admin consoles
private  boolean fullprivs
          If true, the admin console is attached with full privileges to run tasks, shut down the server, and so on.
private static java.util.Date lastDumpDate
          Timestamp that the Ganymede server last consolidated its journal file and dumped its database to disk.
private  arlut.csd.ganymede.serverAdminProxy proxy
          A server-side proxy that maintains an event queue for the admin console attached to this GanymedeAdmin object.
private static java.lang.String state
          The overall server state..
private static long totalMem
          Total memory statistic that the server sends to admin consoles
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
GanymedeAdmin(arlut.csd.ganymede.Admin admin, boolean fullprivs, java.lang.String adminName, java.lang.String clientHost)
          This is the GanymedeAdmin constructor, used to create a new server-side admin console attachment.
 
Method Summary
static void closeAllConsoles(java.lang.String reason)
          This static method handles sending disconnect messages to all attached consoles and cleaning up the GanymedeAdmin.consoles Vector.
private static void detachBadConsoles()
          This private static method is called to remove any consoles that have experienced RMI failures from the static GanymedeAdmin.consoles vector.
 arlut.csd.ganymede.ReturnVal disableTask(java.lang.String name)
          Causes a registered task to be made ineligible for execution until enableTask() is called.
private  void doRefreshTasks(java.util.Vector scheduleHandles)
          This private method updates the task status table on this admin console
private  void doRefreshUsers(java.util.Vector entries)
          This private method updates the user status table on this admin console
private  void doSetState()
          This private method updates the server state display on this admin console
private  void doUpdateCheckedOut()
          This private method updates the objects checked out display on this admin console
private  void doUpdateLastDump()
          This private method updates the last dump time on this admin console
private  void doUpdateLocksHeld()
          This private method updates the number of locks held display on this admin console
private  void doUpdateMemState()
          This private method updates the memory statistics display on this admin console
private  void doUpdateTransCount()
          This private method is used to update this admin console handle's transaction count.
 arlut.csd.ganymede.ReturnVal dumpDB()
          dump the current state of the db to disk
 arlut.csd.ganymede.SchemaEdit editSchema()
          Lock the server to prevent client logins and edit the server schema.
 arlut.csd.ganymede.ReturnVal enableTask(java.lang.String name)
          Causes a task that was temporarily disabled by disableTask() to be available for execution again.
 arlut.csd.ganymede.ReturnVal forceBuild()
          This method is called by admin console code to force a complete rebuild of all external builds.
 void forceDisconnect(java.lang.String reason)
          This public method forces a disconnect of the remote admin console and cleans up the proxy.
private static void handleConsoleRMIFailure(arlut.csd.ganymede.GanymedeAdmin console, java.rmi.RemoteException ex)
          This private static method handles communications link failures.
 arlut.csd.ganymede.ReturnVal kill(java.lang.String user)
          Kick a user off of the Ganymede server on behalf of this admin console
 arlut.csd.ganymede.ReturnVal killAll()
          Kick all users off of the Ganymede server on behalf of this admin console
 void logout()
          Disconnect the remote admin console associated with this object
 void logout(java.lang.String reason)
          Disconnect the remote admin console associated with this object
 void refreshMe()
          This method lets the admin console explicitly request a refresh.
static void refreshTasks()
          This static method is used to update the list of connnected users that appears in any admin consoles attached to the Ganymede server.
static void refreshUsers()
          This static method is used to update the list of connnected users that appears in any admin consoles attached to the Ganymede server.
 arlut.csd.ganymede.ReturnVal runEmbeddedSweep()
          Removes any embedded objects which do not have containers.
 arlut.csd.ganymede.ReturnVal runEmbeddedTest()
          run a verification on the integrity of embedded objects and their containers
 arlut.csd.ganymede.ReturnVal runInvidSweep()
          run a long-running verification and repair operation on the Ganymede server's invid database links
 arlut.csd.ganymede.ReturnVal runInvidTest()
          run a long-running verification suite on the Ganymede server database's invid links
 arlut.csd.ganymede.ReturnVal runTaskNow(java.lang.String name)
          Causes a pre-registered task in the Ganymede server to be executed as soon as possible.
static void setConsoleCount()
          This static method sends an updated console count figure to all of the attached admin consoles.
static void setState(java.lang.String state)
          This static method changes the system state and sends it out to the consoles
static void setStatus(java.lang.String status)
          This static method is used to send debug log info to the consoles.
 arlut.csd.ganymede.ReturnVal shutdown(boolean waitForUsers)
          shutdown the server cleanly, on behalf of this admin console.
 arlut.csd.ganymede.ReturnVal stopTask(java.lang.String name)
          Causes a running task to be interrupted as soon as possible.
 java.lang.String toString()
           
 void unreferenced()
          This method is called when the Java RMI system detects that this remote object is no longer referenced by any remote objects.
static void updateCheckedOut()
          This static method updates the objects checked out count on all consoles.
static void updateLastDump()
          This static method updates the last dump time to all consoles.
static void updateLastDump(java.util.Date date)
          This static method is used to send the last dump time to the consoles.
static void updateLocksHeld()
          This static method updates the locks held count on all consoles.
static void updateMemState()
          This static method is used to send the server's memory status to all connected admin consoles.
static void updateMemState(long freeMem, long totalMem)
          This static method is used to update and transmit the server's memory status to the consoles.
static void updateTransCount()
          This static method is used to send the current transcount to the consoles.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

private static final boolean debug
See Also:
Constant Field Values

consoles

private static java.util.Vector consoles
Static vector of GanymedeAdmin instances, used to keep track of the attached admin consoles.


badConsoles

private static java.util.Vector badConsoles
Static vector of GanymedeAdmin instances for which remote exceptions were caught in the static update methods. Used by detachBadConsoles() to remove consoles that we were not able to communicate with.


state

private static java.lang.String state
The overall server state.. 'normal operation', 'shutting down', etc.


lastDumpDate

private static java.util.Date lastDumpDate
Timestamp that the Ganymede server last consolidated its journal file and dumped its database to disk.


freeMem

private static long freeMem
Free memory statistic that the server sends to admin consoles


totalMem

private static long totalMem
Total memory statistic that the server sends to admin consoles


adminName

private java.lang.String adminName
The name that the admin console authenticated with. We keep it here rather than asking the console later so that the console can't decide it should call itself 'supergash' at some later point.


clientHost

private java.lang.String clientHost
The name or ip address of the system that this admin console is attached from.


fullprivs

private boolean fullprivs
If true, the admin console is attached with full privileges to run tasks, shut down the server, and so on. If false, the user just has privileges to watch the server's operation.


proxy

private arlut.csd.ganymede.serverAdminProxy proxy

A server-side proxy that maintains an event queue for the admin console attached to this GanymedeAdmin object.

Constructor Detail

GanymedeAdmin

public GanymedeAdmin(arlut.csd.ganymede.Admin admin,
                     boolean fullprivs,
                     java.lang.String adminName,
                     java.lang.String clientHost)
              throws java.rmi.RemoteException

This is the GanymedeAdmin constructor, used to create a new server-side admin console attachment.

Admin is an RMI remote object exported by the client in the form of a callback.

This constructor is called from admin(), which is responsible for authenticating the name and password before calling this constructor.

Method Detail

closeAllConsoles

public static void closeAllConsoles(java.lang.String reason)

This static method handles sending disconnect messages to all attached consoles and cleaning up the GanymedeAdmin.consoles Vector.


setStatus

public static void setStatus(java.lang.String status)

This static method is used to send debug log info to the consoles. It is used by Ganymede.debug() to append information to the console logs.


setConsoleCount

public static void setConsoleCount()

This static method sends an updated console count figure to all of the attached admin consoles.


updateTransCount

public static void updateTransCount()
This static method is used to send the current transcount to the consoles.


updateLastDump

public static void updateLastDump(java.util.Date date)
This static method is used to send the last dump time to the consoles.


updateLastDump

public static void updateLastDump()
This static method updates the last dump time to all consoles.


updateMemState

public static void updateMemState(long freeMem,
                                  long totalMem)
This static method is used to update and transmit the server's memory status to the consoles.


updateMemState

public static void updateMemState()
This static method is used to send the server's memory status to all connected admin consoles.


updateCheckedOut

public static void updateCheckedOut()
This static method updates the objects checked out count on all consoles.


updateLocksHeld

public static void updateLocksHeld()
This static method updates the locks held count on all consoles.


setState

public static void setState(java.lang.String state)
This static method changes the system state and sends it out to the consoles


refreshUsers

public static void refreshUsers()

This static method is used to update the list of connnected users that appears in any admin consoles attached to the Ganymede server.


refreshTasks

public static void refreshTasks()

This static method is used to update the list of connnected users that appears in any admin consoles attached to the Ganymede server.


handleConsoleRMIFailure

private static final void handleConsoleRMIFailure(arlut.csd.ganymede.GanymedeAdmin console,
                                                  java.rmi.RemoteException ex)

This private static method handles communications link failures. Note that the serverAdminProxy will handle single instances of admin console RemoteExceptions so that only two RemoteExceptions in sequence will raise a RemoteException.

Any code that calls this method should call detachBadConsoles() once it has exited any loops over the static consoles vector to actually expunge any failed consoles from our consoles vector.


detachBadConsoles

private static void detachBadConsoles()

This private static method is called to remove any consoles that have experienced RMI failures from the static GanymedeAdmin.consoles vector. This method should never be called from within a loop over GanymedeAdmin.consoles.


doUpdateTransCount

private void doUpdateTransCount()
                         throws java.rmi.RemoteException

This private method is used to update this admin console handle's transaction count.

java.rmi.RemoteException

doUpdateLastDump

private void doUpdateLastDump()
                       throws java.rmi.RemoteException
This private method updates the last dump time on this admin console

java.rmi.RemoteException

doUpdateMemState

private void doUpdateMemState()
                       throws java.rmi.RemoteException
This private method updates the memory statistics display on this admin console

java.rmi.RemoteException

doUpdateCheckedOut

private void doUpdateCheckedOut()
                         throws java.rmi.RemoteException
This private method updates the objects checked out display on this admin console

java.rmi.RemoteException

doUpdateLocksHeld

private void doUpdateLocksHeld()
                        throws java.rmi.RemoteException
This private method updates the number of locks held display on this admin console

java.rmi.RemoteException

doSetState

private void doSetState()
                 throws java.rmi.RemoteException
This private method updates the server state display on this admin console

java.rmi.RemoteException

doRefreshUsers

private void doRefreshUsers(java.util.Vector entries)
                     throws java.rmi.RemoteException
This private method updates the user status table on this admin console

java.rmi.RemoteException

doRefreshTasks

private void doRefreshTasks(java.util.Vector scheduleHandles)
                     throws java.rmi.RemoteException
This private method updates the task status table on this admin console

java.rmi.RemoteException

forceDisconnect

public void forceDisconnect(java.lang.String reason)
                     throws java.rmi.RemoteException

This public method forces a disconnect of the remote admin console and cleans up the proxy.

This method *does not* handle removing this GanymedeAdmin console object from the static GanymedeAdmin.consoles Vector, so that it can safely be called from a loop over GanymedeAdmin.consoles in closeAllConsoles() when the server is being shut down.

java.rmi.RemoteException

toString

public java.lang.String toString()
Overrides:
toString in class java.rmi.server.RemoteObject

logout

public void logout()

Disconnect the remote admin console associated with this object

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

No server-side code should call this method from a thread that is looping over the static GanymedeAdmin.consoles Vector, or else the Vector will be changed from within the loop, possibly resulting in an exception being thrown.

Specified by:
logout in interface adminSession

logout

public void logout(java.lang.String reason)

Disconnect the remote admin console associated with this object

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

No server-side code should call this method from a thread that is looping over the static GanymedeAdmin.consoles Vector, or else the Vector will be changed from within the loop, possibly resulting in an exception being thrown.


unreferenced

public void unreferenced()

This method is called when the Java RMI system detects that this remote object is no longer referenced by any remote objects.

This method handles abnormal logouts and time outs for us. By default, the 1.1 RMI time-out is 10 minutes.

Specified by:
unreferenced in interface java.rmi.server.Unreferenced
See Also:
Unreferenced

refreshMe

public void refreshMe()
               throws java.rmi.RemoteException

This method lets the admin console explicitly request a refresh. Upon being called, the server will call several methods on the admin console's Admin interface to pass current status information to the console.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
refreshMe in interface adminSession
java.rmi.RemoteException

forceBuild

public arlut.csd.ganymede.ReturnVal forceBuild()

This method is called by admin console code to force a complete rebuild of all external builds. This means that all databases will have their last modification timestamp cleared and all builder tasks will be scheduled for immediate execution.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
forceBuild in interface adminSession

killAll

public arlut.csd.ganymede.ReturnVal killAll()

Kick all users off of the Ganymede server on behalf of this admin console

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
killAll in interface adminSession

kill

public arlut.csd.ganymede.ReturnVal kill(java.lang.String user)

Kick a user off of the Ganymede server on behalf of this admin console

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
kill in interface adminSession

shutdown

public arlut.csd.ganymede.ReturnVal shutdown(boolean waitForUsers)

shutdown the server cleanly, on behalf of this admin console.

Specified by:
shutdown in interface adminSession
Parameters:
waitForUsers - if true, shutdown will be deferred until all users are logged out. No new users will be allowed to login.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.


dumpDB

public arlut.csd.ganymede.ReturnVal dumpDB()

dump the current state of the db to disk

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
dumpDB in interface adminSession

runInvidTest

public arlut.csd.ganymede.ReturnVal runInvidTest()

run a long-running verification suite on the Ganymede server database's invid links

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
runInvidTest in interface adminSession

runInvidSweep

public arlut.csd.ganymede.ReturnVal runInvidSweep()

run a long-running verification and repair operation on the Ganymede server's invid database links

Removes any invid pointers in the Ganymede database whose targets are not properly defined. This should not ever happen unless there is a bug some place in the server.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
runInvidSweep in interface adminSession

runEmbeddedTest

public arlut.csd.ganymede.ReturnVal runEmbeddedTest()

run a verification on the integrity of embedded objects and their containers

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
runEmbeddedTest in interface adminSession

runEmbeddedSweep

public arlut.csd.ganymede.ReturnVal runEmbeddedSweep()

Removes any embedded objects which do not have containers.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
runEmbeddedSweep in interface adminSession

runTaskNow

public arlut.csd.ganymede.ReturnVal runTaskNow(java.lang.String name)

Causes a pre-registered task in the Ganymede server to be executed as soon as possible. This method call will have no effect if the task is currently running.

Specified by:
runTaskNow in interface adminSession
Parameters:
name - The name of the task to run

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.


stopTask

public arlut.csd.ganymede.ReturnVal stopTask(java.lang.String name)

Causes a running task to be interrupted as soon as possible. Ganymede tasks need to be specifically written to be able to respond to interruption, so it is not guaranteed that the task named will always be able to safely or immediately respond to a stopTask() command.

Specified by:
stopTask in interface adminSession
Parameters:
name - The name of the task to interrupt

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.


disableTask

public arlut.csd.ganymede.ReturnVal disableTask(java.lang.String name)

Causes a registered task to be made ineligible for execution until enableTask() is called. This method will not stop a task that is currently running.

Specified by:
disableTask in interface adminSession
Parameters:
name - The name of the task to disable

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.


enableTask

public arlut.csd.ganymede.ReturnVal enableTask(java.lang.String name)

Causes a task that was temporarily disabled by disableTask() to be available for execution again.

Specified by:
enableTask in interface adminSession
Parameters:
name - The name of the task to enable

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.


editSchema

public arlut.csd.ganymede.SchemaEdit editSchema()

Lock the server to prevent client logins and edit the server schema. This method will return a SchemaEdit remote reference to the admin console, which will present a graphical schema editor using this remote reference. The server will remain locked until the admin console commits or cancels the schema editing session, either through affirmative action or through the death of the admin console or the network connection. The DBSchemaEdit class on the server coordinates everything.

This method is part of the adminSession remote interface, and may be called remotely by attached admin consoles.

Specified by:
editSchema in interface adminSession